Learn R with Real Code Examples
Updated Nov 21, 2025
Installation Setup
Download and install R from CRAN (https://cran.r-project.org/)
Install RStudio for a full IDE experience (optional but recommended)
Set library paths for custom package storage
Use `install.packages()` to add new packages
Verify installation with `R --version` and a test script
Environment Setup
Install R from CRAN
Install RStudio IDE
Set library paths for package storage
Install essential packages
Test R scripts and plots
Config Files
.Rprofile for environment setup
.Renviron for environment variables
R scripts (.R) and notebooks (.Rmd)
Project-specific library paths
Package DESCRIPTION and NAMESPACE files
Cli Commands
R - start interactive REPL
Rscript file.R - run scripts
install.packages('pkg') - install package
update.packages() - update installed packages
R CMD check package - validate package
Internationalization
UTF-8 support
Handles multi-language datasets
CRAN packages support various locales
Reports can be generated in multiple languages
Community examples worldwide
Accessibility
Cross-platform compatibility
Open-source and free
Accessible to statisticians and analysts
Readable syntax for domain-specific tasks
Community support for beginners
Ui Styling
Console-based output
Plots with ggplot2/base graphics
Interactive Shiny dashboards
R Markdown reports (HTML/PDF/Word)
Minimal native GUI, relies on IDE or Shiny
State Management
Global and local variables
Function environments
Mutable lists and data frames
Package namespaces
R session and workspace management
Data Management
Vectors, matrices, lists, data frames
dplyr and data.table for manipulation
tidyr for reshaping
Reading/writing CSV, Excel, databases
Serialization with RDS or feather files