R Programming: 35 Job Interview Questions and Answers

Read the questions. At the bottom, you will find a link to the answers.

The Questions

First Set

  1. Explain what is R?
  2. List out some of the function that R provides?
  3. Explain how you can start the R commander GUI?
  4. In R how you can import Data?
  5. Mention what does not ‘R’ language do?
  6. Explain how R commands are written?
  7. How can you save your data in R?
  8. Mention how you can produce co-relations and covariances?
  9. Explain what is t-tests in R?
  10. Explain what is With () and By () function in R is used for?
  11. What are the data structures in R that is used to perform statistical analyses and create graphs?
  12. Explain general format of Matrices in R?
  13. In R how missing values are represented ?
  14. Explain what is transpose?
  15. Explain how data is aggregated in R?
  16. What is the function used for adding datasets in R?
  17. What is the use of subset() function and sample() function in R ?
  18. Explain how you can create a table in R without external file?

You can find the answers here

Second Set

  1. Data structure -- How many data structures R has? How do you build a binary search tree in R? 
  2. Sorting -- How many sorting algorithms are available? Show me an example in R. 
  3. Low level -- How do you build a R function powered by C? 
  4. String -- How do you implement string operation in R?
  5. Vectorization -- If you want to do Monte Carlo simulation by R, how do you improve the efficiency? 
  6. Function -- How do you take function as argument of another function? What is the apply() function family? 
  7. Threading -- How do you do multi-threading in R? 
  8. Memory limit and database -- What is the memory limit of R? How do you avoid it? How do you use SQL in R? 
  9. Testing -- How do you do testing and debugging in R?
  10. Software development -- How do you develop a package? How do you do version control?

You can find the answers here.

Third Set 

1. If I have a data.frame df <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6), c(7, 8, 9))...

  • How do I select the c(4, 5, 6)?
  • How do I select the 1?
  • How do I select the 5?
  • What is df[, 3]?
  • What is df[1,]?
  • What is df[2, 2]?

2. What is the difference between a matrix and a dataframe?

3. If I concatenate a number and a character together, what will the class of the resulting vector be?

4. What if I concatenate a number and a logical?

5. What if I concatenate a number and NA?

6. What is the difference between sapply and lapply? When should you use one versus the other? Bonus: When should you use vapply?

7. What is the difference between seq(4) and seq_along(4)?

8. What is f(3) where:

y <- 5 f <- function(x) { y <- 2; y^2 + g(x) } g <- function(x) { x + y }


9. I want to know all the values in c(1, 4, 5, 9, 10) that are not in c(1, 5, 10, 11, 13). How do I do that with one built-in function in R? How could I do it if that function didn't exist?

10. Can you write me a function in R that replaces all missing values of a vector with the mean of that vector?

11. How do you test R code? Can you write a test for the function you wrote in #6?

12. Say I have...

fn(a, b, c, d, e) a + b * c - d / e

How do I call fn on the vector c(1, 2, 3, 4, 5) so that I get the same result as fn(1, 2, 3, 4, 5)? (No need to tell me the result, just how to do it.)

13. dplyr <- "ggplot2" library(dplyr)

Why does the dplyr package get loaded and not ggplot2?

14. mystery_method <- function(x) { function(z) Reduce(function(y, w) w(y), x, z) } fn <- mystery_method(c(function(x) x + 1, function(x) x * x)) fn(3)

What is the value of fn(3)? Can you explain what is happening at each step?

You can find the answers here

Other R questions are posted here

Related articles

Views: 36869


You need to be a member of Data Science Central to add comments!

Join Data Science Central

Comment by Idriss Kougoum on July 3, 2020 at 6:07am

Nice stuff!

Comment by Dragos Bandur on February 1, 2017 at 9:43am

I find some answers incomplete and/or misleading.

Comment by Ehsan Siavashi on October 24, 2016 at 3:38pm

Good stuff, Thank you for posting this. Just some questions: Is there a typo in question 6? Did you mean 'comment' instead of 'command'? On question 7, 'save' function is a good option too. Also in the question 8, maybe it meant to be 'correlation' nor 'co-relation' as the answer refers to the cor() function.

© 2021   TechTarget, Inc.   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service