














































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The Certificate in R Programming Exam assesses proficiency in using R for statistical computing and data analysis. Topics include data manipulation, statistical modeling, data visualization, and machine learning. Candidates will demonstrate their ability to analyze data and create solutions using R programming. This certification is ideal for data scientists, statisticians, and analysts working with large datasets.
Typology: Exams
1 / 54
This page cannot be seen from the preview
Don't miss anything!















































Q1. What is R primarily used for? A. Web development B. Statistical computing C. Mobile app development D. Game design Answer: B Explanation: R is a language designed for statistical computing, data analysis, and graphics. Q2. Which of the following is an IDE commonly used with R? A. Visual Studio Code B. RStudio C. Eclipse D. NetBeans Answer: B Explanation: RStudio is the most popular integrated development environment (IDE) for R programming. Q3. How can you access R’s built-in documentation for a function? A. info() B. help() C. doc() D. manual() Answer: B Explanation: The help() function (or using a question mark before the function name) provides the documentation for a given function. Q4. What command installs an R package? A. load.package() B. require() C. install.packages() D. add.packages() Answer: C Explanation: install.packages() is the command used to install packages from CRAN. Q5. Which file typically stores user scripts in RStudio? A. .RData B. .Rprofile
C. Script files with a .R extension D. .RHistory Answer: C Explanation: R scripts are stored in files with a .R extension and can be created or edited in the RStudio script editor. Q6. What is the primary difference between the R console and the script editor? A. Console is for code, script editor for images B. Console executes code immediately, while script editor saves code for later execution C. Script editor is only for documentation D. They are identical Answer: B Explanation: The console executes code line by line, while the script editor is used for writing and saving code for later execution. Q7. Which function provides a quick search of help topics in R? A. search.help() B. help.search() C. find.help() D. lookup.help() Answer: B Explanation: The help.search() function helps to locate help topics in R. Q8. In R, which data type is used to represent a sequence of numbers? A. Matrix B. Vector C. List D. Data frame Answer: B Explanation: A vector is the fundamental data type in R for storing sequences of elements. Q9. How do you create a vector in R containing the numbers 1 to 5? A. vector(1,5) B. c(1,2,3,4,5) C. seq(5) D. list(1:5) Answer: B Explanation: The c() function concatenates the numbers into a vector. Q10. Which operator is used for element-wise addition in R? A. +
Q15. Which function is used to create an array in R? A. array() B. matrix() C. data.frame() D. c() Answer: A Explanation: The array() function is used to create arrays in R, allowing for multi-dimensional data structures. Q16. What is a key characteristic of a data frame in R? A. All columns must be numeric B. Columns can have different data types C. It only holds vectors D. It does not support row names Answer: B Explanation: Data frames can store columns with different types of data, such as numeric, character, or factor. Q17. How can you add a new column to a data frame named df? A. df$new <- vector B. add.column(df, vector) C. df + vector D. cbind(df, new=vector) Answer: D Explanation: cbind() can be used to add a new column, though the assignment df$new <- vector also works; here option D is more explicit for creating a new column. Q18. What distinguishes a list from a vector in R? A. Lists can contain different data types, while vectors cannot B. Vectors can contain multiple data types C. Lists are always numeric D. Vectors are slower than lists Answer: A Explanation: Lists are more flexible and can hold elements of different data types, unlike vectors which are usually homogeneous. Q19. What are factors in R used for? A. Storing dates B. Representing categorical data C. Calculating factorials D. Indexing matrices
Answer: B Explanation: Factors are used to handle categorical variables and store them efficiently with levels. Q20. How can you check the levels of a factor variable named f? A. levels(f) B. unique(f) C. f.levels() D. categories(f) Answer: A Explanation: The levels() function returns the unique levels of a factor variable. Q21. Which function is used to read CSV files into R? A. read.xlsx() B. read.table() C. read.csv() D. load.csv() Answer: C Explanation: The read.csv() function is specifically designed for reading CSV files into R. Q22. What package is known for its fast data input functions like read_csv()? A. dplyr B. ggplot C. readr D. tidyr Answer: C Explanation: The readr package provides functions such as read_csv() that are optimized for fast data import. Q23. How would you read an Excel file into R using a common package? A. read.excel() from base R B. read.xlsx() from the xlsx package C. import.excel() from utils D. excel.read() from stats Answer: B Explanation: The read.xlsx() function from packages like xlsx is used to import Excel files. Q24. What function writes data to a CSV file in R? A. write.csv() B. save.csv() C. export.csv() D. write.table()
Answer: B Explanation: Subsetting refers to selecting a portion of the data based on conditions or specific indices. Q30. Which function filters rows based on a condition in R? A. filter() B. subset() C. select() D. arrange() Answer: B Explanation: The subset() function is commonly used to filter rows of a data frame based on specified conditions. Q31. Which operator is commonly used to apply a condition across rows in R? A. && B. & C. | D.! Answer: B Explanation: The single ampersand (&) is used for element-wise logical operations across vectors in R. Q32. How can you sort a vector in ascending order in R? A. order() B. sort() C. rank() D. arrange() Answer: B Explanation: The sort() function sorts a vector in ascending order by default. Q33. What does the order() function return in R? A. A sorted vector B. The indices that would sort the data C. A new data frame D. The original unsorted vector Answer: B Explanation: order() returns the indices that would arrange the vector or data frame in order. Q34. What is aggregation in the context of R data manipulation? A. Combining multiple datasets into one B. Summarizing data by grouping
C. Sorting data alphabetically D. Reshaping data from wide to long format Answer: B Explanation: Aggregation involves summarizing data, such as calculating averages, sums, or counts, for groups within the dataset. Q35. Which function can apply a function over margins of an array or matrix? A. sapply() B. lapply() C. apply() D. mapply() Answer: C Explanation: The apply() function applies a function over the rows or columns of a matrix or array. Q36. What package is primarily used for data manipulation in R with functions like filter() and mutate()? A. ggplot B. dplyr C. tidyr D. readr Answer: B Explanation: dplyr is a powerful package for data manipulation, offering functions such as filter(), mutate(), select(), and arrange(). Q37. What does the mutate() function do in dplyr? A. Filters rows B. Sorts data C. Adds new columns or modifies existing ones D. Merges datasets Answer: C Explanation: mutate() is used to add new variables or modify existing ones based on calculations or transformations. Q38. Which function is used to pivot data from wide to long format in tidyr? A. spread() B. gather() C. pivot_longer() D. pivot_wider() Answer: C Explanation: pivot_longer() is used to convert data from a wide format to a long format in tidyr.
Answer: B Explanation: ifelse() applies a condition across a vector, returning one value if the condition is true and another if false. Q44. How do you create a for loop in R? A. loop for() {} B. for(variable in sequence) { code } C. iterate() D. while() Answer: B Explanation: The syntax for a for loop in R is “for(variable in sequence) { code }”, which iterates over each element in the sequence. Q45. Which loop structure in R executes code repeatedly until a condition is met? A. for loop B. while loop C. repeat loop D. Both B and C Answer: D Explanation: Both while loops and repeat loops are used for iterative execution until a specified condition is met, though repeat requires an explicit break. Q46. What is a key advantage of using the apply() family of functions in R? A. They require more code than loops B. They are slower than traditional loops C. They simplify code and often run faster than explicit loops D. They only work on numeric data Answer: C Explanation: The apply() family of functions makes code more concise and can offer performance benefits over traditional loops. Q47. How do you define a custom function in R? A. def functionName() {} B. functionName <- function(arguments) { code } C. create function functionName() {} D. function functionName() {} Answer: B Explanation: Custom functions in R are defined using the syntax: functionName <- function(arguments) { code }. Q48. What is the scope of a variable defined inside an R function? A. Global
B. Local C. Both global and local D. Static Answer: B Explanation: Variables created inside a function are typically local to that function. Q49. Which function helps to handle errors gracefully in R? A. tryCatch() B. handleError() C. catchError() D. errorCatch() Answer: A Explanation: tryCatch() allows you to catch and handle errors, warnings, or messages in R. Q50. What does the stop() function do in R? A. Begins a loop B. Terminates function execution with an error C. Pauses execution D. Prints data Answer: B Explanation: The stop() function is used to throw an error and halt the execution of a function or script. Q51. What function creates a basic histogram in base R? A. barplot() B. hist() C. plot() D. curve() Answer: B Explanation: hist() is used to create histograms in base R. Q52. Which R function is used for creating scatterplots in base R? A. boxplot() B. plot() C. scatter() D. chart() Answer: B Explanation: The plot() function can create scatterplots when provided with x and y coordinates. Q53. How can you add a title to a base R plot? A. Using title()
Q58. What is a heatmap commonly used for? A. Displaying hierarchical data B. Showing the intensity of data values as colors C. Plotting line graphs D. Creating pie charts Answer: B Explanation: A heatmap visualizes data where individual values are represented as colors, indicating intensity. Q59. What type of plot is best suited for displaying the distribution of a continuous variable? A. Bar plot B. Histogram C. Pie chart D. Scatterplot Answer: B Explanation: A histogram displays the distribution of a continuous variable by grouping data into bins. Q60. Which function in ggplot2 initializes a plot? A. ggplot() B. init_plot() C. start_plot() D. plot.gg() Answer: A Explanation: The ggplot() function initializes a ggplot2 plot by setting up the data and aesthetic mappings. Q61. What statistical measure represents the central tendency of data? A. Variance B. Mean C. Range D. Standard deviation Answer: B Explanation: The mean is the average of a dataset and is one measure of central tendency. Q62. Which function calculates the mean of a vector in R? A. average() B. mean() C. sum() D. median()
Answer: B Explanation: The mean() function computes the arithmetic mean of a numeric vector. Q63. How is the median of a dataset defined? A. The sum of all values B. The middle value when data is sorted C. The most frequently occurring value D. The difference between the highest and lowest values Answer: B Explanation: The median is the middle value in a sorted list of numbers. Q64. Which test in R is used to compare the means of two groups? A. chi-square test B. t-test C. ANOVA D. correlation test Answer: B Explanation: A t-test is commonly used to compare the means of two groups to see if they differ significantly. Q65. What does ANOVA stand for? A. Analysis of Variance B. Annual Variance C. Analysis of Values D. Average Number of Variables Answer: A Explanation: ANOVA stands for Analysis of Variance, used to compare means among three or more groups. Q66. Which function in R calculates a simple linear regression model? A. lm() B. glm() C. reg() D. linear() Answer: A Explanation: The lm() function is used to fit linear models in R. Q67. What is the primary purpose of a confusion matrix in model evaluation? A. To summarize data distribution B. To assess the performance of a classification model C. To compute regression coefficients D. To visualize clusters
C. S4 is a deprecated system D. S4 does not support inheritance Answer: A Explanation: S4 is more formal than S3, requiring explicit class definitions and method signatures. Q73. Which of the following is a best practice in R programming? A. Writing long, monolithic scripts B. Using meaningful variable names and proper comments C. Avoiding any comments in code D. Ignoring error messages Answer: B Explanation: Good programming practices include using meaningful variable names, adding comments, and organizing code clearly. Q74. How can you manage memory usage efficiently in R? A. By keeping all objects in memory B. By using vectorized operations and removing unnecessary objects C. By writing more loops D. By storing data in text files Answer: B Explanation: Efficient memory management involves vectorized operations and cleaning up unused objects. Q75. Which function in R is used for profiling code performance? A. system.time() B. prof() C. Rprof() D. profile() Answer: C Explanation: Rprof() is used to profile R code to identify performance bottlenecks. Q76. What is the purpose of version control when working on R projects? A. To track changes and collaborate efficiently B. To increase runtime speed C. To reduce code size D. To format the code Answer: A Explanation: Version control systems like Git help track changes, manage versions, and collaborate with others.
Q77. Which function in R allows you to connect to SQL databases? A. dbConnect() B. sqlConnect() C. connectDB() D. openDatabase() Answer: A Explanation: dbConnect() from packages such as DBI is used to establish connections to SQL databases. Q78. Which package is commonly used for web scraping in R? A. shiny B. rvest C. ggplot D. dplyr Answer: B Explanation: The rvest package simplifies web scraping tasks in R. Q79. What does the rvest package primarily help with? A. Data visualization B. Data import/export C. Extracting data from web pages D. Performing statistical tests Answer: C Explanation: rvest is designed to extract and parse data from HTML and XML content on web pages. Q80. Which function in rvest is used to read HTML content from a webpage? A. html() B. read_html() C. get_html() D. scrape_html() Answer: B Explanation: read_html() is used to import HTML content for further scraping in R. Q81. In machine learning, what is supervised learning? A. Learning with labeled data B. Learning without any data C. Learning with unlabeled data D. Learning without algorithms
B. To visualize the trade-off between true positive and false positive rates C. To show data distribution D. To compare multiple datasets Answer: B Explanation: A ROC (Receiver Operating Characteristic) curve illustrates the diagnostic ability of a classifier by plotting the true positive rate against the false positive rate. Q87. In unsupervised learning, what is the goal of clustering? A. To predict outcomes B. To group similar data points together C. To calculate averages D. To label data automatically Answer: B Explanation: Clustering is used to identify natural groupings in data based on similarity without using labeled outcomes. Q88. Which clustering algorithm partitions data into k groups? A. Hierarchical clustering B. K-means clustering C. Decision trees D. Linear regression Answer: B Explanation: K-means clustering divides data into k clusters by minimizing the variance within each cluster. Q89. What is Principal Component Analysis (PCA) used for? A. To reduce the dimensionality of data B. To increase the number of variables C. To create clusters D. To perform regression analysis Answer: A Explanation: PCA reduces the number of variables by transforming them into a smaller set of uncorrelated components while preserving most of the variance. Q90. Which R function is typically used to perform PCA? A. prcomp() B. pca() C. principal() D. compPCA()
Answer: A Explanation: The prcomp() function is commonly used to perform principal component analysis in R. Q91. What is the purpose of using R Markdown? A. To compile C++ code B. To create dynamic and reproducible reports C. To visualize data D. To connect to databases Answer: B Explanation: R Markdown enables users to create dynamic documents that integrate code, output, and narrative text in various formats. Q92. Which file extension is used for R Markdown documents? A. .Rmd B. .Rtxt C. .Rmdoc D. .Rreport Answer: A Explanation: R Markdown documents have the .Rmd extension. Q93. How do you include a code chunk in an R Markdown document? A. Using triple backticks with {r} B. Using HTML tags C. Using XML tags D. Using single quotes Answer: A Explanation: Code chunks in R Markdown are enclosed within triple backticks and typically start with {r} to indicate R code. Q94. Which output formats can R Markdown generate? A. Only HTML B. HTML, PDF, and Word C. Only PDF D. Only text files Answer: B Explanation: R Markdown can produce output in multiple formats, including HTML, PDF, and Word, as well as slides and other formats. Q95. What is the benefit of using version control in R projects? A. It automates data cleaning B. It tracks changes and facilitates collaboration