Coding basics

R as a calculator

1000 / 10
## [1] 100
x <- 1000/10
# x

assignment symbol

x <- 3 * 4
x
## [1] 12

What’s in a name?

this_is_a_really_long_name <- 2.5
r_rocks <- 2 ^ 3

Calling functions

Use of TAB

seq(from = 1, to = 10, by = 1)
##  [1]  1  2  3  4  5  6  7  8  9 10

continuation character, +

seq(from =1, to = 10)
##  [1]  1  2  3  4  5  6  7  8  9 10

Printing to screen

y <- seq(1, 10, length.out = 5)
y
## [1]  1.00  3.25  5.50  7.75 10.00
(y <- seq(1, 10, length.out = 5))
## [1]  1.00  3.25  5.50  7.75 10.00