R Programming Examples
Unlike the SAS course materials on CodeHurry, which are organized into structured lessons, this section provides a collection of R programming examples developed from prior data analysis projects. These examples demonstrate selected applications of R programming and practical coding approaches used in analytic tasks.
Demonstrates how to import and export data in R using a variety of
file formats, including SAS, text, CSV, Excel, and JSON files.
Covers read.table(), read.csv(),
read_excel(), fromJSON(), and
save()/load() for creating and managing
R data objects.
Demonstrates how to explore built-in datasets in R packages using
data(), head(), class(),
mode(), and typeof() to examine data
structures and variable types.
Demonstrates basic data frame manipulation and exploratory data analysis in R. Extract variables and subsets, count missing and specific values, create frequency tables, and sort a data frame.
View Code
Uses the dplyr package to filter observations, group data by selected
classification variables, compute aggregate counts, and generate a formatted
summary table. Uses knitr::kable() to create a Markdown-formatted
table and write the output to a text file.
Demonstrates the difference between lapply() and
sapply(). lapply() returns a list,
while sapply() simplifies the result to a named
vector, matrix, or array when possible.
Demonstrates commonly used R utility functions, including
dir.exists(), file.exists(),
list.files(), rm(), and
sink(), for managing files, directories,
workspace objects, and output.
The R programming materials provided on this website are intended for educational and reference purposes only. The author assumes no responsibility for errors, omissions, or consequences resulting from the use of these materials. Users should independently verify program logic, analytical assumptions, and results before applying these examples to their own research or production analyses.
R® is a registered trademark of the R Foundation for Statistical Computing. CodeHurry is not affiliated with, endorsed by, or sponsored by the R Foundation for Statistical Computing. R-related programming examples on this website are provided solely for educational and reference purposes.