Creates vector
vec1 = c(1,2,3,4,5,6)
Gives the length of and object.
length(vec1)
## [1] 6
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
Constructs a data frame
vec2 = c(7,8,9,10,11,12)
data1 = data.frame(vec1, vec2)
##plot Makes a scatterplot
plot(vec1, vec2)
Makes a histogram
hist(vec1)
Adds a line to a plot
plot(vec1, vec2)
abline(v = 2, col = "red")
Gives mean of data
mean(vec1)
## [1] 3.5