r programmin bits 2
r programmin bits 2
2. Which of the following function is used to read data from a CSV file in R?
29.Which of the following is the correct way to create a sequence of numbers from 1 to 10 with a
33. In R, which of the following is used to create a random sample from a dataset?
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?
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?
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?
53.Which of the following R operators is used to check if two values are not equal?
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?
66.Which of the following is the correct way to return multiple values from a function in R?
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?
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?
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)?
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
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
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
=, :=, <-, ==
Database management, Data analysis and statistics, Web development, Operating system develop
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
1 ,2 ,TRUE ,FALSE
A character vector , A numeric vector , A factor with levels "red" and "blue" , A logical vector
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
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()`
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
The loop will execute once ,The loop will execute multiple times ,The loop will not execute at all
occur
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()
0 , 0.5 ,1 , 0.3989
rnorm(1000, 0, 1) , rnorm(1000) ,runif(1000), dnorm(1000)
v = c(1, 2, 3)
read.csv()
<-
length()
Both a and c
print()
install.packages()
Tuple
data.frame()
Male, "Female"
Alphabetically
TRUE
x[2]
List
3
is.data.frame()
c()
str()
`NA`
`plot()`
Both B and C
Both A and B
`paste()`
`merge()`
`sample()`
Set
Numeric
Both A and B
Lists can store elements of different types
repeat loop
next
The loop executes once for each element of the specified sequence.
&
!=
function(arg = value)
The default value for the argument is used
Yes
return(list(a, b))
rnorm()
mean()
runif()
pnorm()
pnorm(1.96)
pnorm(120, mean = 100, sd = 15)
cumsum()
cumprod()
58888
min()
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)
t.test()
alternative