wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

HARSHA R QUIZ

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What function is used to create a vector in R?

a)

A) vector()

b)

B) list()

c)

C) c()

d)

D) array()

2.

Which of the following is used to check the class of an object in R?

a)

A) check()

b)

B) class()

c)

C) typeof()

d)

D) identity()

3.

How do you install a package in R?

a)

A) install()

b)

B) install.packages()

c)

C) library()

d)

D) pack.install()

4.

What does the function summary() do in R?

a)

A) Prints the first few rows of a dataset

b)

B) Provides a summary of an object (like a data frame or vector)

c)

C) Summarizes the functions used in a script

d)

D) Summarizes the data types in a dataframe

5.

How do you access the first element of a vector v?

a)

A) v[1]

b)

B) v[0]

c)

C) v(1)

d)

D) v::first()

6.

Which function is used to generate a sequence of numbers in R?

a)

A) seq()

b)

B) sequence()

c)

C) range()

d)

D) series()

7.

How can you check the structure of a data frame in R?

a)

A) structure()

b)

B) summary()

c)

C) str()

d)

D) view()

8.

What function is used to create a matrix in R?

a)

A) matrix()

b)

B) mat()

c)

C) array()

d)

D) table()

9.

Which of the following is used to install and load a package in one step?

a)

A) install.packages()

b)

B) library()

c)

C) require()

d)

D) both B and C

10.

What does the function mean() return in R?

a)

A) The sum of elements

b)

B) The average of the elements

c)

C) The median of the elements

d)

D) The variance of the elements

11.

How do you remove an object in R?

a)

A) delete()

b)

B) remove()

c)

C) rm()

d)

D) clear()

12.

Which function is used to concatenate strings in R?

a)

A) concat()

b)

B) merge()

c)

C) paste()

d)

D) append()

13.

How do you find the length of a vector v in R?

a)

A) len(v)

b)

B) length(v)

c)

C) size(v)

d)

D) count(v)

14.

What is the correct way to create a data frame in R?

a)

A) data.frame()

c)

C) frame()

d)

D) df()

15.

What does the function tail() do in R?

a)

A) Returns the last few elements of an object

b)

B) Returns the first few elements of an object

c)

C) Removes the last element of an object

d)

D) Removes the first element of an object

16.

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

a)

A) Applies a function to an entire dataset

b)

B) Applies a function to a vector

c)

C) Applies a function to a row or column of a matrix

d)

D) Applies a function to a list

17.

Which of the following functions is used to read a CSV file in R?

a)

A) read_csv()

b)

B) read.table()

c)

C) read.csv()

d)

D) import.csv()

18.

Which operator is used for element-wise multiplication in R?

a)

A) %%

b)

B) *

c)

C) .

d)

D) /

19.

What does the dim() function return in R?

a)

A) The dimensions of an object like a matrix or data frame

b)

B) The size of a vector

c)

C) The length of a vector

d)

D) The structure of an object

20.

How do you create a factor variable in R?

a)

A) factor()

b)

B) as.factor()

c)

C) to.factor()

d)

D) create.factor()

21.

Which of the following functions is used to compute the standard deviation in R?

a)

A) stdev()

b)

B) sd()

c)

C) var()

d)

D) mean()

22.

What does the function which() do in R?

a)

A) Returns the index of the maximum value

b)

B) Returns the positions of the TRUE elements in a logical vector

c)

C) Returns the element from a vector

d)

D) Returns the class of an object

23.

How can you combine two data frames by row in R?

a)

A) rbind()

b)

B) cbind()

c)

C) bind()

d)

D) combine()

24.

How can you merge two data frames in R by a common column?

a)

A) merge()

b)

B) combine()

c)

C) join()

d)

D) link()

25.

Which of the following functions is used to create a random sample in R?

a)

A) random()

b)

B) sample()

c)

C) draw()

d)

D) shuffle()