21
What is the purpose of the length() function in R?
A)
Returns the sum of elements
B)
Returns the number of elements
C)
Computes the length of a vector
D)
Calculates the mean of a vector
Answer & Solution
Answer: Option
B
22
In R, how do you create a sequence of even numbers from 2 to 10?
A)
seq(2, 10, by = 2)
B)
seq_even(2, 10)
C)
even_seq(2, 10)
D)
seq(2, 10)
Answer & Solution
Answer: Option
A
23
What does the sort() function do in R?
A)
Arrange elements in ascending order
B)
Shuffle the elements randomly
C)
Reverse the order of elements
D)
Sort elements in descending order
Answer & Solution
Answer: Option
A
24
How do you calculate the mean of a numeric vector in R?
A)
mean(vector)
B)
average(vector)
C)
vec_mean(vector)
D)
calc_mean(vector)
Answer & Solution
Answer: Option
A
25
In R, how is the minimum value of a numeric vector calculated using the min() function?
A)
min(vector)
B)
minimum(vector)
C)
vectorMin(vector)
D)
min_value(vector)
Answer & Solution
Answer: Option
A
26
What does the rev() function do in R?
A)
Reverse the order of elements
B)
Remove duplicate elements
C)
Rotate elements to the right
D)
Sort elements in descending order
Answer & Solution
Answer: Option
A
27
How do you create a vector of logical values in R?
A)
c(TRUE, FALSE, TRUE)
B)
vector(TRUE, FALSE, TRUE)
C)
logical_vector(TRUE, FALSE, TRUE)
D)
create_logical_vector(TRUE, FALSE)
Answer & Solution
Answer: Option
A
28
In R, what does the abs() function do?
A)
Return the absolute values of elements
B)
Compute the average of elements
C)
Calculate the square root
D)
Find the maximum value
Answer & Solution
Answer: Option
A
29
What is the purpose of the unique() function in R?
A)
Remove duplicate elements from a vector
B)
Identify unique elements in a vector
C)
Create a vector of unique values
D)
Find the maximum unique value
Answer & Solution
Answer: Option
A
30
How do you create a vector of characters in R?
A)
c("apple", "banana", "cherry")
B)
char_vector("apple", "banana", "cherry")
C)
vector("apple", "banana", "cherry")
D)
create_char_vector("apple", "banana")
Answer & Solution
Answer: Option
A