R Programming Quiz

Last Updated :
Discuss
Comments

Question 1

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

  • A

    mice.impute()

  • B

    impute.data()

  • C

    mice()

  • D

    mice::complete()

Question 2

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

  • A

    Displays a summary of the model's coefficients

  • B

    Displays a summary of the model's residuals

  • C

    Provides a summary of the model's performance metrics

  • D

    Presents an overview of the model's input features

Question 3

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

  • A

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

  • B

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

  • C

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

  • D

    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?**

  • A

    Melts a data frame from wide to long format

  • B

    Casts a data frame from long to wide format

  • C

    Reshapes a data frame by merging columns  

  • D

    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))
 

  • A

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

  • B

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

  • C

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

  • D

    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)
 

  • A

    Creates a vector x with values 1 to 5

  • B

    Calculates the mean of vector x

  • C

    Calculates the sum of vector x

  • D

    Raises each element of vector x to the power of 2

Question 7

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

  • A

    Splits a string into substrings based on a specified delimiter

  • B

    Concatenates strings into a single string

  • C

    Reverses the order of characters in a string

  • D

    Extracts a substring from a string

Question 8

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

  • A

    A scatter plot of data points

  • B

    A matrix of distances between data points

  • C

    A tree-like structure representing the clustering hierarchy

  • D

    A network graph of relationships between variables

Question 9

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

  • A

    Adds new variables or modifies existing ones in a data frame

  • B

    Performs matrix multiplication

  • C

    Mutates the entire data frame

  • D

    Deletes variables from a data frame

Question 10

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

  • A

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

  • B

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

  • C

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

  • D

    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