Introduction to R (part 1)

Photo by Lukas Blazek on Unsplash

Things to know before learning R

Installation

To Install R

To Install RStudio

Running R code

> 24 + 7 + 11
> 24 + 7 + 11 
[1] 42
> print(“Hello world!”) 
[1] “Hello world!”
# An addition
5 + 5
[1] 10
# A subtraction
5–5
[2] 0
# A multiplication
3 * 5
[3] 15
# A division
(5 + 5) / 2
[4] 5
# Exponentiation
2^5
[5] 32
# Modulo
28%%6
[6] 4
# Assign the value 42 to x
x <- 42
# Print out the value of the variable x
x
[1] 42
# Assign a value to the variables my_apples and my_oranges
my_apples <- 5
# Add these two variables together
my_oranges <- 6
# Create the variable my_fruit
my_fruit <- my_apples + my_oranges
# Print out the value of the variable my_fruit
my_fruit
[1] 11
 h <-  “Hello”h [1] “Hello”
> h <- “Hello”> yourname <- readline(“What is your name? “)What is your name? Lilian> paste(h, yourname)[1] “Hello Lilian”

Getting help in R

> help(Syntax)
> ?Syntax
> help.search("histograms")
> ??"histograms"