QUESTIONS
1. What is the correct way to create a vector in R?
2. Which of the following function is used to read data from a CSV file in R?
3. Which operator is used to assign a value to a variable in R?
4. Which function is used to find the length of a vector in R?
[Link] is R primarily used for?
6. Which symbol is used to assign a value to a variable in R?
[Link] function is used to display data in R?
[Link] does the following command do? `x <- c(1, 2, 3)`
[Link] of the following is an R data structure?
[Link] would you install a package in R?
[Link] of the following is not a basic data type in R?
[Link] function is used to combine values into a data frame in R?
[Link] does the `str()` function in R do?
[Link] of the following is an example of a factor in R?
[Link] is the default method of ordering a factor variable in R?
[Link] will the following code return? `[Link](c(1, 2, 3))`
[Link] would you access the second element of a vector `x` in R?
[Link] of the following data types cannot be stored in a matrix in R?
[Link] will `length(list(1, 2, 3))` return in R?
[Link] function is used to check if an object is a data frame in R?
[Link] function in R is used to create a vector?
[Link] is the result of the following operation in R: `TRUE + TRUE`?
[Link] function is used to find the structure of an object in R?
[Link] is the output of `factor(c('red', 'blue', 'blue', 'red'))` in R?
[Link] will `mean(c(1, 2, 3, NA))` return in R?
[Link] function in R is used to plot data?
[Link] can you remove NA values from a vector `x` in R?
[Link] is the purpose of the `apply()` function in R?
[Link] of the following is the correct way to create a sequence of numbers from 1 to 10 with a
[Link] function is used to concatenate strings in R?
[Link] does the `dim()` function return in R?
[Link] R function is used to merge two data frames by common columns?
33. In R, which of the following is used to create a random sample from a dataset?
[Link] of the following is not a valid data structure in R?
[Link] of the following is an atomic vector type in R?
36. Which of the following is used to access an element in a data frame?
[Link] R function is used to combine elements into a matrix?
[Link] of the following data structures is used to store data in rows and columns in R?
[Link] of the following is true about R lists?
[Link] of the following is the correct syntax for a for loop in R?
[Link] is the primary purpose of the break statement in R loops?
[Link] of the following loops will run infinitely until a break condition is met?
43. Which of the following statements is used to skip the current iteration of a loop in R?
44. In a while loop, what will happen if the condition is initially FALSE?
[Link] can you create a loop that prints the squares of numbers from 1 to 5 in R?
[Link] of the following statements is true about the for loop in R?
[Link] of the following will print the names of all columns in a data frame df?
[Link] of the following code snippets will loop over the keys and values of a named list in R?
[Link] R function can you use to loop over the elements of a data frame when you want to acc
name?
50. Which of the following is the correct arithmetic operator for exponentiation in R?
[Link] of the following logical operators is used for "AND" in R?
[Link] of the following is used to perform an "OR" operation in R?
[Link] of the following R operators is used to check if two values are not equal?
54. What is the purpose of the xor() function in R?
[Link] R, how do you specify a default value for a function argument?
[Link] happens when you call a function in R without specifying an argument that has a default
[Link] R, what happens if you call a function with missing arguments for which no default value is
58. How can you override a default argument value when calling a function in R?
[Link] will happen if you specify a default value for a parameter in a function, but later call the
parameter set to NULL?
[Link] a function has multiple arguments with default values, which arguments must be specified w
function?
[Link] default argument values in R be functions themselves?
[Link] happens when you pass NULL as a value for an argument that has a default value?
[Link] does the return() function do in R?
[Link] is the default behavior of a function in R if there is no return() statement?
[Link] does R handle the return() value in a function?
[Link] of the following is the correct way to return multiple values from a function in R?
[Link] a function in R return an error?
[Link] R, which function generates random numbers from a normal distribution?
[Link] does the seq() function do in R?
[Link] R, which function is used to calculate the mean of a numeric vector?
[Link] is the default method for generating random numbers from a uniform distribution in R?
[Link] function would you use in R to calculate the cumulative probability (CDF) for a norma
[Link] would you calculate the probability that a value from a standard normal distribution (mea
less than 1.96?
[Link] can you calculate the probability that a value from a normal distribution with mean 100 a
deviation 15 is less than 120 in R?
[Link] R, which function is used to compute the cumulative sum of a vector?
[Link] function in R calculates the cumulative product of the elements of a vector?
[Link] does the function cummin() do in R?
[Link] you have a vector y <- c(5, 8, 3, 6, 1), what does cummax(y) return in R?
79. How would you find the minimum value in a numeric vector in R?
[Link] does the function [Link]() do in R?
[Link] R, which function is used to find the index of the maximum value in a vector?
[Link] function would you use in R to calculate the running total of a vector?
[Link] R, how would you find the largest value in a vector x <- c(3, 9, 2, 5, 8)?
[Link] function in R is used to create a basic scatter plot?
[Link] function would you use to create a bar plot in R?
[Link] can you add a title to a plot in R?
[Link] R, which function is used to create a histogram?
[Link] does the function boxplot() do in R?
[Link] of the following functions is used to add grid lines to a plot in R?
[Link] function would you use to customize the color of a scatter plot in R?
91. Which of the following R functions would you use to create a pie chart?
[Link] function is used in R to calculate the probability density function (PDF) for a Poisson d
93. Which R function generates random numbers from a normal distribution?
[Link] is the default mean and standard deviation when using the rnorm() function in R?
[Link] would you generate 1000 random numbers from a normal distribution with a mean of 5 a
deviation of 2 in R?
[Link] is the output of dnorm(0) for a standard normal distribution?
[Link] would you generate a vector of 1000 random numbers from a standard normal distributio
[Link] of the following is used to visualize a normal distribution in R?
[Link] function in R is used to perform a one-sample t-test?
[Link] argument in [Link]() is used to specify whether the test is two-tailed or one-tailed?
Options
v = (1, 2, 3), v = c(1, 2, 3),v = vector(1, 2, 3),v = 1, 2, 3
[Link](), [Link](), [Link](),[Link]()
=, :=, <-, ==
length() dim()size() count()
Database management, Data analysis and statistics, Web development, Operating system develop
=, :=, ->, Both a and c
print(), display(),show(), write()
Creates a vector of length 1, Creates a vector with 1, 2, and 3, Creates a matrix with 1, 2, 3, Crea
with 1, 2, 3
List, Vector, Matrix, All of the above
[Link](), library(), require(), [Link]()
Numeric, Integer,Date,Tuple
[Link](),combine(), frame(),[Link]()
Converts a vector to a string, Displays the structure of an R object, Sorts a data frame, Strips wh
string
1, 2, 3, "Male", "Female",TRUE, FALSE, 3.14
Alphabetically, By frequency of occurrence, By numeric values, User-defined
TRUE, FALSE,Error, NULL
x[2], x(2),x$2, x[1]
Numeric ,Integer, Character ,List
3 ,2 , NULL, Error
[Link](), [Link](), [Link](), [Link]()
vector() , list() , c() , [Link]()
1 ,2 ,TRUE ,FALSE
str() , summary() , dim() , class()
A character vector , A numeric vector , A factor with levels "red" and "blue" , A logical vector
Error , `NA` , `2` ,`3`
`plot()` ,`graph()` ,`chart()` ,`diagram()`
`removeNA(x)` , `[Link](x)` ,`x[]` , Both B and C
To apply a function to a vector ,To apply a function to each element of a list or vector ,To apply a
each column or row of a matrix or array, To apply a model to a dataset
`seq(1, 10, 2)` , `seq(1, 10, by=2)` , `[Link]` , Both A and B
`concatenate()` , `combine()` ,`paste()` ,`stringify()`
The length of a vector, The dimensions of an object (e.g., matrix or array), The size of an object,
object
`merge()` ,`join()` ,`union()` ,`combine()`
`sample()` ,`rand()` ,`[Link]()` ,`[Link]()`
Data frame ,List , Array ,Set
Data frame ,Matrix ,Numeric , List
dataframe[3] , dataframe[3, ] , dataframe[, 3] , All of the above
array() ,cbind() ,rbind() ,All of the above
Matrix, Data frame ,Array , Both A and B
Lists can only store elements of the same type ,Lists can store elements of different types , Lists a
dimensional ,Lists are stored in a fixed size
for (i in 1:5) { print(i) } ,for (i = 1:5) { print(i) } ,for (i from 1 to 5) { print(i) } ,for (1:5 in i) { pri
To continue to the next iteration, To exit the loop completely ,To skip the current iteration , To pr
and exit
while loop ,for loop , repeat loop , do-while loop
exit() ,continue , next ,skip
The loop will execute once ,The loop will execute multiple times ,The loop will not execute at all
occur
for (i in 1:5) { print(i^2) } ,for (i = 1 to 5) { print(i^2) } , for (i in 1:5) { print(i * 2) } , for (i = 1; i
{ print(i^2) }
The loop is always executed at least once, regardless of the condition, The loop executes as long a
evaluates to TRUE ,The for loop in R does not support iteration over vectors, The loop executes o
element of the specified sequence.
for (col in df) { print(col) }, for (col in colnames(df)) { print(col) }, for (col in df) { print(colname
,for (col in df$columns) { print(col) }
for (key in names(my_list)) { print(my_list[key]) }, for (key in my_list) { print(key) } , for (key i
{ print(my_list$key) } , for (key, value in my_list) { print(key, value) }
for (col in df) { print(col) } , apply(df, 1, function(x) print(x)) , lapply(df, function(x) print(x)) , fo
names(df)) { print(col) }
^ , ** ,exp() , log()
&& ,AND ,& , and()
|| , & , or() , |
!= ,== ,<> ,===
To perform an "exclusive or" logical operation ,To check if two vectors are identical , To check if
not equal ,To compute the logical "AND" of two conditions
function(arg = value) , function(arg -> value) , function(arg : value) ,function(arg <- value)
The function will return NULL , The function will throw an error , The default value for the argu
used ,The function will not execute
The function will return an error ,The function will use a NULL value for those arguments ,The fu
ignore the missing arguments , The function will use a default value automatically
By using NULL , By setting the argument in the function call ,By using the = operator in the func
definition ,By passing default as an argument
The default value will be ignored ,The argument will be set to NULL ,The function will throw an
argument will be replaced with a default value
All arguments ,Only the arguments without default values , Arguments with default values ,None
will be used
Yes ,No , Only if the argument is numeric ,Only for default strings
The argument will take the value of NULL ,The default value will be used ,The function will retu
argument will be ignored
It stops the execution of the function, It prints a value to the console , It returns a value from a fun
a value to a variable
The function returns NULL ,The function returns NA ,The function throws an error ,The function
empty value
The function value is stored in a global variable ,The value is printed to the console automatically
assigned to the calling environment ,The value is discarded if not explicitly assigned
return(a, b) ,return(a + b) , return(list(a, b)) ,return(c(a, b))
Yes, by using stop() or warning() functions ,No, functions can only return values ,Yes, but only w
function is used , No, return() can only return a value
runif() ,rnorm() , rbinom() , sample()
It creates a sequence of random numbers , It creates a sequence of numbers based on a range and
calculates the cumulative sum of a vector, It generates a vector of normally distributed values
average() ,mean() , median() ,meanvalue()
runif() ,rnorm() ,rpois() , runif()
dnorm() , qnorm() ,pnorm() , rnorm()
pnorm(1.96) , dnorm(1.96) , pnorm(1.96, mean = 0, sd = 1) , rnorm(1.96)
pnorm(120, mean = 100, sd = 15) , pnorm(120) ,dnorm(120, mean = 100, sd = 15) , qnorm(120, m
15)
cumprod() , cumsum() ,cummin() , cummax()
cumprod() ,cumsum() , prod() , cummax()
Calculates the cumulative sum ,Calculates the cumulative product , Calculates the cumulative min
Calculates the cumulative maximum
5 8 8 8 8 ,5 6 6 6 6 , 5 8 8 8 1 ,5 8 8 8 8
min() , max() ,range() , mean()
Returns the smallest value in a vector , Returns the index of the smallest value in a vector , Return
index , Returns the first minimum value in a vector
[Link]() ,[Link]() ,max() , min()
cummin() ,cumprod() , cumsum() , sum()
max(x) ,min(x) , cummax(x) , mean(x)
plot(), barplot() , hist(), boxplot()
plot() ,hist() ,boxplot() , barplot()
title("My Plot") , addtitle("My Plot") , plot_title("My Plot") ,labels("My Plot")
plot() , hist() ,barplot() , lineplot()
Creates a line plot , Creates a histogram , Creates a box-and-whisker plot , Creates a scatter plot
grid() ,add_grid() ,add_lines() ,line_grid()
col() , color() , plot_color() ,rgb()
pie(), barplot() , scatter() ,boxplot()
ppois() , dpois() ,qpois() ,rpois()
rnorm() , dnorm() ,pnorm() ,qnorm()
Mean = 0, SD = 1 ,Mean = 1, SD = 0 ,Mean = 0, SD = 2 , Mean = 1, SD = 1
rnorm(1000) , rnorm(1000, mean = 5, sd = 2) , rnorm(1000, 5, 2) ,runif(1000, 5, 2)
0 , 0.5 ,1 , 0.3989
rnorm(1000, 0, 1) , rnorm(1000) ,runif(1000), dnorm(1000)
plot() ,hist() ,density() , All of the above
[Link]() ,[Link]() , [Link]() , ttest()
type , alternative , test_type , tail
Correct answers
v = c(1, 2, 3)
[Link]()
<-
length()
Data analysis and statistics
Both a and c
print()
Creates a vector with 1, 2, and 3
All of the above
[Link]()
Tuple
[Link]()
Displays the structure of an R object
Male, "Female"
Alphabetically
TRUE
x[2]
List
3
[Link]()
c()
str()
A factor with levels "red" and "blue"
`NA`
`plot()`
Both B and C
To apply a function to each column or row of a matrix or array
Both A and B
`paste()`
The dimensions of an object (e.g., matrix or array)
`merge()`
`sample()`
Set
Numeric
All of the above
All of the above
Both A and B
Lists can store elements of different types
for (i in 1:5) { print(i) }
To exit the loop completely
repeat loop
next
The loop will not execute at all
for (i in 1:5) { print(i^2) }
The loop executes once for each element of the specified sequence.
for (col in colnames(df)) { print(col) }
for (key in names(my_list)) { print(my_list[key]) }
for (col in names(df)) { print(col) }
&
!=
To perform an "exclusive or" logical operation
function(arg = value)
The default value for the argument is used
The function will return an error
By setting the argument in the function call
The argument will be set to NULL
Only the arguments without default values
Yes
The argument will take the value of NULL
It returns a value from a function
The function returns NULL
The value is assigned to the calling environment
return(list(a, b))
Yes, by using stop() or warning() functions
rnorm()
It creates a sequence of numbers based on a range and step size
mean()
runif()
pnorm()
pnorm(1.96)
pnorm(120, mean = 100, sd = 15)
cumsum()
cumprod()
Calculates the cumulative minimum
58888
min()
Returns the index of the smallest value in a vector
[Link]()
cumsum()
max(x)
plot()
barplot()
title("My Plot")
hist()
Creates a box-and-whisker plot
grid()
col()
pie()
dpois()
rnorm()
Mean = 0, SD = 1
rnorm(1000, mean = 5, sd = 2)
0.3989
rnorm(1000)
All of the above
[Link]()
alternative