wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pop Quiz - R Programming - Revision for All Chapter

Total questions: 25

Worksheet time: 18mins

Name
Class
Date
1.

Which of the following is not a valid R object type?

a)

Vector

b)

Data frame

c)

Pointer

d)

List

2.

What is the default mode of a vector when combining numeric and character elements using c()?

a)

Numeric

b)

Character

c)

Factor

d)

Logical

3.

Given x <- factor(c("high", "low", "medium")), what is the class of x?

a)

Factor

b)

Character

c)

List

d)

Matrix

4.

What is the result of length(list(1:5))?

a)

5

b)

10

c)

15

d)

1

5.

Which function is used to test if an object is a data frame?

a)

is.frame()

b)

is.data()

c)

is.data.frame()

d)

is.df()

6.

Which statement about R factors is correct?

a)

They cannot store numeric values.

b)

They are internally stored as integers.

c)

They are always ordered.

d)

They replace characters automatically.

7.

Which operator checks for exact identity in R?

a)

==

b)

=

c)

identical()

d)

===

8.

Which of the following correctly defines a function with a default argument in R?

a)

f(x=5) { return(x*2) }

b)

function f(x=5) { x*2 }

c)

f <- function(x=5) { x*2 }

d)

f <- def(x=5) { x*2 }

9.

What happens if a function does not have an explicit return() statement?

a)

It returns NULL

b)

It returns the first expression

c)

It returns the last evaluated expression

d)

It causes an error

10.

What is the output of cor(c(1,2,3), c(2,4,6))?

(a)  

11.

What does the lm() function return by default?

a)

Coefficients only

b)

Residuals

c)

A list of regression results

d)

A matrix of predictions

12.

What is the default method of cor() in R?

a)

Spearman

b)

Kendall

c)

Pearson

d)

Covariance

13.

What does a correlation coefficient of -0.85 indicate?

a)

Strong negative correlation

b)

Strong positive correlation

c)

Weak negative correlation

d)

No correlation

14.

Which function is used to plot a fitted linear regression line over a scatter plot?

a)

abline(model)

b)

line(model)

c)

geom_lm()

d)

lines(model)

15.

Which is the correct syntax for a basic scatter plot in base R?

(a)  

16.

Which ggplot2 layer adds points to a graph?

(a)  

17.

How do you create a multi-panel plot in lattice?

a)

plotGrid()

b)

facet_wrap()

c)

xyplot(y ~ x | factor)

d)

panel.xyplot()

18.

How do you create a numeric vector containing numbers from 1 to 10?

(a)  

19.

Which R object type allows storage of mixed data types in rows and columns?

(a)  

20.

How do you calculate the correlation between two vectors x and y?

(a)  

21.

Which function provides a summary of a fitted regression model?

(a)  

22.

What is the basic function to create a histogram in R?

(a)  

23.

Write a command to add a title "My Graph" to a plot.

(a)  

24.

How do you check the current working directory in R?

(a)  

25.

What does NA represent in R?

(a)