R Programming Interview Questions & Answers
All 200 unique questions in one place — 58 easy, 97 medium, 45 hard — grouped by topic.
Practise by topic
Practise the way your interview works
What are the atomic data types in R?
Show answer
What is the difference between <- and = for assignment in R?
Show answer
How do you install and load a package, and what is the difference between library() and require()?
Show answer
What is a factor in R and when would you use one?
Show answer
A numeric column in your data has been read as character. How do you fix it?
Show answer
How do you create sequences and repeated values in R?
Show answer
How do you handle missing values in calculations in R?
Show answer
Why did you choose to learn R?
Show answer
How do you manage working directories and file paths in an R project?
Show answer
Your analysis gives slightly different results every time you run it. How do you make it reproducible?
Show answer
Explain the difference between NA, NULL and NaN in R.
Show answer
What is type coercion in R and how can it cause bugs?
Show answer
What is vectorization in R and why does it matter?
Show answer
What is the recycling rule in R?
Show answer
Your R script works on your laptop but fails on a colleague's machine with 'could not find function'. What do you check?
Show answer
Reading a 2 GB CSV file with read.csv() is very slow. What would you do?
Show answer
How do you find out why your R code is slow?
Show answer
How would you compare R and Python for a data role?
Show answer
Tell me about a time you automated a manual report.
Show answer
Explain environments and lexical scoping in R.
Show answer
What is lazy evaluation in R?
Show answer
What does copy-on-modify mean in R and how does it affect performance?
Show answer
Your R session runs out of memory while processing a large dataset. What steps do you take?
Show answer
What are the differences between S3, S4 and R6 classes?
Show answer
What is the difference between a vector and a list in R?
Show answer
What is a data frame in R?
Show answer
How is a matrix different from a data frame?
Show answer
Show different ways to index vectors and data frames in R.
Show answer
Dates in your file look like 25/12/2025 and as.Date() returns NA. What is wrong and how do you fix it?
Show answer
What is an array in R?
Show answer
How do you explain technical results to non-technical managers?
Show answer
What is the difference between [ ], [[ ]] and $ when subsetting?
Show answer
What does drop = FALSE do when subsetting?
Show answer
Explain the apply family of functions in R.
Show answer
How do you create, modify and combine lists in R?
Show answer
You receive 60 monthly CSV files with the same structure. How do you combine them into one data frame?
Show answer
A loop that adds rows to a data frame with rbind() takes very long. How do you speed it up?
Show answer
What is a tibble and how does it differ from a base data frame?
Show answer
What is data.table and when would you use it?
Show answer
Write common data.table operations for filtering, aggregating and joining.
Show answer
How do you clean and manipulate text data in R?
Show answer
How are dates and times handled in R?
Show answer
After merging two data frames you get more rows than expected. What happened?
Show answer
Describe a time you found a data quality issue in your analysis.
Show answer
Tell me about a time you had two urgent analysis requests at the same time.
Show answer
What is a list-column and why is it useful?
Show answer
Write code to fit one regression model per group using nested data.
Show answer
Are factors more memory efficient than character vectors in modern R?
Show answer
An API returns deeply nested JSON. How do you turn it into a tidy data frame in R?
Show answer
What is the tidyverse?
Show answer
What are the main dplyr verbs?
Show answer
What are the principles of tidy data?
Show answer
Write dplyr code to find total and average sales by city, sorted by total.
Show answer
How do you split one column into several, or combine columns into one?
Show answer
Finance says 120 transactions are missing from your report compared with their system. How do you find them?
Show answer
What is the difference between mutate() and summarise()?
Show answer
What is the difference between %>% and |> in R?
Show answer
How do you create a column with multiple conditions in dplyr?
Show answer
Explain the different types of joins in dplyr.
Show answer
How do you reshape data between wide and long formats in R?
Show answer
How do you apply the same transformation to many columns in dplyr?
Show answer
What window functions does dplyr provide?
Show answer
You need month-over-month sales growth for each product. How do you calculate it in R?
Show answer
A customer table has multiple records per customer. How do you keep only the latest record for each?
Show answer
Salary data has a few extreme values that distort averages. How do you handle them?
Show answer
How would you impute missing values differently for each group?
Show answer
What are semi_join() and anti_join() used for?
Show answer
Why is ungroup() important in dplyr?
Show answer
Tell me about the messiest dataset you have cleaned.
Show answer
Your dplyr pipeline is too slow on a 50 million row dataset. What are your options?
Show answer
What is dbplyr and how does it work?
Show answer
What is tidy evaluation and why do you need {{ }} in functions?
Show answer
Write a reusable function that summarises any numeric column by any grouping column using dplyr.
Show answer
Describe a mistake you made in an analysis and how you handled it.
Show answer
What is the grammar of graphics in ggplot2?
Show answer
Which chart types would you use for comparing categories, trends and distributions?
Show answer
Write ggplot2 code for a monthly sales line chart with points.
Show answer
Write code to show the distribution of order values using a histogram and a boxplot by category.
Show answer
How do you save a ggplot chart for a report or presentation?
Show answer
Bars in your chart appear in alphabetical order instead of by value. How do you fix it?
Show answer
What is the difference between base R graphics and ggplot2?
Show answer
Your manager says your charts are confusing. How do you respond?
Show answer
What is the difference between mapping and setting an aesthetic in ggplot2?
Show answer
What is the difference between geom_bar() and geom_col()?
Show answer
What are facets in ggplot2?
Show answer
How do you customise scales, labels and themes in ggplot2?
Show answer
Your scatter plot of 200,000 points looks like a solid blob. How do you fix it?
Show answer
Some stakeholders are colour-blind. How do you design charts for them?
Show answer
How do you create interactive charts in R?
Show answer
How do you add labels and annotations to a ggplot chart?
Show answer
What do geom_smooth() and stat_summary() do?
Show answer
What makes a chart misleading?
Show answer
Tell me about a chart or visualization that changed a business decision.
Show answer
Leadership wants a single report page with 15 charts. How do you approach it?
Show answer
Why are dual-axis charts discouraged and how does ggplot2 handle secondary axes?
Show answer
Rendering a ggplot with 10 million points is extremely slow. What would you do?
Show answer
What is the difference between coord_cartesian() limits and scale limits in ggplot2?
Show answer
How would you create a reusable branded theme for all team charts?
Show answer
How do you create maps in R?
Show answer
When would you report the median instead of the mean?
Show answer
What is the difference between variance and standard deviation?
Show answer
Why does correlation not imply causation?
Show answer
How do you produce descriptive statistics for each group in R?
Show answer
What are skewness and kurtosis?
Show answer
How do you keep improving your statistics knowledge?
Show answer
What is the Central Limit Theorem and why is it important?
Show answer
What is a p-value?
Show answer
Explain Type I and Type II errors.
Show answer
How do you perform a t-test in R?
Show answer
How do you test whether two categorical variables are related in R?
Show answer
What is the difference between Pearson and Spearman correlation?
Show answer
You ran an A/B test on a checkout page: 4.1 percent conversion versus 4.6 percent. How do you decide if the difference is real?
Show answer
Your data is heavily skewed and the sample is small. Can you still use a t-test?
Show answer
What does a 95 percent confidence interval mean?
Show answer
Explain the d, p, q and r functions for probability distributions in R.
Show answer
How do you check whether data is normally distributed in R?
Show answer
How do you compare means across more than two groups in R?
Show answer
Product wants to detect a lift in conversion from 5 to 5.5 percent. How many users do you need per group?
Show answer
What is the multiple testing problem and how do you correct for it?
Show answer
What is bootstrapping and when would you use it?
Show answer
A manager says a test with p = 0.06 proves the change had no effect. How do you respond?
Show answer
You are analysing a national survey where some groups were deliberately oversampled. How do you compute correct averages?
Show answer
Overall, treatment A has a higher success rate than B, but B is better in every hospital. How is that possible?
Show answer
Tell me about a time your analysis did not support what a stakeholder hoped to see.
Show answer
How do you write a function in R with default arguments?
Show answer
What is the difference between if, ifelse() and dplyr's if_else()?
Show answer
Explain for, while and repeat loops in R.
Show answer
Write a recursive function in R to calculate factorial and Fibonacci numbers.
Show answer
How does the switch() function work in R?
Show answer
Describe a time you learned something from a teammate.
Show answer
How do you handle errors in R code?
Show answer
What does the ... (dots) argument do in an R function?
Show answer
What is the purrr map family?
Show answer
Write code using map2() and pmap() to iterate over multiple inputs.
Show answer
How do you validate inputs inside an R function?
Show answer
Your function gives correct results when you test it but wrong results in the main script. What could be the cause?
Show answer
How do you debug an R function?
Show answer
Your function fails with 'the condition has length > 1' when given a vector. What is wrong?
Show answer
What is a pure function and why prefer them in data pipelines?
Show answer
The same 40 lines of cleaning code are copied into ten scripts. What would you do?
Show answer
What is the difference between errors, warnings and messages in R?
Show answer
Tell me about feedback you received in a code review and what you changed.
Show answer
What are closures and function factories in R?
Show answer
A loop calls an external API 5,000 times and crashes at call 3,200. How do you make it robust?
Show answer
How do you run R code in parallel?
Show answer
A simulation loop runs for 40 minutes. How would you speed it up?
Show answer
What is Rcpp and when would you use it?
Show answer
How do you use Reduce(), Filter() and Map() in base R?
Show answer
A function that looks up exchange rates is called thousands of times with the same inputs and is slow. How do you fix it?
Show answer
How do you build a linear regression model in R?
Show answer
Why do we split data into training and test sets, and what is cross-validation?
Show answer
What is overfitting and how do you prevent it?
Show answer
Explain the confusion matrix and the metrics derived from it.
Show answer
What are the assumptions of linear regression?
Show answer
Why should we hire you as a fresher for an R analyst role?
Show answer
How do you interpret the summary output of an lm() model?
Show answer
How do you build a logistic regression model for churn in R?
Show answer
What is tidymodels and how does it compare with caret?
Show answer
Write a tidymodels workflow to train and evaluate a random forest.
Show answer
You are building a fraud model where only 0.5 percent of transactions are fraud. How do you handle the imbalance?
Show answer
Your model has R-squared 0.92 on training data but 0.55 on test data. What do you do?
Show answer
How does a random forest work and which R packages implement it?
Show answer
In your regression, coefficient signs look wrong and standard errors are huge. What might be the problem?
Show answer
How do you perform k-means clustering in R?
Show answer
How do you do feature engineering with recipes in tidymodels?
Show answer
What tools does R offer for time series forecasting?
Show answer
How do you calculate ROC AUC and plot an ROC curve in R?
Show answer
Walk me through an end-to-end machine learning project you have done in R.
Show answer
A predictor such as pincode has 500 levels. How do you use it in a model?
Show answer
You are asked to forecast daily demand for the Diwali season. How do you approach it?
Show answer
What is regularization and how do you apply it in R?
Show answer
Business users do not trust your gradient boosting model because it is a black box. What do you do?
Show answer
Your R model must score new customers every morning for the CRM team. How would you deploy it?
Show answer
Tell me about a time a model you built did not perform as expected after deployment.
Show answer
What is R Markdown and why is it useful?
Show answer
What is Shiny and how is a Shiny app structured?
Show answer
What is renv and why should you use it?
Show answer
How do you connect R to a SQL database and run queries?
Show answer
Why should R projects use Git and how does RStudio support it?
Show answer
The finance team wants the daily output as a formatted Excel file, not a CSV. How do you produce it?
Show answer
Where do you see yourself in three years in an R or analytics career?
Show answer
What is the difference between Quarto and R Markdown?
Show answer
Explain reactivity in Shiny.
Show answer
Write a minimal Shiny app that filters sales by region and plots them.
Show answer
How do you generate the same report for each of 20 regions automatically?
Show answer
Your team wants to share a Shiny app with 200 internal users. What deployment options exist?
Show answer
What is the structure of an R package?
Show answer
How do you write unit tests for an R function?
Show answer
An R script must run every morning at 7 AM and email a report. How do you schedule it?
Show answer
You notice database passwords hardcoded in a shared R script. What do you do?
Show answer
What is plumber in R?
Show answer
Code reviews show inconsistent R code style across the team. How would you standardise it?
Show answer
How do you add logging to a production R script?
Show answer
Tell me about a dashboard or app you built in R.
Show answer
Describe a disagreement with a teammate about a technical approach.
Show answer
Your Shiny dashboard becomes very slow when 50 users open it at once. How do you improve it?
Show answer
What is the difference between reactive(), observe() and observeEvent() in Shiny?
Show answer
Your R pipeline works on your laptop but fails on the Linux server because of missing system libraries. How do you fix it permanently?
Show answer
Tell me about a time a production job failed and you had to fix it under pressure.
Show answer
Frequently asked questions
What jobs can I get after learning R programming?
R skills lead to roles such as Data Analyst, R Programmer, Statistical Programmer, Biostatistician, Data Scientist, Shiny Developer and Analytics Consultant. Analytics firms, consulting companies, pharma and clinical research organizations, banks, insurance companies and market research agencies hire R professionals. Freshers usually start as analysts working on reporting and data cleaning, then grow into modelling, statistical programming or dashboard development roles as they build experience and domain knowledge.
Who is eligible to learn R programming?
Anyone comfortable with basic mathematics can learn R. Students and graduates from B.Sc, B.Com, BBA, BCA, B.Tech, statistics, economics, life sciences and pharmacy backgrounds commonly take it up. Working professionals in finance, research, operations or Excel-heavy roles also switch to R for analytics. No prior coding experience is required, although basic statistics and SQL knowledge will help you progress faster and perform better in interviews.
How long does it take to learn R for a job?
With regular practice of one to two hours daily, most learners become job-ready for an entry-level analyst role in about three months. The first month covers fundamentals and data wrangling, the second visualization and statistics, and the third modelling, reporting and projects. Becoming strong in advanced areas such as Shiny development, statistical programming or machine learning usually takes another six to twelve months of hands-on work.
Is R still relevant in 2026 compared with Python?
Yes. R remains a leading language for statistics, biostatistics, clinical research, econometrics and reproducible reporting, and the tidyverse, tidymodels, Quarto and Shiny ecosystems are actively developed. Python is more common for general software and deep learning, so many teams use both. Learning R deeply along with SQL and basic Python makes you flexible across analytics, research and data science roles in India.
Do I need a certification to get an R job?
A certification helps show structured learning, but employers mainly judge practical ability. A course completion certificate combined with a portfolio of three or four projects on GitHub, such as a cleaned dataset analysis, a Quarto report, a predictive model and a Shiny dashboard, is far more convincing. Be ready to write dplyr and ggplot2 code live and to explain statistical results clearly during interviews.
What projects should I build to get hired as an R analyst?
Build projects that mirror real work: a sales or e-commerce analysis with dplyr and ggplot2, an A/B test analysis with proper hypothesis testing, a churn or credit risk model in tidymodels, a time series forecast for demand and an interactive Shiny dashboard. Use public Indian datasets where possible, publish code on GitHub with clear README files and write short summaries of business insights for each project.