Data Frame Operations and Manipulation
Key takeaway: Practice R with 53+ runnable code examples — vectors, strings, math, data frames, recursion, and sampling — with expected output to verify instantly.
R is a programming language for statistical computing and data analysis. These examples are for data science students, researchers, analysts, and anyone learning R for coursework or work projects.
Quick Start
- Select a topic from the sidebar
- Study the code and expected output
- Run with
Rscript file.Ror paste into RStudio - Modify inputs to experiment and learn
Related:All R Examples · Python Examples · Java Examples · C Examples
[1] "name" "age_years"
name age 1 Ann 19 2 Bob 21
[1] id name <0 rows> (or 0-length row.names)
id name 1 1 Ann 2 2 Bob 3 3 Cara
name 1 Ann 2 Bob
age name 1 19 Ann 2 21 Bob
$A group val 1 A 1 2 A 2 $B group val 3 B 3
id a b 1 1 10 NA 2 2 20 200 3 3 NA 300
name age 2 Bob 21
$df1 [1] 2 $df2 [1] 2
[1] "Hello World"
Frequently Asked Questions
main.R, run Rscript main.R. Or use RStudio.Learn R the Practical Way
R ranks among the top 20 languages on the TIOBE Index, dominant in academia and data science.
Topics Covered
- Vectors, lists, and data frames
- String manipulation and text processing
- Math, statistics, and random sampling
- Control flow — if/else, for, while
- Recursion and custom functions
- File I/O and formatted output
Who Is This For?
- Data science students — coursework and R-based exams
- Researchers — statistical analysis for papers
- Analysts — data wrangling skills for work
- Career switchers — transitioning into data roles