R Programming Basics — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on R Programming Basics — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What symbol is used for assignment in R?
Correct Answer: Option A — <-
Detailed Academic Explanation:
<- is the correct answer to “What symbol is used for assignment in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the function print() do in R?
Correct Answer: Option A — Display the result of a calculation
Detailed Academic Explanation:
Display the result of a calculation is the correct answer to “What does the function print() do in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how is a variable assigned a value?
Correct Answer: Option A — set
Detailed Academic Explanation:
set is the correct answer to “In R, how is a variable assigned a value”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the seq() function in R?
Correct Answer: Option A — Create a sequence of numbers
Detailed Academic Explanation:
Create a sequence of numbers is the correct answer to “What is the purpose of the seq() function in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what is the primary data structure to store a sequence of elements of the same type?
Correct Answer: Option D — Vector
Detailed Academic Explanation:
Vector is the correct answer to “In R, what is the primary data structure to store a sequence of elements of the same type”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the factor data type represent in R?
Correct Answer: Option B — Categorical data
Detailed Academic Explanation:
Categorical data is the correct answer to “What does the factor data type represent in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how is a comment denoted?
Correct Answer: Option C — # Comment
Detailed Academic Explanation:
# Comment is the correct answer to “In R, how is a comment denoted”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid way to create a numeric vector in R?
Correct Answer: Option A — c(1, 2, 3)
Detailed Academic Explanation:
c(1, 2, 3) is the correct answer to “Which of the following is a valid way to create a numeric vector in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is the length of a vector determined in R?
Correct Answer: Option A — length(vector)
Detailed Academic Explanation:
length(vector) is the correct answer to “How is the length of a vector determined in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what is the purpose of the paste() function?
Correct Answer: Option A — Concatenate strings
Detailed Academic Explanation:
Concatenate strings is the correct answer to “In R, what is the purpose of the paste() function”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the role of the rep() function in R?
Correct Answer: Option A — Repeat elements of a vector
Detailed Academic Explanation:
Repeat elements of a vector is the correct answer to “What is the role of the rep() function in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you check the data type of a variable in R?
Correct Answer: Option B — class(var)
Detailed Academic Explanation:
class(var) is the correct answer to “How do you check the data type of a variable in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of 5 %% 2 in R?
Correct Answer: Option A — 1
Detailed Academic Explanation:
1 is the correct answer to “What is the output of 5 %% 2 in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you round a numeric value to the nearest integer using the round() function?
Correct Answer: Option A — round(5.78)
Detailed Academic Explanation:
round(5.78) is the correct answer to “In R, how do you round a numeric value to the nearest integer using the round() function”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the scan() function do in R?
Correct Answer: Option B — Read data from a file
Detailed Academic Explanation:
Read data from a file is the correct answer to “What does the scan() function do in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to calculate the square root of a number in R?
Correct Answer: Option A — sqrt()
Detailed Academic Explanation:
sqrt() is the correct answer to “What function is used to calculate the square root of a number in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of sum(1:5) in R?
Correct Answer: Option A — 15
Detailed Academic Explanation:
15 is the correct answer to “What is the result of sum(1:5) in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is the maximum value of a numeric vector calculated in R using the max() function?
Correct Answer: Option A — max(vector)
Detailed Academic Explanation:
max(vector) is the correct answer to “How is the maximum value of a numeric vector calculated in R using the max() function”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the length() function in R?
Correct Answer: Option B — Returns the number of elements
Detailed Academic Explanation:
Returns the number of elements is the correct answer to “What is the purpose of the length() function in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you create a sequence of even numbers from 2 to 10?
Correct Answer: Option A — seq(2, 10, by = 2)
Detailed Academic Explanation:
seq(2, 10, by = 2) is the correct answer to “In R, how do you create a sequence of even numbers from 2 to 10”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the sort() function do in R?
Correct Answer: Option A — Arrange elements in ascending order
Detailed Academic Explanation:
Arrange elements in ascending order is the correct answer to “What does the sort() function do in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you calculate the mean of a numeric vector in R?
Correct Answer: Option A — mean(vector)
Detailed Academic Explanation:
mean(vector) is the correct answer to “How do you calculate the mean of a numeric vector in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how is the minimum value of a numeric vector calculated using the min() function?
Correct Answer: Option A — min(vector)
Detailed Academic Explanation:
min(vector) is the correct answer to “In R, how is the minimum value of a numeric vector calculated using the min() function”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the rev() function do in R?
Correct Answer: Option A — Reverse the order of elements
Detailed Academic Explanation:
Reverse the order of elements is the correct answer to “What does the rev() function do in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a vector of logical values in R?
Correct Answer: Option A — c(TRUE, FALSE, TRUE)
Detailed Academic Explanation:
c(TRUE, FALSE, TRUE) is the correct answer to “How do you create a vector of logical values in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what does the abs() function do?
Correct Answer: Option A — Return the absolute values of elements
Detailed Academic Explanation:
Return the absolute values of elements is the correct answer to “In R, what does the abs() function do”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the unique() function in R?
Correct Answer: Option A — Remove duplicate elements from a vector
Detailed Academic Explanation:
Remove duplicate elements from a vector is the correct answer to “What is the purpose of the unique() function in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a vector of characters in R?
Correct Answer: Option A — c("apple", "banana", "cherry")
Detailed Academic Explanation:
c("apple", "banana", "cherry") is the correct answer to “How do you create a vector of characters in R”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Decimal values are referred as . . . . . . . . data types in R.
Correct Answer: Option A — Numeric
Detailed Academic Explanation:
Numeric is the correct answer to “Decimal values are referred as . . . . . . . . data types in R.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The . . . . . . . . function can be used to create vectors of objects by concatenating things together.
Correct Answer: Option B — c()
Detailed Academic Explanation:
c() is the correct answer to “The . . . . . . . . function can be used to create vectors of objects by concatenating things together.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
An ordered factor is used to represent an . . . . . . . .
Correct Answer: Option A — Ordinal variable
Detailed Academic Explanation:
Ordinal variable is the correct answer to “An ordered factor is used to represent an . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? x <- c("a", "b", "c") > as.numeric(x)
Correct Answer: Option A — Warning
Detailed Academic Explanation:
Warning is the correct answer to “What will be the output of the following R code? x <- c("a", "b", "c") > as.numeric(x)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > m <- 1:10 > m
Correct Answer: Option A — 1 2 3 4 5 6 7 8 9 10
Detailed Academic Explanation:
1 2 3 4 5 6 7 8 9 10 is the correct answer to “What will be the output of the following R code? > m <- 1:10 > m”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What should we use to access elements with a value greater than five?
Correct Answer: Option A — Subsetting commands
Detailed Academic Explanation:
Subsetting commands is the correct answer to “What should we use to access elements with a value greater than five”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Lists can be coerced with which function?
Correct Answer: Option A — As.lists
Detailed Academic Explanation:
As.lists is the correct answer to “Lists can be coerced with which function”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which dimension corresponds to the explanatory variables collected for each species?
Correct Answer: Option B — Second
Detailed Academic Explanation:
Second is the correct answer to “Which dimension corresponds to the explanatory variables collected for each species”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > m <- matrix(nrow = 2, ncol = 3) > dim(m)
Correct Answer: Option B — 2 3
Detailed Academic Explanation:
2 3 is the correct answer to “What will be the output of the following R code? > m <- matrix(nrow = 2, ncol = 3) > dim(m)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- factor(c("yes", "yes", "no", "yes", "no")) > table(x)
Correct Answer: Option A — no yes 2 3
Detailed Academic Explanation:
no yes 2 3 is the correct answer to “What will be the output of the following R code? > x <- factor(c("yes", "yes", "no", "yes", "no")) > table(x)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following code constructs vector of length 11?
Correct Answer: Option C — > v <- 2*x + y + 1
Detailed Academic Explanation:
> v <- 2*x + y + 1 is the correct answer to “Which of the following code constructs vector of length 11”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we access the first component of the list?
Correct Answer: Option A — Number of the position
Detailed Academic Explanation:
Number of the position is the correct answer to “How can we access the first component of the list”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.