#R Practice Session 1
#Use this script with the intro slides
#Kristen Sosulski 3/23/2017
# R as a calculator
3 + 2
## [1] 5
100/5
## [1] 20
12 + 12 + 12
## [1] 36
#assignment of variables
y=42
y
## [1] 42
#updating of variables
y <- 42
y <- y - 1
print(y)
## [1] 41
#reassignment
x = y
x
## [1] 41
#data types
class(x)
## [1] "numeric"
z = 1.2
class(z)
## [1] "numeric"
b="book"
b
## [1] "book"
#find out data type
class(b)
## [1] "character"
##vectors
x <- c(1, 2, 3, 4, 5, 9)
x + 2
## [1] 3 4 5 6 7 11
#[1] 3 4 5 6 7 11
months <- c(1,2,3,4,5,6,7,8,9,10,11,12)
#alternative
months <- 1:12
months
## [1] 1 2 3 4 5 6 7 8 9 10 11 12
months^2
## [1] 1 4 9 16 25 36 49 64 81 100 121 144
months
## [1] 1 2 3 4 5 6 7 8 9 10 11 12
days =c("Monday","Tuesday","Wednesday")
#data type
class(days)
## [1] "character"
##Functions
sqrt(25)
## [1] 5
mean(c(1,2,3,4,5))
## [1] 3
toupper("hello world")
## [1] "HELLO WORLD"