Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming R Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What does the function `install.packages()` do in R?

a)

It updates installed packages to the latest version.

b)

It installs new R packages from CRAN.

c)

It lists all available packages in CRAN.

d)

It removes specified packages from the system.

2.

Which function is used to read a CSV file in R?

a)

read.csv()

b)

read_excel()

c)

open.csv()

d)

file.open()

3.

How do you create a vector in R containing the numbers 1 through 5?

a)

c(1:5)

b)

vector(1, 5)

c)

list(1-5)

d)

sequence(1, 5)

4.

What symbol is used to assign a value to a variable in R?

a)

=

b)

:=

c)

<-

d)

==

5.

Which of the following is a way to generate a sequence of numbers from 1 to 10 in steps of 2 in R?

a)

seq(1, 10, by=2)

b)

sequence(1, 10, 2)

c)

1:10+2

d)

c(1, 3, 5, 7, 9)

6.

How do you check the structure of a data frame named `df` in R?

a)

structure(df)

b)

str(df)

c)

typeof(df)

d)

describe(df)

7.

What is the output of the following code snippet? ```R x <- c(TRUE, FALSE, TRUE, FALSE) sum(x) ```

a)

0

b)

2

c)

4

d)

TRUE

8.

Which function in R is used to apply a function over the margins of an array or matrix?

a)

lapply()

b)

apply()

c)

sapply()

d)

tapply()

9.

What does the `ggplot2` package in R primarily used for?

a)

Data manipulation

b)

Statistical analysis

c)

Data visualization

d)

Machine learning

10.

How do you install multiple packages at once in R?

a)

install.packages(c("dplyr", "ggplot2"))

b)

install.packages("dplyr", "ggplot2")

c)

c(install.packages("dplyr"), install.packages("ggplot2"))

d)

install.packages("dplyr") + install.packages("ggplot2")