1. What is R used for?
a. Data analysis and statistics
b. Web development
c. Graphic design
d. Game development
Answer: a
2. Which of the following is not a basic data structure in R?
a. Vector
b. Matrix
c. Data Frame
d. Loop
Answer: d
3. What does the <- operator do in R?
a. Subtraction
b. Assignment
c. Comparison
d. Division
Answer: b
4. Which function is used to read data from a CSV file in R?
a. read.table
b. read.csv
c. load_data
d. import_csv
Answer: b
5. Which package is commonly used for data visualization in R?
a. base
b. ggplot2
c. dplyr
d. plotly
Answer: b
6. What does the summary() function do in R?
a. Print the entire dataset
b. Display a brief summary of a dataset's statistics
c. Generate a histogram
d. Create a scatterplot
Answer: b
7. In R, what function is used to remove missing values from a dataset?
a. rm_na()
b. remove_na()
c. na.omit()
d. clean_na()
Answer: c
8. Which operator is used for element-wise multiplication of two vectors in R?
a. ***
b. +
c. /
d. %*%
**Answer: a
9. How do you comment out a single line in R?
a. Using /* /
**b. Using #*
c. Using //
d. Using <!-- -->
Answer: b
10. What is the purpose of the subset() function in R?
a. To create a new dataset from an existing dataset
b. To remove outliers from a dataset
c. To calculate the mean of a dataset
d. To reorder the columns in a data frame
Answer: a
11. Which function is used to install packages in R?
a. require()
b. install.packages()
c. load.package()
d. library()
Answer: b
12. What is the R function for calculating the mean of a numeric vector?
a. avg()
b. mean()
c. average()
d. median()
Answer: b
13. What does the str() function do in R?
a. Convert data types
b. Calculate standard deviation
c. Display the structure of an R object
d. Create a scatterplot
Answer: c
14. Which package is used for data manipulation in R, specifically for functions like filter() and arrange()?
a. dplyr
b. tidyr
c. base
d. plyr
Answer: a
15. In R, which function is used to perform a t-test?
a. ttest()
b. test_t()
c. t.test()
d. perform_t_test()
Answer: c
16. What is the primary data structure for storing categorical data in R?
a. Data Frame
b. List
c. Matrix
d. Factor
Answer: d
17. What does the cor() function calculate in R?
a. Covariance
b. Correlation
c. Variance
d. Mean
Answer: b
18. Which package is used for creating interactive web-based visualizations in R?
a. ggplot2
b. plotly
c. lattice
d. rgl
Answer: b
19. In R, what is the purpose of the aggregate() function?
a. Filter rows based on a condition
b. Group data and perform an operation on each group
c. Remove duplicates from a dataset
d. Sort data in ascending order
Answer: b
20. How can you find the number of rows in a data frame in R?
a. count(df)
b. nrow(df)
c. length(df)
d. rows(df)
Answer: b
21. Which function is used to add new rows to a data frame in R?
a. add_row()
b. insert_row()
c. append()
d. rbind()
Answer: d
22. In R, what function is used to change the data type of a variable?
a. as()
b. convert()
c. to()
d. change_type()
Answer: a
23. Which operator is used to filter rows in a data frame based on a condition?
a. &
b. |
c. !
d. %in%
Answer: a
24. How can you install a package from GitHub in R?
a. install_github()
b. install.package()
c. install_git()
d. install_url()
Answer: a
25. Which function is used to merge two data frames by a common column in R?
a. combine()
b. merge()
c. join()
d. concat()
Answer: b
26. What is the purpose of the strsplit() function in R?
a. Split a string into a list of substrings
b. Combine two strings into one
c. Replace a specific substring in a string
d. Convert a string to a numeric value
Answer: a
27. How can you rename a column in a data frame in R?
a. rename_column()
b. change_column_name()
c. colnames()
d. names()
Answer: c
28. Which package provides the %>% operator for creating pipelines in R?
a. dplyr
b. magrittr
c. pipeR
d. tidyr
Answer: b
29. What is the purpose of the rep() function in R?
a. Generate a sequence of numbers
b. Replicate a vector or value
c. Remove duplicates from a vector
d. Calculate the mean of a vector
Answer: b
30. How can you calculate the cumulative sum of a numeric vector in R?
a. cumulative_sum()
b. cumsum()
c. sum_cumulative()
d. accumulate()
Answer: b
Latest comments (0)