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?
5.What is R primarily used for?
6. Which symbol is used to assign a value to a variable in R?
7.Which function is used to display data in R?
8.What does the following command do? `x <- c(1, 2, 3)`
9.Which of the following is an R data structure?
10.How would you install a package in R?
11.Which of the following is not a basic data type in R?
12.Which function is used to combine values into a data frame in R?
13.What does the `str()` function in R do?
14.Which of the following is an example of a factor in R?
15.What is the default method of ordering a factor variable in R?
16.What will the following code return? `is.vector(c(1, 2, 3))`
17.How would you access the second element of a vector `x` in R?
18.Which of the following data types cannot be stored in a matrix in R?
19.What will `length(list(1, 2, 3))` return in R?
20.Which function is used to check if an object is a data frame in R?
21.Which function in R is used to create a vector?
22.What is the result of the following operation in R: `TRUE + TRUE`?
23.Which function is used to find the structure of an object in R?
24.What is the output of `factor(c('red', 'blue', 'blue', 'red'))` in R?
25.What will `mean(c(1, 2, 3, NA))` return in R?
26.Which function in R is used to plot data?
27.How can you remove NA values from a vector `x` in R?
28.What is the purpose of the `apply()` function in R?
29.Which of the following is the correct way to create a sequence of numbers from 1 to 10 with a
30.Which function is used to concatenate strings in R?
31.What does the `dim()` function return in R?
32.Which 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?
34.Which of the following is not a valid data structure in R?
35.Which 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?
37.Which R function is used to combine elements into a matrix?
38.Which of the following data structures is used to store data in rows and columns in R?
39.Which of the following is true about R lists?
40.Which of the following is the correct syntax for a for loop in R?
41.What is the primary purpose of the break statement in R loops?
42.Which 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?
45.How can you create a loop that prints the squares of numbers from 1 to 5 in R?
46.Which of the following statements is true about the for loop in R?
47.Which of the following will print the names of all columns in a data frame df?
48.Which of the following code snippets will loop over the keys and values of a named list in R?
49.Which 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?
51.Which of the following logical operators is used for "AND" in R?
52.Which of the following is used to perform an "OR" operation in R?
53.Which 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?
55.In R, how do you specify a default value for a function argument?
56.What happens when you call a function in R without specifying an argument that has a default
57.In 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?
59.What will happen if you specify a default value for a parameter in a function, but later call the
parameter set to NULL?
60.If a function has multiple arguments with default values, which arguments must be specified w
function?
61.Can default argument values in R be functions themselves?
62.What happens when you pass NULL as a value for an argument that has a default value?
63.What does the return() function do in R?
64.What is the default behavior of a function in R if there is no return() statement?
65.How does R handle the return() value in a function?
66.Which of the following is the correct way to return multiple values from a function in R?
67.Can a function in R return an error?
68.In R, which function generates random numbers from a normal distribution?
69.What does the seq() function do in R?
70.In R, which function is used to calculate the mean of a numeric vector?
71.What is the default method for generating random numbers from a uniform distribution in R?
72.Which function would you use in R to calculate the cumulative probability (CDF) for a norma
73.How would you calculate the probability that a value from a standard normal distribution (mea
less than 1.96?
74.How can you calculate the probability that a value from a normal distribution with mean 100 a
deviation 15 is less than 120 in R?
75.In R, which function is used to compute the cumulative sum of a vector?
76.Which function in R calculates the cumulative product of the elements of a vector?
77.What does the function cummin() do in R?
78.If 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?
80.What does the function which.min() do in R?
81.In R, which function is used to find the index of the maximum value in a vector?
82.Which function would you use in R to calculate the running total of a vector?
83.In R, how would you find the largest value in a vector x <- c(3, 9, 2, 5, 8)?
84.Which function in R is used to create a basic scatter plot?
85.Which function would you use to create a bar plot in R?
86.How can you add a title to a plot in R?
87.In R, which function is used to create a histogram?
88.What does the function boxplot() do in R?
89.Which of the following functions is used to add grid lines to a plot in R?
90.What 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?
92.Which 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?
94.What is the default mean and standard deviation when using the rnorm() function in R?
95.How would you generate 1000 random numbers from a normal distribution with a mean of 5 a
deviation of 2 in R?
96.What is the output of dnorm(0) for a standard normal distribution?
97.How would you generate a vector of 1000 random numbers from a standard normal distributio
98.Which of the following is used to visualize a normal distribution in R?
99.Which function in R is used to perform a one-sample t-test?
100.Which argument in t.test() 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
read.csv(), load.csv(), read.table(),import.csv()
=, :=, <-, ==
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
install.packages(), library(), require(), add.package()
Numeric, Integer,Date,Tuple
data.frame(),combine(), frame(),create.df()
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
is.data.frame(), is.frame(), check.data(), is.table()
vector() , list() , c() , data.frame()
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)` , `na.omit(x)` ,`x[!is.na(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)` , `1:10:2` , 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()` ,`sample.random()` ,`random.sample()`
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
which.max() ,which.min() ,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
t.test() ,t.test.one() , one.sample.t.test() , ttest()
type , alternative , test_type , tail
Correct answers
v = c(1, 2, 3)
read.csv()
<-
length()
Data analysis and statistics
Both a and c
print()
Creates a vector with 1, 2, and 3
All of the above
install.packages()
Tuple
data.frame()
Displays the structure of an R object
Male, "Female"
Alphabetically
TRUE
x[2]
List
3
is.data.frame()
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
which.max()
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
t.test()
alternative