Contents
R Architecture
Understanding How R Works
R is an interpreted programming language. It evaluates instructions when you execute your code and displays the results.
Three important concepts help you understand how R works:
- Objects: Named items that store values, such as numbers, text, or tables.
- Functions: Reusable operations that perform specific tasks.
- Environment: The space where R stores and manages objects created during your session.
For example, you can store a student's mark in an object and display its value:
marks <- 85
print(marks)
Output:
[1] 85
Here, marks is the object name, <- assigns the value, and print() displays it.
R, RStudio, and R Packages
R, RStudio, and packages serve different purposes in your workflow.
Think of a car:
- R is the engine: It executes code and performs calculations.
- RStudio is the dashboard: It provides a convenient interface with a code editor, Console, and Plots pane.
- Packages are additional tools: They extend R with functions for specific tasks.
For example:
- dplyr helps you select, filter, and transform data.
- ggplot2 helps you create data visualizations.
You need to install R first. RStudio makes it easier to work with R, while packages provide additional functionality when required.
R Project Structure
An R project is a folder that keeps the files for a particular analysis together. A consistent structure makes your work easier to manage, understand, and share.
A typical project structure looks like this:
student-analysis/
├── data/ # Raw and cleaned CSV files
├── scripts/ # R scripts
├── output/ # Charts and reports
└── student-analysis.Rproj
Each folder has a specific purpose:
- data/ stores raw and cleaned datasets.
- scripts/ contains the R code used for analysis.
- output/ stores generated charts and reports.
- .Rproj file helps RStudio manage the project and its working directory.
Best Practice: Keep your data, code, and generated outputs organized separately. This makes the project easier to maintain and reproduce.
R for Data Science
Harini A








