Functions

c()

Creates vector

vec1 = c(1,2,3,4,5,6)

length()

Gives the length of and object.

length(vec1)
## [1] 6

log()

Computes the natural log

vec1_log = c(vec1, NA)
log(vec1_log)
## [1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595        NA

data.frame

Constructs a data frame

vec2 = c(7,8,9,10,11,12)
data1 = data.frame(vec1, vec2)

##plot Makes a scatterplot

plot(vec1, vec2)

hist()

Makes a histogram

hist(vec1)

abline()

Adds a line to a plot

plot(vec1, vec2)
abline(v = 2, col = "red")

mean()

Gives mean of data

mean(vec1)
## [1] 3.5