WorksheetsR Basic
Total questions: 15
Worksheet time: 8mins
Which of the following correctly assigns the value 10 to a variable x in R?
x = 10
10 -> x
x <- 10
All of the above
What is the result of the following R command?
class(3.14)
"integer"
"numeric"
"double"
"character"
Which command correctly creates a numeric vector containing the values 1, 3, and 5?
c(1, 3, 5)
vector(1, 3, 5)
seq(1, 5, 2)
Both A and C
What function is used to read data from a CSV file into a data frame in R?
In R, what does the 'length()' function return?
Number of rows in a data frame
Number of columns in a data frame
Total number of elements in an object
Sum of elements in a numeric vector
How can you comment out a single line in R?
// Comment
/* Comment */
# Comment
-- Comment
Which function is commonly used to view the first few rows of a data frame?
head()
tail()
summary()
str()
Given the vector below:
v <- c(5, 10, 15, 20)
What is the output of v[2]?
5
10
15
20
What does the 'seq()' function do in R?
Generates a sequence of numbers
Calculates the sum of a vector
Finds the median of a dataset
Removes missing values from a data frame
How is the logical OR operator represented in R?
&
|
!
%
What is the purpose of the 'apply()' function in R?
Applies a function to each element of a vector or matrix
Calculates the mean of a dataset
Sorts the elements of a vector in ascending order
Filters out missing values from a data frame
How can you create a scatter plot in R?
plot(x, y)
scatterplot(x, y)
create.scatterplot(x, y)
scatter(x, y)
How do you install a package named 'ggplot2' in R?
install.packages('ggplot2')
install.library('ggplot2')
library(ggplot2)
load('ggplot2')
Which function is used to generate random numbers from a normal distribution in R?
rnorm()
runif()
rbinom()
rexp()
How to find P(Z<1) if Z is a standard normal random variable?
dnorm(1)
rnorm(1)
pnorm(1)
qnorm(1)
