Slides prepared with 💙 & Quarto
Image source: https://r4ds.hadley.nz/

“R is a free software environment for statistical computing and graphics.”
R website link: https://www.r-project.org/
Rank #8 in May 2026: Highest Position (since 2007)
Intially as S language by Bell Labs.
First appeared in August 1993 as R language by:


Demo: https://www.r-project.org/
R version 4.6.0 (2026-04-24)
R name “Because it was There”
R licence “ABSOLUTELY NO WARRANTY”
R prompt >

Don’t save workspace image
It helps in “freshly minted R sessions”.
“put more trust in your script than in your memory”.

Source: R Bloggers
> prompt and press Enter to run.RRender to produce a final HTML, PDF, or Word reportPress Enter key to run the code in console
Copy code to clipboard
12 + 3 in this code + is an operator.
“Operators are used to perform operations on variables and values.”
Source: w3schools
“Arithmetic operators are used with numeric values to perform common mathematical operations.”
Put spaces between and around operators (= + - * /)
Increase screen font size for better view.
| Operator | Name | Example |
|---|---|---|
+ |
Addition | x + y |
- |
Subtraction | x - y |
* |
Multiplication | x * y |
/ |
Division | x / y |
^ |
Exponent | x ^ y |
%% |
Remainder | x %% y |
Source: w3schools
“Comparison operators are used to compare two values.”
| Operator | Name | Example |
|---|---|---|
== |
Equal | x == y |
!= |
Not equal | x != y |
> |
Greater than | x > y |
< |
Less than | x < y |
>= |
Greater than or equal to | x >= y |
<= |
Less than or equal to | x <= y |
Source: w3schools
“Miscellaneous operators are used to manipulate data.”
Source: w3schools
[1] 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
A function is a shortcut for a task we do repeatedly.
“A function, in a programming environment, is a set of instructions.”
sum()sum()The help() function and ? help operator in R.
Use args() function to the get the list of arguments of a function.
Add two numbers: 15 + 27
Create a sequence of numbers from 1 to 10
Create a sequence from 5 to 50, interval by 5
Find the square root of 81
Round the number 3.786 to 2 decimal places
Add two numbers: 15 + 27, 15 + 27
Create a sequence of numbers from 1 to 10, seq(1, 10)
Create a sequence from 5 to 50, interval of 5, seq(5, 50, by = 5)
Find the square root of 81, sqrt(81)
Round the number 3.786 to 2 decimal places, round(3.786, 2)
Everything in one Software codes, results, writing.
Always reproducible re-run work, anytime, by anyone.
Share and publish with other Word, PDF or HTML.
We need a superhero 🐾 RStudio

RStudio is an integrated development environment (IDE) for R and Python from company posit
Download RStudio: https://posit.co/download/rstudio-desktop
“to divide your work into multiple contexts, each with their own”
Source: RStudio & artwork by Allison Horst
.R File)Clean and focused - a .R file contains only code, making it easy to read, edit, and run without any extra formatting.
Fast to execute - you can run the entire script in one go, making it ideal data cleaning scripts, and automation.
Easy to share and version control - a plain .R file is lightweight and it opens immediately.
Ctrl + Enter (Win) / Cmd + Enter (Mac)Ctrl + EnterCtrl + Shift + EnterA variable stores a value, like a box, so you can reuse it.
Use <- to assign (R’s way of saying “equals”): Alt + - (Win) / option + - (Mac)
Character (text - always in quotes), numeric (whole number or decimal) and logical (TRUE or FALSE)
Comment is any line in R that starts with # - R completely ignores it when running code
Type variable name and run
Type variable name and run
Create a variable called my_name with your name.
Create a variable called my_city with your city.
Print both. What class are they?
Writing readable code because other people might need to use your code.
Writing readable code because you might need to use your code, a few weeks/months/years after you’ve written it.
Put spaces between and around variable names and operators (= + - * /).
Break up long lines of code.
Keeping a consistent style.
A vector is a sequence of values of the SAME type.
c() function means “combine” - it is how to build a vector.
R starts counting from 1
length(scores) for how many elements?sum(scores) for totalmean(scores) for averagemedian(scores) for middle valuemax(scores) for highestmin(scores) for lowestrange(scores) for min and max togethersd(scores)for standard deviation.R File)Output is not saved with the code - plots appear in the Plots pane and results in the Console, but closing RStudio loses everything; you have to rerun the script every time to see the output again.
No narrative or context - you can only add short comments with #; there is no space to explain your thinking, interpret results, or present findings in a readable way for others.
Not reproducible as a report — a .R file cannot be directly shared as a document; turning your analysis into something a non-coder can read requires extra steps, unlike .qmd which renders everything in one click.
Create a vector of 5 temperatures (any values you like).
Find the mean, max, and min.
Which temperatures are above 30? (use >= 30)
name city score passed
1 Priya Delhi 88 TRUE
2 Rahul Jaipur 75 TRUE
3 Anita Mumbai 92 TRUE
4 Suresh Lucknow 60 FALSE
5 Meena Pune 85 TRUE
head(participants) first 6 rows (useful for big data)
tail(participants) last 6 rows
nrow(participants) number of rows
ncol(participants) number of columns
dim(participants) rows and columns together
names(participants) column names
str(participants) structure — types of each column
summary(participants) quick stats for each column
$— gives you the whole column as a vector
[row, column]name, age, and favourite_subject.name and favourite_subject columns.25?“An R package is a collection of functions, data, and documentation that extends the capabilities of base R. Using packages is key to the successful use of R.”
Source: R for Data Science, 2e
Install the R package
Call the R package
Update the R package
Remove the R package
If you un-install R or RStudio, you will lose all installed packages.
mean(), sum(), c()add_numbers()function(x, y){result <- x + y & return(result)}F = (C * 9/5) + 32.“An open-source scientific and technical publishing system”
Source: https://quarto.org/ | Artwork from Allison Horst


YAML
Markdown Text
Code Chunk/Block/Cell
More YAML options for HTML ouput https://quarto.org/docs/reference/formats/html.html
---
title: "Hello World"
subtitle: "2nd SARA Bootcamp 2026"
author: "Dr. Ajay Kumar Koli"
date: today
format: html
---
## First Time Coding
- Relax
- Patience
## Having Fun
This is *just* the beginning.
It will be **awesome** at the end.
Learn more from this link <https://quarto.org/docs/reference/formats/html.html>.
## Add Image
Markdown basics https://quarto.org/docs/authoring/markdown-basics.html
---
title: "ggplot2 demo"
author: "Norah Jones"
date: "5/22/2021"
format:
html:
code-fold: true
---
## Air Quality
@fig-airquality further explores the impact of temperature on ozone level.
```{r}
#| label: fig-airquality
#| fig-cap: "Temperature and ozone level."
#| warning: false
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```R Code Blocks https://quarto.org/docs/computations/r.html
Caution
Not all YAML options are supported across every output format.
Module 1 complete 🎉
SARA Institute of Data Science - 3rd SARA Summer School 22-26 July 2026 “R for Researchers”
Course Slides website: https://sara-course-r4b.netlify.app/
