R Programming Quiz

Last Updated :
Discuss
Comments

Question 1

How can you perform linear regression in R using the lm() function?

  • mice.impute()

  • impute.data()

  • mice()

  • mice::complete()

Question 2

In R, what is the purpose of the summary() function when applied to a linear regression model created with lm()?

  • Displays a summary of the model's coefficients

  • Displays a summary of the model's residuals

  • Provides a summary of the model's performance metrics

  • Presents an overview of the model's input features

Question 3

In R, what is the purpose of the `purrr` package's `map()` function?**

  • Applies a function to each element of a vector and returns a list  

  • Applies a function to each row of a data frame and returns a vector  

  • Applies a function to each element of a list and returns a list of results  

  • Applies a function to each column of a matrix and returns a matrix

Question 4

What is the purpose of the `reshape2` package's `melt()` function in R?**

  • Melts a data frame from wide to long format

  • Casts a data frame from long to wide format

  • Reshapes a data frame by merging columns  

  • Applies a function to each element of a matrix

Question 5

What does the following R code do?

df <- data.frame(name = c("Alice", "Bob", "Charlie"),
                age = c(25, 30, 22))
 

  • Creates a matrix with two columns: "name" and "age"

  • Creates a data frame with two columns: "name" and "age"

  • Creates a list with two elements: "name" and "age"

  • Raises an error due to incorrect syntax

Question 6

What does the following R code do?

x <- c(1, 2, 3, 4, 5)
y <- sum(x)
 

  • Creates a vector x with values 1 to 5

  • Calculates the mean of vector x

  • Calculates the sum of vector x

  • Raises each element of vector x to the power of 2

Question 7

What is the purpose of the strsplit() function in R?

  • Splits a string into substrings based on a specified delimiter

  • Concatenates strings into a single string

  • Reverses the order of characters in a string

  • Extracts a substring from a string

Question 8

In R, what does the dendrogram class represent in hierarchical clustering?

  • A scatter plot of data points

  • A matrix of distances between data points

  • A tree-like structure representing the clustering hierarchy

  • A network graph of relationships between variables

Question 9

In R, what does the mutate() function from the dplyr package do?

  • Adds new variables or modifies existing ones in a data frame

  • Performs matrix multiplication

  • Mutates the entire data frame

  • Deletes variables from a data frame

Question 10

In R, what does the lapply() function do?

  • Applies a function to each element of a list and returns a list of the results

  • Applies a function to each element of a vector and returns a vector

  • Applies a function to each column of a data frame and returns a list of the results

  • Applies a function to each row of a matrix and returns a list of the results

There are 25 questions to complete.

Take a part in the ongoing discussion