2.1 Starting the First R Session
2.2 R Features
2.3 Vectors in R
2.4 Making Code Clear and Legible
Some few notes before we proceed to the next discussion
Start a new R session, type the following in the console and press Enter
x <- 5
print (x)
## [1] 5
x
## [1] 5
msg <- "hello"
msg
## [1] "hello"
x1 <- 1:5
x1
## [1] 1 2 3 4 5
c(1, 2, 3, 4, 5)
## [1] 1 2 3 4 5
1 + 2 + 3 + 4 + 5
## [1] 15
We try applying sum () function and see what the outputs;
sum (x1)
sum (1:5)
sum (c(1, 2, 3, 4, 5))
All these commands will give us the same output;
## [1] 15