Monday, March 23, 2015

vectors, list, matrix, data frames in R language

##vector

x <- c(2, 5, 6, 1)
y <- c(5, 4, 8, 9)
year <- 1990:1993
names <- c("a", "b", "c", "d")

##postion of element
y[1]
y[length(y)]

##list

person <- list(names = "a", x = 2, y = 9, year = 1990)
person

##list data extraction
person$names
person$x

##column bind
cbind(year, x, y)

##Data Frame
D <- data.frame(names, year, x, y)
nrow(D)

##inside Data frame
D$names
D$names[nrow(D)]

No comments:

Post a Comment