Basic R
Objectives
- Introduction to RStudio
- Introduction to Core R Data Types
- Introduction to R Control Flow
- Overview of R Data Input and Output
- R Data Wrangling: Transformation using Base R
- Introduction to scripting with R
Topics
- Basic RStudio tour: console, editor, environment/build/git, help/packages
- How to run RStudio: Application, Server, Cloud
- Basic Data Types
- Vector, Matrix, ... of
int,double,char,logical, ... - Date, Datetime, factors, ...
NA,NaN,NULL- If time: More on types, dispatch, classes, ...
- Vector, Matrix, ... of
- Compound Types
- DataFrame
- List
- Not Covered
- Closure
- Environment
- Language Object
- Getting Data In is part of just about any analysis!
- R excels at this
- truly broad coverage of file formats
- as well as 'backends' such as databases
- or different web-based APIs
- Our focus: read/write of csv data
- Mention other formats: json, xml, ...
- Efficient R-specific storage: rds
- Mention protobuf, msgpack, feather, fst, ...
- Data wrangling topics
data.framemanipulations- modifying by adding columns
- subsetting and summaries
- conditional operation by groups
- merging (and its relationship to SQL joins)
- functional programming approaches
- Rscript and r
- docopt
Core Material
Lecture Slides
- Lecture 11 (2025): R Fundamentals (Box)
- Lecture 12 (2025): R Data Input/Output (Box)
- Lecture 13 (2025): R Data Wrangling (Box)
- Lecture 14 (2025): R Scripting (Box)
Lecture Videos
The core videos which complement the slides are the (now captioned) versions of the 2021 course. As the captions may obstruct some of the displayed code, we also show the uncaptioned original versions.
- Video 17 (2025): Week 6 (Box) also Video 17 (2025, captioned) (ClassTranscribe)
- Video 18 (2021): R Data Type Intro (Box, captioned), also Video 18 (2021): R Data Type Intro (uncaptioned)
- Video 19 (2021): R Control Flow (Box, captioned), also Video 19 (2021): R Control Flow (uncaptioned)
- Video 20 (2025): Week 7 (Box) also Video 20 (2025, captioned) (ClassTranscribe)
- Video 21 (2021): Data Wrangling (Box, captioned) and example code, also Video 21 (2021): Data Wrangling (uncaptioned)
- Video 22 (2021): R Scripting (Box, captioned), also Video 22: R Scripting (uncaptioned)
Extras
- Chapter 4: Basics of R in Lander, R for Everyone, 2017.
- Chapter 5: Advanced Data Structures in Lander, R for Everyone, 2017.
- Chapter 7: R Programming Structures in Matloff, Art of R Programming, 2011.
- Chapter 6: Reading Data into R in Lander, R for Everyone, 2017.
- Chapter 5: Data Frames in Matloff, Art of R Programming, 2011.
- Chapter 6: Factor And Tables in Matloff, Art of R Programming, 2011.
- Sections 1 and 2 of Chapter 11, Group Manipulations in Lander, R for Everyone, 2017.
- Littler examples script directory
Additional Resources
- RStudio IDE cheatsheet
- Section 2.2: RStudio in Lander, R for Everyone, 2017.
- Several of the early chapters in The Art of R Programming by Matloff, 2011.
- R data types and control flow are key topics covered in all introductory tests, so see the additional resources for several other suggestions.
- R Data Import/Export Manual: html and pdf versions
- While R for Data Science is popular, it skips Base R which this lecture block covers
- Titanic titanic/ data directory of examples repo