Font size
WorksheetsPop Quiz - R Programming - Revision for All Chapter
Total questions: 25
Worksheet time: 18mins
Which of the following is not a valid R object type?
Vector
Data frame
Pointer
List
What is the default mode of a vector when combining numeric and character elements using c()?
Numeric
Character
Factor
Logical
Given x <- factor(c("high", "low", "medium")), what is the class of x?
Factor
Character
List
Matrix
What is the result of length(list(1:5))?
5
10
15
1
Which function is used to test if an object is a data frame?
is.frame()
is.data()
is.data.frame()
is.df()
Which statement about R factors is correct?
They cannot store numeric values.
They are internally stored as integers.
They are always ordered.
They replace characters automatically.
Which operator checks for exact identity in R?
==
=
identical()
===
Which of the following correctly defines a function with a default argument in R?
f(x=5) { return(x*2) }
function f(x=5) { x*2 }
f <- function(x=5) { x*2 }
f <- def(x=5) { x*2 }
What happens if a function does not have an explicit return() statement?
It returns NULL
It returns the first expression
It returns the last evaluated expression
It causes an error
What is the output of cor(c(1,2,3), c(2,4,6))?
(a)
What does the lm() function return by default?
Coefficients only
Residuals
A list of regression results
A matrix of predictions
What is the default method of cor() in R?
Spearman
Kendall
Pearson
Covariance
What does a correlation coefficient of -0.85 indicate?
Strong negative correlation
Strong positive correlation
Weak negative correlation
No correlation
Which function is used to plot a fitted linear regression line over a scatter plot?
abline(model)
line(model)
geom_lm()
lines(model)
Which is the correct syntax for a basic scatter plot in base R?
(a)
Which ggplot2 layer adds points to a graph?
(a)
How do you create a multi-panel plot in lattice?
plotGrid()
facet_wrap()
xyplot(y ~ x | factor)
panel.xyplot()
How do you create a numeric vector containing numbers from 1 to 10?
(a)
Which R object type allows storage of mixed data types in rows and columns?
(a)
How do you calculate the correlation between two vectors x and y?
(a)
Which function provides a summary of a fitted regression model?
(a)
What is the basic function to create a histogram in R?
(a)
Write a command to add a title "My Graph" to a plot.
(a)
How do you check the current working directory in R?
(a)
What does NA represent in R?
(a)
