wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

R programming

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is a valid way to create a vector in R?

a)

vec <- [1,2,3,4]

b)

vec <- c(1,2,3,4)

c)

vec = (1,2,3,4)

d)

vector <- {1,2,3,4}

2.

What will length(c(10, 20, 30, 40)) return?

a)

3

b)

4

c)

40

d)

10 20 30 40

3.

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

a)

read.table()

b)

read.csv()

c)

import.csv()

d)

load.csv()

4.

What is the result of sum(1:5)?

a)

10

b)

15

c)

5

d)

1 2 3 4 5

5.

Which of the following is NOT a data type in R?

a)

Numeric

b)

Character

c)

Boolean

d)

String

6.

What does str() function do in R?

a)

Displays the structure of an object

b)

Converts a number to string

c)

Creates a new string

d)

Reads CSV files

7.

Which of the following can store elements of different data types in R?

a)

Vector

b)

Matrix

c)

List

d)

Factor

8.

What is the output of 1:5 * 2 in R?

a)

2 4 6 8 10

b)

1 2 3 4 5 2

c)

Error

d)

1 4 9 16 25

9.

What will is.data.frame(airquality) return if airquality is a built-in dataset?

a)

TRUE

b)

FALSE

c)

Depends on the version of R

d)

NULL

10.

Which function generates random numbers from a normal distribution?

a)

runif()

b)

rnorm()

c)

sample()

d)

rand()