1. Which of the following is NOT a control structure in R?
A . if-else
B . for
C . while
D . switch-case
2. How do you define a function in R?
A . function myFunc() { }
B . def myFunc() { }
C . myFunc <- function() { }
D . create function myFunc() { }
3. What will be the output of c(1,2,3) + c(4,5,6)?
A . c(5,7,9)
B . c(4,5,6,1,2,3)
C . c(1,2,3,4,5,6)
D . Error
4. How do you check the length of a vector?
A . size()
B . length()
C . dim()
D . count()
5. What will seq(1, 10, by=3) generate?
A . c(1,2,3,4,5,6,7,8,9,10)
B . c(1,4,7,10)
C . c(1,5,10)
D . c(1,2,5,7,10)
6. What is the default mode of a vector created using c(1,2,3,4)?
A . Character
B . Integer
C . Numeric
D . Logical
7. How do you remove an element from a vector?
A . remove(vector, index)
B . vector <- vector[-index]
C . del(vector, index)
D . vector.delete(index)
8. What will rep(1, times=5) produce?
A . c(1,1,1,1,1)
B . c(1,5)
C . c(5,5,5,5,5)
D . Error
9. How do you extract the 3rd element from a vector v?
A . v{3}
B . v(3)
C . v[3]
D . v[[3]]
10. What will 1:5 * 2 return?
A . c(1,2,3,4,5,2,4,6,8,10)
B . c(2,4,6,8,10)
C . c(1,2,3,4,5,2)
D . Error
11. What will length(c(TRUE, FALSE, TRUE)) return?
A . 3
B . 2
C . 1
D . TRUE
12. How do you check if an object is a matrix?
A . is.matrix()
B . isMatrix()
C . matrix.check()
D . is.mat()
13. How do you create a 3x3 matrix with values 1 to 9?
A . matrix(1:9, nrow=3, ncol=3)
B . matrix(1,9,3,3)
C . mat(1:9, 3, 3)
D . array(1:9, c(3,3))
14. How do you create a list in R?
A . list(a=1, b=2, c=3)
B . c(a=1, b=2, c=3)
C . array(a=1, b=2, c=3)
D . vector(a=1, b=2, c=3)
15. How do you extract an element from a list in R?
A . listname[element]
B . listname[[element]]
C . listname{element}
D . listname.element
16. What function is used to get the current date?
A . Sys.time()
B . Sys.Date()
C . date()
D . currentDate()
17. What will as.logical(0) return?
A . TRUE
B . FALSE
C . 0
D . Error
18. Which loop is used to iterate over a sequence in R?
A . for loop
B . while loop
C . repeat loop
D . if loop
19. Which function is used to return a value from a function in R?
A . return()
B . output()
C . result()
D . value()
20. Which function is used to assign a value to a global variable inside a function in R?
A . global()
B . assign()
C . set()
D . <<-
21. Which function is used to create a sequence of numbers in R?
A . seq()
B . sequence()
C . range()
D . generate()
22. What does nrow() return? __________________________
23. What does ncol() return? ____________________________
24. What is the output of Sys.time()?_______________________________
25. ________________ function is used to check the type of an object?
26. ____________________ function is used to check if a variable is a function?
27. How do you extract an element from a matrix? ______________________
28. ____________________ function is used to convert a matrix to a vector?
29.What does is.numeric("5") return? ________________________
30.____________________ is used to create an empty vector?
☞ R - Programming MCQs - Unit-1 - [ R-Programming ]
☞ R - Programming MCQs - Unit-2 - [ R-Programming ]
☞ R - Programming MCQs - Unit-3 - [ R-Programming ]
☞ R - Programming MCQs - Unit-4 - [ R-Programming ]
☞ R - Programming MCQs - Unit-5 - [ R-Programming ]
☞ Formal Languages and Automata Theory (FLAT) MCQs - Unit-1 - [ FLAT ]
☞ Formal Languages and Automata Theory (FLAT) MCQs - Unit-2 - [ FLAT ]
☞ Formal Languages and Automata Theory (FLAT) MCQs - Unit-3 - [ FLAT ]
☞ Formal Languages and Automata Theory (FLAT) MCQs - Unit-4 - [ FLAT ]
☞ Formal Languages and Automata Theory (FLAT) MCQs - Unit-5 - [ FLAT ]
☞ PPS MCQs - Unit-1 - [ PPS ]
☞ PPS MCQs - Unit-2 - [ PPS ]
☞ PPS MCQs - Unit-3 - [ PPS ]
☞ PPS MCQs - Unit-4 - [ PPS ]
☞ PPS MCQs - Unit-5 - [ PPS ]
☞ Object Oriented Programming through Java MCQs - Unit-1 - [ OOP_JAVA ]
☞ Object Oriented Programming through Java MCQs - Unit-2 - [ OOP_JAVA ]
☞ Object Oriented Programming through Java MCQs - Unit-3 - [ OOP_JAVA ]
☞ Object Oriented Programming through Java MCQs - Unit-4 - [ OOP_JAVA ]
☞ Object Oriented Programming through Java MCQs - Unit-5 - [ OOP_JAVA ]
☞ Design and Analysis of Algorithms MCQs - Unit-1 - [ DAA ]
☞ Design and Analysis of Algorithms MCQs - Unit-2 - [ DAA ]
☞ Design and Analysis of Algorithms MCQs - Unit-3 - [ DAA ]
☞ Design and Analysis of Algorithms MCQs - Unit-4 - [ DAA ]
☞ Design and Analysis of Algorithms MCQs - Unit-5 - [ DAA ]
☞ Software Engineering MCQs - Unit-1 - [ SE ]
☞ Software Engineering MCQs - Unit-2 - [ SE ]
☞ Software Engineering MCQs - Unit-3 - [ SE ]
☞ Software Engineering MCQs - Unit-4 - [ SE ]
☞ Software Engineering MCQs - Unit-5 - [ SE ]
☞ Data Mining MCQs - Unit-1 - [ DM ]
☞ Data Mining MCQs - Unit-2 - [ DM ]
☞ Data Mining MCQs - Unit-3 - [ DM ]
☞ Data Mining MCQs - Unit-4 - [ DM ]
☞ Data Mining MCQs - Unit-5 - [ DM ]
☞ Computer Organization and Architecture (COA) Objective Question Bank-Unit-1 - [ COA ]
☞ Computer Organization and Architecture (COA) Objective Question Bank-Unit-2 - [ COA ]
☞ Computer Organization and Architecture (COA) Objective Question Bank-Unit-3 - [ COA ]
☞ Computer Organization and Architecture (COA) Objective Question Bank-Unit-4 - [ COA ]
☞ Computer Organization and Architecture (COA) Objective Question Bank-Unit-5 - [ COA ]
☞ Data Structures Objective Type Question Bank-Unit-1 - [ DS ]
☞ Data Structures Objective Type Question Bank-Unit-2 - [ DS ]
☞ Data Structures Objective Type Question Bank-Unit-3 - [ DS ]
☞ Data Structures Objective Type Question Bank-Unit-4 - [ DS ]
☞ Data Structures Objective Type Question Bank-Unit-5 - [ DS ]
☞ Database Management System Objective Type Question Bank-Unit-1 - [ DBMS ]
☞ Database Management System Objective Type Question Bank-Unit-2 - [ DBMS ]
☞ Database Management System Objective Type Question Bank-Unit-3 - [ DBMS ]
☞ Database Management System Objective Type Question Bank-Unit-4 - [ DBMS ]
☞ Database Management System Objective Type Question Bank-Unit-5 - [ DBMS ]
☞ Cyber Forensics Objective Type Question Bank-Part-2 - [ Cyber Forensics ]
☞ Cyber Forensics Objective Type Question Bank-Part-1 - [ Cyber Forensics ]
☞ Java Programming Objective Type Question Bank - [ Java Programming ]
☞ Java Programming Objective Type Questions-Part-1 - [ Java Programming ]
☞ Java Programming Objective Type Questions-Part-2 - [ Java Programming ]