WorksheetsR variable Data Type and Flow Control Quiz
Total questions: 12
Worksheet time: 6mins
What is the correct way to assign a value to a variable in R?
x <- 5
x = 5
5 -> x
All of the above
Which function is used to check the type of a variable in R?
typeof()
type()
variable_type()
None of the above
Which of the following is true about variables in R?
Variables cannot store multiple data types.
Variables are case-sensitive.
Variable names can start with a number.
Variables name can have _
What is the correct way to create a numeric vector in R?
vector(1, 2, 3)
[1, 2, 3]
num(1, 2, 3)
c(1, 2, 3)
What will be the output of the following code?
Error
1, 2, 3
2, 4, 6
3, 4, 5
Which of the following correctly creates a list in R?
list("a", 1, TRUE)
c("a", 1, TRUE)
("a", 1, TRUE)
None
How do you access the third element of my_list as a List in R?
my_list[3]
my_list[[3]]
my_list$3
my_list(3)
What function is used to create a matrix in R?
create_matrix()
array()
mat()
matrix()
How do you access the element in the second row and third column of a matrix mat?
mat[2, 2]
mat[[2, 3]]
mat[2][3]
mat[2, 3]
What will be the output of the following code?
[1] 1 2 3
[1] 7 8 9
[1] 4 5 6
None of the above
What is the correct syntax for an if statement in R?
if {condition} { ... }
if condition { ... }
if (condition) { ... }
if [condition] { ... }
What is the output of the following code?
Error
"Greater than 10"
"10 or less"
Nothing
