21
How is a list created in R?
A)
list(a = 1, b = "hello", c = TRUE)
B)
c(1, "hello", TRUE)
C)
data.frame(a = 1, b = "hello", c = TRUE)
D)
matrix(c(1, "hello", TRUE), nrow = 1)
Answer & Solution
Answer: Option
A
22
What does the R function median() compute?
A)
Median of a numeric vector
B)
Mean of a numeric vector
C)
Standard deviation of a numeric vector
D)
Sum of a numeric vector
Answer & Solution
Answer: Option
A
23
How do you install a package in R from the CRAN repository using the install.packages() function?
A)
install.packages("package_name")
B)
install.package("package_name")
C)
install_cran_package("package_name")
D)
add.package("package_name")
Answer & Solution
Answer: Option
A
24
In R, how do you access the help documentation for a specific function, e.g., mean()?
A)
help(mean)
B)
?mean
C)
info(mean)
D)
get.help(mean)
Answer & Solution
Answer: Option
B
25
What does the lengths() function do in R?
A)
Returns the number of elements in each list element
B)
Computes the lengths of strings in a character vector
C)
Calculates the length of a numeric vector
D)
Counts the number of elements in a list
Answer & Solution
Answer: Option
A
26
How is a character string defined in R?
A)
"Hello, World!"
B)
'Hello, World!'
C)
c("Hello", "World")
D)
char("Hello, World!")
Answer & Solution
Answer: Option
A
27
What does the R function table() do?
A)
Creates a contingency table
B)
Displays the first few rows of a data frame
C)
Produces a summary of data
D)
Sorts a vector
Answer & Solution
Answer: Option
A
28
How is the data frame column Age selected in R?
A)
data$Age
B)
data[,"Age"]
C)
data[["Age"]]
D)
data.column("Age")
Answer & Solution
Answer: Option
B
29
What is the purpose of the search() function in R?
A)
Displays the search path for loaded packages
B)
Searches for a file in the working directory
C)
Searches for a keyword in the help
D)
Displays the search history
Answer & Solution
Answer: Option
A
30
In R, how is the mean of a numeric vector calculated using the mean() function?
A)
mean(vector)
B)
calculate.mean(vector)
C)
vector.mean(vector)
D)
avg(vector)
Answer & Solution
Answer: Option
A