β˜‘ MCQ PRACTICE

R Programming Unit 1

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

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

R Programming β€” Unit 1

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

01

Which of the following is true about R?

A R is a programming language
B R is used for statistical computing
C R has extensive graphical capabilities
D All of the above
Correct Answer All of the above
02

How do you install a package in R?

A install("package_name")
B install.package("package_name")
C install.packages("package_name")
D install.packages package_name
Correct Answer install.packages("package_name")
03

What command is used to check installed packages in R?

A installed.packages()
B list.packages()
C show.packages()
D get.packages()
Correct Answer installed.packages()
04

Which of the following is NOT an R Object type?

A Character
B List
C Tuple
D Factor
Correct Answer Tuple
05

What does c(1, 2, 3, 4) create in R?

A A list
B A vector
C A data frame
D A matrix
Correct Answer A vector
06

Which operator is used for assignment in R?

A <-
B ->
C =
D All of the above
Correct Answer All of the above
07

What function is used to check the data type of an object?

A typeof()
B class()
C mode()
D All of the above
Correct Answer All of the above
08

What does as.integer(4.7) return?

A 4.7
B 5
C 4
D Error
Correct Answer 4
09

What will be the output of 10 %% 3 in R?

A 1
B 3
C 0
D 10
Correct Answer 1
10

What is the result of 10 %/% 3?

A 3.33
B 3
C 10
D 1
Correct Answer 3
11

Which function rounds 3.76 to the nearest integer?

A round(3.76)
B floor(3.76)
C ceiling(3.76)
D trunc(3.76)
Correct Answer round(3.76)
12

How do you create a factor variable in R?

A as.factor()
B factor()
C convert.factor()
D as.category()
Correct Answer factor()
13

Which of the following is a logical operator in R?

A &
B |
C !
D All of the above
Correct Answer All of the above
14

How do you check if a value is missing in R?

A is.missing()
B is.na()
C is.null()
D missing()
Correct Answer is.na()
15

What is the default mode of a numeric value in R?

A integer
B double
C float
D complex
Correct Answer double
16

How do you generate a sequence from 1 to 10 with step size 2?

A seq(1,10,2)
B sequence(1,10,2)
C generate(1,10,2)
D seq(1,10,by=2)
Correct Answer seq(1,10,by=2)
17

What is the class of TRUE in R?

A Character
B Logical
C Numeric
D Integer
Correct Answer Logical
18

Which function is used to round numbers in R?

A round()
B ceiling()
C floor()
D All of the above
Correct Answer All of the above
19

What does the expression df$column return?

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

Which operator is used for subsetting a data frame in R?

A $
B []
C [[]]
D All of the above
Correct Answer All of the above
21

Which operator is used for integer division in R?

A /
B %/%
C %%
D *
Correct Answer %/%
22

Which of the following is a valid variable name in R?

A 1var
B _var
C var1
D var-1
Correct Answer var1
23

What does the expression x[1] return if x is a vector?

A The first element of x
B The last element of x
C The length of x
D The type of x
Correct Answer The first element of x
24

What is the default value of a logical object in R?

A TRUE
B FALSE
C NA
D NULL
Correct Answer FALSE
Quick Revision

Fill in the Blanks

Complete the following R Programming questions.

01
____________________ function returns the number of elements in a vector?
Answer length()
02
______________ function creates a matrix in R?
Answer matrix()
03
______________ function is used to concatenate two strings in R?
Answer paste()
04
What does rep(4, times=5) do_______________________?
Answer Creates a vector with five 4’s
05
___________ function combines multiple elements into a vector?
Answer c()
06
What is the output of class(3L) ?__________________________
Answer "integer"
← Back to All MCQs