Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

R Basic

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which of the following correctly assigns the value 10 to a variable x in R?

a)

x = 10

b)

10 -> x

c)

x <- 10

d)

All of the above

2.

What is the result of the following R command?
class(3.14)

a)

"integer"

b)

"numeric"

c)

"double"

d)

"character"

3.

Which command correctly creates a numeric vector containing the values 1, 3, and 5?

a)

c(1, 3, 5)

b)

vector(1, 3, 5)

c)

seq(1, 5, 2)

d)

Both A and C

4.

What function is used to read data from a CSV file into a data frame in R?

a)

read.table()

b)

read.csv()

d)

both a and b are correct

5.

In R, what does the 'length()' function return?

a)

Number of rows in a data frame

b)

Number of columns in a data frame

c)

Total number of elements in an object

d)

Sum of elements in a numeric vector

6.

How can you comment out a single line in R?

a)

// Comment

b)

/* Comment */

c)

# Comment

d)

-- Comment

7.

Which function is commonly used to view the first few rows of a data frame?

a)

head()

b)

tail()

c)

summary()

d)

str()

8.

Given the vector below:
v <- c(5, 10, 15, 20)
What is the output of v[2]?

a)

5

b)

10

c)

15

d)

20

9.

What does the 'seq()' function do in R?

a)

Generates a sequence of numbers

b)

Calculates the sum of a vector

c)

Finds the median of a dataset

d)

Removes missing values from a data frame

10.

How is the logical OR operator represented in R?

a)

&

b)

|

c)

!

d)

%

11.

What is the purpose of the 'apply()' function in R?

a)

Applies a function to each element of a vector or matrix

b)

Calculates the mean of a dataset

c)

Sorts the elements of a vector in ascending order

d)

Filters out missing values from a data frame

12.

How can you create a scatter plot in R?

a)

plot(x, y)

b)

scatterplot(x, y)

c)

create.scatterplot(x, y)

d)

scatter(x, y)

13.

How do you install a package named 'ggplot2' in R?

a)

install.packages('ggplot2')

b)

install.library('ggplot2')

c)

library(ggplot2)

d)

load('ggplot2')

14.

Which function is used to generate random numbers from a normal distribution in R?

a)

rnorm()

b)

runif()

c)

rbinom()

d)

rexp()

15.

How to find P(Z<1) if Z is a standard normal random variable?

a)

dnorm(1)

b)

rnorm(1)

c)

pnorm(1)

d)

qnorm(1)