Important MCQs for Advanced R Programming for Data Analytics in Business
1. What function in R is used to create a sequence of numbers from 1 to 10?
A) seq(1, 10)
B) rep(1:10)
C) list(1,10)
D) range(1,10)
Answer: A) seq(1, 10)
2. Which of the following data structures in R is used to store data in a tabular form?
A) Vector
B) Matrix
C) Data Frame
D) List
Answer: C) Data Frame
3. What does the function 'str()' do in R?
A) Converts data to string
B) Displays the structure of an object
C) Creates a string vector
D) Splits a string
Answer: B) Displays the structure of an object
4. In ggplot2, which function is used to add layers to a plot?
A) geom_point()
B) aes()
C) theme()
D) + (plus sign)
Answer: D) + (plus sign)
5. How do you remove missing values from a vector in R?
A) omit(vector)
B) na.rm(vector)
C) na.omit(vector)
D) delete.na(vector)
Answer: C) na.omit(vector)
6. What function would you use to read a CSV file in R?
A) read.csv()
B) read.table()
C) read.xls()
D) read.csvfile()
Answer: A) read.csv()
7. Which package in R is most commonly used for data wrangling?
A) ggplot2
B) dplyr
C) shiny
D) lattice
Answer: B) dplyr
8. In R, what is the difference between '==' and '===' operators?
A) Both are the same
B) '==' is used for assignment, '===' is for equality check
C) '==' is for equality check, '===' does not exist in base R
D) '==' is a logical AND, '===' checks object class
Answer: C) '==' is for equality check, '===' does not exist in base R
9. How do you install a package in R from CRAN?
A) install.package()
B) load.package()
C) install.packages()
D) library()
Answer: C) install.packages()
10. What is the purpose of the 'tidyverse' package in R?
A) It is used for machine learning algorithms
B) It provides a collection of packages for data science
C) It is used for statistical testing only
D) It is used for creating dashboards
Answer: B) It provides a collection of packages for data science