R Programming Language Certification Professional Standards & Competencies 4 — Questions and Answers
Question 1: Which R package provides tools for creating professional, publication-ready data visualizations aligned with best practices?
- ggplot2, following the Grammar of Graphics framework (Correct answer)
- base plot, because it requires no additional installation
- plotly, because all professional charts must be interactive
- lattice, as it is the oldest and most established system
Correct answer: ggplot2, following the Grammar of Graphics framework
ggplot2's Grammar of Graphics framework enables consistent, layered, and publication-quality visualizations.
Question 2: What is the recommended way to handle credentials (API keys, passwords) in an R project?
- Store them in environment variables or a .Renviron file excluded from version control (Correct answer)
- Hardcode them at the top of the script for easy access
- Store them in a plain text file committed to the repository
- Pass them as function arguments in all function calls
Correct answer: Store them in environment variables or a .Renviron file excluded from version control
Environment variables keep credentials out of source code and version history, preventing accidental exposure.
Question 3: A professional submitting an R package to CRAN must ensure which of the following?
- All examples, tests, and vignettes pass R CMD check with no ERRORs or WARNINGs (Correct answer)
- The package has at least 100 unit tests
- The package avoids using any tidyverse dependencies
- The package size exceeds 1 MB to demonstrate completeness
Correct answer: All examples, tests, and vignettes pass R CMD check with no ERRORs or WARNINGs
CRAN policy requires packages to pass R CMD check cleanly; errors and warnings are grounds for rejection.
Question 4: What is the professional standard for handling missing data in a published R analysis?
- Document the extent of missingness, justify the handling method, and apply it consistently (Correct answer)
- Remove all rows with any missing value without comment
- Replace all missing values with zero as a universal default
- Ignore missing values since R functions handle them automatically
Correct answer: Document the extent of missingness, justify the handling method, and apply it consistently
Transparent documentation of missing data decisions allows readers to assess potential bias and reproduce the analysis.
Question 5: Which approach best supports accessibility when sharing R-generated reports?
- Providing both visual charts and accompanying descriptive alt text or data tables (Correct answer)
- Using only color to distinguish chart elements for visual clarity
- Delivering reports exclusively as interactive HTML that requires JavaScript
- Omitting axis labels to keep charts uncluttered
Correct answer: Providing both visual charts and accompanying descriptive alt text or data tables
Alt text and data tables ensure that reports are usable by people relying on screen readers or who have color vision deficiencies.
Question 6: When writing an R function intended for use by others, what is considered a professional documentation standard?
- Using roxygen2 comments to document parameters, return values, and examples (Correct answer)
- Writing a separate Word document describing the function behavior
- Relying on descriptive variable names alone instead of formal documentation
- Documenting only functions longer than 50 lines
Correct answer: Using roxygen2 comments to document parameters, return values, and examples
roxygen2 generates standardized help files from structured inline comments, making documentation maintainable and accessible via ?function.
Question 7: Why is it important to set a random seed (set.seed()) in R scripts that involve randomness?
- To ensure reproducibility so that others running the script get the same results (Correct answer)
- To speed up random number generation
- To prevent R from generating truly random numbers
- To comply with CRAN's requirement for deterministic packages
Correct answer: To ensure reproducibility so that others running the script get the same results
set.seed() initializes the random number generator to a known state, making stochastic results reproducible.
Which R package provides tools for creating professional, publication-ready data visualizations aligned with best practices?