readyforhires

Advanced R test (Advanced)

40 questions · 40 minutes · Free

Statistical modelling, performance and packages.

Take the Advanced R test

What it covers

Interview format

Sample questions

5 sample questions from the Advanced R test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. Which of the following expressions correctly computes the odds ratios for a logistic regression model stored in the object `fit`?

    1. exp(coef(fit))
    2. summary(fit)$coefficients
    3. coef(fit)
    4. predict(fit, type = 'response')

    Answer: A. exp(coef(fit))

    In logistic regression, the coefficients represent log-odds. To obtain odds ratios, the exponential function `exp()` is applied to the coefficients. This is a key step in interpreting the impact of each predictor on the outcome.

  2. In a Shiny app, you are using `outputProxy` to dynamically update a plot. However, the plot is re-rendering unnecessarily when other inputs change. What is the best practice to avoid this?

    1. Use `observeEvent` to manually trigger updates to the proxy output.
    2. Use `renderUI` with `outputProxy` to dynamically update the proxy output.
    3. Use `reactiveVal` to store the proxy output and update it manually.
    4. Use `outputProxy` with `isolate` to prevent unnecessary re-rendering.

    Answer: D. Use `outputProxy` with `isolate` to prevent unnecessary re-rendering.

    When using `outputProxy` in Shiny, wrapping the reactive expression with `isolate` ensures that the proxy output does not re-render unnecessarily when other reactive values change. This is a common approach to optimize performance and avoid unexpected behavior in complex Shiny apps.

  3. Which of the following is the most effective way to improve performance in base R when working with large datasets?

    1. Using `for` loops with preallocated vectors for better performance
    2. Using `apply()` for faster computation on data frames
    3. Using vectorised functions like `rowSums()` or `pmax()` instead of `for` loops
    4. Avoiding `ifelse()` in favour of `if` and `else` for better control flow

    Answer: C. Using vectorised functions like `rowSums()` or `pmax()` instead of `for` loops

    Vectorised functions in base R are implemented in C and execute much faster than `for` loops in R, which are slower due to interpretation overhead. This is a key principle of performance optimisation in R.

  4. Which approach correctly enables syntax highlighting in an R Markdown document while also ensuring that code chunks are displayed with comments removed?

    1. Add `highlight: true` to the YAML metadata and use `highlight::highlight()` in the code chunks.
    2. Apply `highlight::highlight()` to the entire document in the YAML header.
    3. Use `knitr::opts_chunk$set(echo = TRUE, comment = NA, highlight = TRUE)` in the YAML header.
    4. Use `rmarkdown::render()` with the `highlight = TRUE` argument.

    Answer: C. Use `knitr::opts_chunk$set(echo = TRUE, comment = NA, highlight = TRUE)` in the YAML header.

    The `knitr::opts_chunk$set()` function is used in the YAML header to configure chunk options globally. Setting `highlight = TRUE` enables syntax highlighting, `echo = TRUE` displays the code, and `comment = NA` removes comments from the output. Other options do not provide the correct configuration for syntax highlighting.

  5. What does it indicate if the residuals of a linear model do not follow a normal distribution?

    1. The model's predictions have high variance.
    2. The model's residuals are not normally distributed.
    3. The model has high multicollinearity among predictors.
    4. The model's coefficients are not statistically significant.

    Answer: B. The model's residuals are not normally distributed.

    In linear model diagnostics, if the residuals are not normally distributed, it indicates that the assumptions of the linear regression model are violated. This can be checked using a Q-Q plot or statistical tests like the Shapiro-Wilk test. The other options relate to different aspects of model performance or assumptions but are not directly related to the normality of residuals.

Frequently asked questions

How many questions are in the Advanced R test?
40 questions (24 multiple choice, 12 multi-answer, 4 predict-the-output), with 40 minutes to answer them.
What does the Advanced R test cover?
Linear and logistic models, Vectorisation and performance, Writing packages, Shiny, R Markdown and reproducibility.
Is the Advanced R test free?
Yes. It is free to take with a readyforhires account.
What level is the Advanced R test?
Advanced, in Data.

More Data tests

Roles that test these skills

Companies that test these skills

All practice tests · All Data tests

Last updated