β˜‘ MCQ PRACTICE

R Programming Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

πŸ“š R Programming
πŸ“– Unit 3
🎯 MCQs
MCQ Practice

R Programming β€” Unit 3

Practice the following objective questions. Click β€œShow Answer” whenever you want to check your answer.

01

In R, which function is used to create a list?

A vector()
B list()
C array()
D create.list()
Correct Answer list()
02

Lists in R can contain elements of _____ types.

A Same
B Integer only
C Different
D Character only
Correct Answer Different
03

How do you access the second element of a list named mylist?

A mylist[2]
B mylist[[2]]
C mylist(2)
D mylist{2}
Correct Answer mylist[[2]]
04

Which operator is used to access list components by name?

A #
B @
C $
D %
Correct Answer $
05

To add an element to a list, it can be assigned to a _____.

A new index
B function
C vector type
D data frame
Correct Answer new index
06

What happens when NULL is assigned to a list element?

A The element becomes zero
B The element gets deleted
C The element becomes NA
D An error is generated
Correct Answer The element gets deleted
07

Which function is used to apply a function to each element of a list?

A apply()
B lapply()
C loop()
D each()
Correct Answer lapply()
08

What is the value of length(list()) in R?

A 0
B 1
C NULL
D Error
Correct Answer 0
09

Which function is used to find the size of a list?

A size()
B count()
C length()
D list.size()
Correct Answer length()
10

Which function gives the structure of a list?

A structure()
B str()
C typeof()
D inspect()
Correct Answer str()
11

Text concordance lists store _____.

A Numbers only
B Words and positions
C Images and files
D Functions and variables
Correct Answer Words and positions
12

Which statement deletes the second element of list x?

A x[2] <- 0
B delete(x[2])
C x[[2]] <- NULL
D remove(x, 2)
Correct Answer x[[2]] <- NULL
13

Which function reads a list from a file?

A read.list()
B scan()
C get.list()
D import.list()
Correct Answer scan()
14

What is the default indexing of a list in R?

A Name based
B Position based
C Value based
D Random
Correct Answer Position based
15

Which function is used to create a data frame in R?

A dataframe()
B data.frame()
C create.data()
D frame()
Correct Answer data.frame()
16

A data frame in R is most similar to a _____.

A Matrix
B Function
C String
D Scalar
Correct Answer Matrix
17

Each column of a data frame is a _____.

A Matrix
B Vector
C List only
D Function
Correct Answer Vector
18

Which operator is used to access a data-frame column by name?

A #
B $
C %
D @
Correct Answer $
19

What is the data type returned by class(df) for a data frame df?

A matrix
B vector
C data.frame
D list
Correct Answer data.frame
20

Which function returns the number of rows and columns of a data frame?

A size()
B length()
C dim()
D shape()
Correct Answer dim()
21

Which function displays the first few rows of a data frame?

A first()
B head()
C top()
D rows()
Correct Answer head()
22

What does df[,2] return when df is a data frame?

A First column
B Second row
C Second column
D Entire data frame
Correct Answer Second column
23

Which statement adds a new column to a data frame?

A df + newcol
B df$newcol <- vector
C add(df, newcol)
D df.column(newcol)
Correct Answer df$newcol <- vector
24

A column can be removed from a data frame by assigning _____ to it.

A 0
B NA
C NULL
D FALSE
Correct Answer NULL
25

Which function applies a function across rows or columns of a data structure?

A apply()
B lapply()
C rowapply()
D column()
Correct Answer apply()
26

Which function is used to transpose a matrix or data frame?

A transpose()
B t()
C trans()
D rotate()
Correct Answer t()
27

Which function combines data frames vertically?

A cbind()
B merge()
C rbind()
D combine()
Correct Answer rbind()
28

Which function merges data frames using common columns?

A join()
B merge()
C combine()
D match.data()
Correct Answer merge()
True / False

R Programming β€” Unit 3

Check whether the following statements are True or False.

29
Lists can contain another list inside.
Answer TRUE
30
All columns in a data frame must be of the same type.
Answer FALSE
← Back to All MCQs