Q1. What is the purpose of the RStudio IDE mentioned in the text?
- A. It is used to download and install the latest version of R.
- B. It is used to create and save R scripts.
- C. It is used to run R codes and view outputs.
- D. It is used to generate random numbers from the normal distribution.
Select the answer that is more appropriate.
Q2. Which function is used to set a seed for reproducibility in random number generation?
- A. set.seed()
- B. exp()
- C. rnorm()
- D. curve()
Try ? and then each command in R to find out their usage.
Q3. How can you change the name of variables/columns in a data frame?
- A. Using the colnames() function
- B. Using the dim() function
- C. Using the rbind() function
- D. Using the for loop function
Select the answer that is more appropriate.
Q4. If we set the seed to 11 and generate 10 random numbers from a normal distribution, will we get the same result each time we run it?
Select the answer that is more appropriate.
Q5. How can you change the column names of a data frame called df to 'Studyid', 'Grade', and 'Sex' in R?
- A. names(df) <- c('Studyid', 'Grade', 'Sex')
- B. colnames(df) <- c('Studyid', 'Grade', 'Sex')
- C. df$names <- c('Studyid', 'Grade', 'Sex')
- D. df$colnames <- c('Studyid', 'Grade', 'Sex')
Select the answer that is more appropriate.
Q6. How can you extract the value from the first row and first column of a data frame called df in R?
- A. df[0, 0]
- B. df[1, 1]
- C. df[0][0]
- D. df[1][1]
Select the answer that is more appropriate.
Q7. How can you combine two matrices into a list in R?
- A. c(matrix1, matrix2)
- B. list(matrix1, matrix2)
- C. combine(matrix1, matrix2)
- D. join(matrix1, matrix2)
Select the answer that is more appropriate.
Q8. How do you create a matrix with 5 rows and 2 columns filled by rows in R?
- A. matrix(x, row = 5, col = 2, byrow = TRUE)
- B. matrix(x, nrows = 5, ncols = 2, byrow = TRUE)
- C. matrix(x, r = 5, c = 2, byrow = TRUE)
- D. matrix(x, nrows = 5, ncols = 2, byrow = TRUE)
Select the answer that is more appropriate.
Q9. How do you create a vector with values ranging from 0 to 100 in steps of 10 in R?
- A. c(0, 100, 10)
- B. seq(0, 100, 10)
- C. seq(by = 0, from = 100, to = 10)
- D. range(0, 100, 10)
Select the answer that is more appropriate.
Q10. How can you set a seed to ensure reproducible results in R?
- A. seed(11)
- B. rnorm(seed = 11)
- C. set.seed(11)
- D. random.seed(11)
Select the answer that is more appropriate.
Q11. What is the output of the command exp(2)?
- A. 2
- B. 7.389056
- C. 1
- D. 10
Select the answer that is more appropriate.
Q12. If x1 <- 2 and y1 <- x1^2, what is the value of y1?
Select the answer that is more appropriate.