University-Level Practice Examination — R Syntax, Data Structures,
Data Manipulation, Statistical Analysis, Visualization, Probability,
Regression, Hypothesis Testing & Programming — 190 Multiple-
Choice Questions with Answers & Detailed Rationales
SECTION 1: R BASICS AND DATA TYPES (Questions 1-25)
Question 1
What is the primary purpose of the assignment operator <- in R?
A. To compare two values for equality
B. To assign a value to a variable
C. To create a comment in code
D. To concatenate strings
Correct Answer: B
Explanation: The <- operator assigns values to variables in R, though = also works. It's the
idiomatic assignment operator in R programming.
Question 2
Which function is used to determine the data type of an object in R?
A. type()
B. typeof()
C. datatype()
,D. classonly()
Correct Answer: B
Explanation: typeof() returns the internal data type, while class() returns the object's class
attribute. Both are useful for different purposes.
Question 3
What will be the output of length(c(1, 2, NA, 4)) in R?
A. 3
B. 4
C. NA
D. Error
Correct Answer: B
Explanation: The length() function counts all elements including NA values. It returns 4
because NA is still an element in the vector.
Question 4
Which R object can contain elements of different data types?
A. Vector
B. Matrix
C. List
,D. Array
Correct Answer: C
Explanation: Lists are heterogeneous containers that can hold elements of different types,
unlike vectors, matrices, and arrays which require uniform types.
Question 5
A researcher stores patient ages as c(25, 34, 45, 52). What is the class of this object?
A. Character
B. Integer
C. Numeric
D. Logical
Correct Answer: C
Explanation: Numbers with decimal points or those created without "L" suffix are stored as
numeric (double) by default in R, not integer.
Question 6
What does NA represent in R?
A. Not Available, indicating missing data
B. Null value
C. Zero value
, D. Negative answer
Correct Answer: A
Explanation: NA stands for "Not Available" and represents missing values. It's different from
NULL which represents the absence of an object.
Question 7
Which function creates a sequence of numbers from 1 to 10 in increments of 2?
A. seq(1, 10, 2)
B. range(1, 10, 2)
C. series(1, 10, 2)
D. order(1, 10, 2)
Correct Answer: A
Explanation: seq() generates sequences with specified parameters: from, to, and by. It
produces 1, 3, 5, 7, 9.
Question 8
What is the result of paste("Hello", "World", sep="-")?
A. "Hello World"
B. "Hello-World"
C. "HelloWorld"