R Tutorial menu

R Quiz

Check your R knowledge with this quiz covering the whole tutorial.

How the Quiz Works

There are ten questions. Choose an answer for each one to see if it is correct, along with a short explanation. If you get one wrong, go back to that lesson and read it again.

QuestionsTopics
1 to 3Syntax, variables and data types
4 to 6Vectors, lists, matrices and factors
7 to 8Data frames
9 to 10If else, loops and functions

Questions

Exercise

1. What does this code print? x <- 7; x %% 3

Exercise

2. What does paste0("Roll-", 25) return?

Exercise

3. What does as.numeric("abc") give?

Exercise

4. If x <- c(4, 8, 15), what is x[2]?

Exercise

5. What does mean(c(2, NA, 6)) return?

Exercise

6. Which structure should you use to count how many customers bought size S, M or L?

Exercise

7. In a data frame df, what does df[3, ] return?

Exercise

8. Which function reads a CSV file into a data frame?

Exercise

9. Which keyword skips the rest of the current loop round and moves to the next item?

Exercise

10. What does this code print? f <- function(a, b = 10) a + b; f(5)

What Next?

Scored 8 or more? You are ready to work with real data. Try the Data Science tutorial next. Scored less? Revisit the lessons on vectors, data frames and functions, then try again.

Learn R with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp