Affine R Programming Interview Questions & Answers
Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
About Affine hiring for R Programming roles
Affine is a Bengaluru-based analytics and AI consulting company that helps businesses in gaming, media, retail, consumer goods and technology use data science for decisions. Its teams build predictive models, marketing analytics, pricing solutions and data engineering pipelines. It hires business analysts, data scientists, data engineers and analytics consultants who combine technical skills with business understanding.
For R Programming roles, this Affine practice set focuses most on Modelling and Machine Learning in R (7), Data Visualization with ggplot2 (5), Data Structures in R (4), Functions and Functional Programming (4). It has 5 easy, 20 medium, 5 hard questions, so you can start easy and work up to the harder ones.
Company type
Analytics
Headquarters
Bengaluru, India
Main India offices
Bengaluru
Affine R Programming interview process
Online assessment (aptitude + SQL + statistics)
Technical interview
Case study round
HR round
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for AffineStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
geom_smooth() adds a fitted trend line with a confidence band, using loess for small data and a GAM for large data by default, or method = 'lm' for a straight line. stat_summary() computes summaries of y for each x, for example stat_summary(fun = mean, geom = 'point') to plot group means, or fun.data = mean_cl_normal for error bars. Both let you show patterns without precomputing summaries.
02
Dates in your file look like 25/12/2025 and as.Date() returns NA. What is wrong and how do you fix it?
Indian files often store dates as dd/mm/yyyy, but as.Date() expects yyyy-mm-dd by default, so values become NA. I specify the format, as.Date(x, format = '%d/%m/%Y'), or use lubridate::dmy(x), which handles different separators automatically. Then I count NAs before and after conversion to confirm nothing failed silently. If the column came from Excel as serial numbers, I use as.Date(x, origin = '1899-12-30') instead.
03
How do you add labels and annotations to a ggplot chart?
I wrap each call with purrr::safely() or tryCatch() so one failure does not stop the loop, and add retries with exponential backoff, which httr2 supports through req_retry(). I respect rate limits with Sys.sleep() or req_throttle(). I save results incrementally, for example every 100 calls to an RDS file or database, so a restart resumes from the last checkpoint. Finally I log failed IDs and rerun only those.
06
Write a tidymodels workflow to train and evaluate a random forest.
This is Simpson's paradox. It happens when a confounding variable, here hospital or patient severity, is unevenly distributed between groups. If A was used mostly in hospitals with easier cases, its overall rate looks better even though B wins within each hospital. In R I would group by hospital and compare rates, then use a stratified analysis or regression with hospital as a covariate to estimate the adjusted effect.
Conversion is a proportion, so I use a two-proportion test: prop.test(c(conv_a, conv_b), c(n_a, n_b)). I check the p-value and, more importantly, the confidence interval for the difference. Before trusting it, I confirm the sample size was planned in advance, the test ran for full weeks to cover weekday effects, users were randomized properly and nobody stopped the test early when results looked good. Then I judge business significance.
12
After merging two data frames you get more rows than expected. What happened?
Extra rows after a join usually mean the key is duplicated in one or both tables, so each match multiplies rows. I check uniqueness with df %>% count(key) %>% filter(n > 1) on both sides. Then I decide whether to deduplicate, aggregate before joining or join on a composite key such as customer_id plus month. In dplyr 1.1 and later, the relationship argument, for example 'many-to-one', makes the join fail loudly when this assumption breaks.
13
How do you produce descriptive statistics for each group in R?
The forecast package provides auto.arima(), ets() for exponential smoothing and easy plotting of forecasts with intervals. The newer tidyverts family, with tsibble for time-series data frames, fable for models and feasts for features and decomposition, works with tidy data and fits many series at once. prophet handles strong seasonality and holidays. Typical steps are visualizing, decomposing trend and seasonality, fitting candidates and comparing accuracy on a holdout period.
15
In your regression, coefficient signs look wrong and standard errors are huge. What might be the problem?
This is a classic sign of multicollinearity, where predictors are highly correlated, for example total spend and online spend. The model cannot separate their effects, so coefficients become unstable. I check correlations and the variance inflation factor with car::vif(); values above 5 or 10 are a concern. Solutions are removing or combining correlated variables, using principal components or ridge regression. Prediction accuracy may be fine, but interpretation is unreliable.
Skewness measures asymmetry of a distribution. Positive or right skew has a long right tail, typical of income and order values, so the mean exceeds the median. Negative skew has a long left tail. Kurtosis measures how heavy the tails are compared with a normal distribution; high kurtosis means more extreme values, common in financial returns. In R, the moments or e1071 packages provide skewness() and kurtosis() functions.
18
Describe a disagreement with a teammate about a technical approach.
Situation: a teammate wanted to build our reporting pipeline in Excel macros, while I preferred R scripts. Task: agree on an approach quickly. Action: instead of arguing, we listed requirements together: refresh frequency, data size and who would maintain it. I built a small R prototype in a day to compare. Result: we chose R for the pipeline and kept an Excel output for users, and my teammate later helped improve the formatting.
19
How do you create a column with multiple conditions in dplyr?
I save the fitted workflow, including the recipe, with saveRDS() or the vetiver package, which versions models and adds monitoring. For batch scoring, a scheduled R script reads new customers from the database, predicts and writes scores back, run by cron, Posit Connect or a container in the cloud. For real-time needs, I expose the model as a REST API with plumber or vetiver in Docker. I log inputs and track drift.
21
How do you use Reduce(), Filter() and Map() in base R?
This is overplotting. I reduce point size and add transparency with geom_point(alpha = 0.1, size = 0.5). Better options are geom_hex() or geom_bin2d(), which show density as colour, or geom_density_2d() contours. I could also plot a random sample for shape and a smoothed trend with geom_smooth() on the full data. If x values are discrete, geom_jitter() spreads points. The goal is to make density visible, not every point.
23
Tell me about a chart or visualization that changed a business decision.
Situation: the operations team believed late deliveries were spread evenly across the week. Task: I was asked to review delivery data. Action: in R I built a heatmap of late deliveries by weekday and hour with ggplot2, which showed a sharp cluster on Monday mornings linked to weekend order backlog. Result: management added a Sunday evening shift, and late deliveries dropped by about 18 percent the next quarter.
24
Tell me about the messiest dataset you have cleaned.
Situation: I received three years of vendor invoices from different branches in Excel files with inconsistent headers, merged cells and dates in four formats. Task: build one clean table for spend analysis. Action: I used readxl to read all sheets, janitor::clean_names() to standardise headers, lubridate to parse dates and a mapping table for vendor name variants. I wrote validation checks for totals. Result: a clean dataset of 180,000 rows that finance now refreshes monthly.
25
How does a random forest work and which R packages implement it?
A random forest builds many decision trees, each on a bootstrap sample of rows and considering a random subset of features at each split, then averages their predictions for regression or takes a majority vote for classification. This reduces the variance of single trees and handles non-linear relationships well. In R, randomForest is the classic package and ranger is a much faster implementation. Key parameters are the number of trees, mtry and minimum node size.
26
Your function fails with 'the condition has length > 1' when given a vector. What is wrong?
An if statement can only check a single TRUE or FALSE value, and since R 4.2 a longer condition is an error. The function was written for one value but received a vector. I would replace if with a vectorized alternative such as ifelse(), dplyr::if_else() or case_when(). If the function is truly meant for single values, I validate the input length with stopifnot(length(x) == 1) or apply it over elements with purrr::map().
27
Code reviews show inconsistent R code style across the team. How would you standardise it?
I would adopt the tidyverse style guide as the team standard, then automate it rather than relying on reviewers. styler reformats code automatically, including an RStudio add-in, and lintr flags issues such as long lines, unused variables and inconsistent naming. I add lintr to a pre-commit hook or a GitHub Actions check so pull requests are checked automatically. A short template for new scripts and projects helps new joiners follow the same structure.
28
Your manager says your charts are confusing. How do you respond?
I would thank them and ask which part was unclear, such as too many colours, missing labels or an unclear message. In my internship this happened with a crowded chart of twelve product lines. I simplified it by highlighting the top three, greying the rest, adding a clear title stating the finding and labelling values directly. My manager found the new version easy to present, and I now review every chart for one clear message.
29
How do you interpret the summary output of an lm() model?
Each coefficient is the expected change in the outcome for a one-unit increase in that predictor, holding others constant. The p-value tests whether the coefficient differs from zero. R-squared is the share of variance explained, and adjusted R-squared penalizes extra predictors. Residual standard error shows typical prediction error in outcome units. The F-statistic tests whether the model beats an intercept-only model. For factors, coefficients are differences from the reference level.
30
How do you install and load a package, and what is the difference between library() and require()?
install.packages() downloads from CRAN once; library() loads it in every session. library() throws an error if the package is missing, while require() returns FALSE with a warning, so require() suits conditional checks.
install.packages('dplyr')
library(dplyr)
if (!require('data.table')) {
install.packages('data.table')
library(data.table)
}
Tips to crack the Affine R Programming interview
Practise SQL and Python data manipulation, and be ready to solve a small analysis problem using a sample dataset.
Revise statistics concepts like distributions, sampling and A/B testing, and explain how they guide real business decisions.
Prepare for case questions on topics like customer churn or pricing, structuring your approach before jumping into models.
Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
Practise the hard questions on this page aloud; Affine interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the Affine R Programming interview?
Candidates usually go through 4 stages: Online assessment (aptitude + SQL + statistics); Technical interview; Case study round; HR round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.
Which topics should I prepare for the Affine R Programming interview?
This practice set leans on Modelling and Machine Learning in R (7), Data Visualization with ggplot2 (5), Data Structures in R (4), Functions and Functional Programming (4). Revise those first, then practise explaining one or two of your own projects end to end, because most Affine interviewers ask you to walk through real work.
Are these the exact questions asked at Affine?
No. These are curated practice questions that match the skills and difficulty usually tested in analytics interviews like Affine's. They are not a leaked or verified list of past questions.
Where does Affine hire R Programming professionals in India?
Affine has large teams in Bengaluru. Openings and locations change often, so check the Affine careers page and filter by city and experience.