c()
function.
cool_numeric_vector <-
c(4, 8, 15, 16, 23, 42)
cool_numeric_vector
## [1] 4 8 15 16 23 42
""
or ''
).
cool_character_vector <-
c("I", "like", "bananas", "and", "rhubarb", "pie")
cool_character_vector
## [1] "I" "like" "bananas" "and" "rhubarb" "pie"
matrix()
function based on the numeric
vector you built in the first exercise.
nrow
or ncol
option to get the proper layout of the matrix.
cool_matrix <- matrix(cool_numeric_vector, nrow = 3)
cool_matrix
## [,1] [,2]
## [1,] 4 16
## [2,] 8 23
## [3,] 15 42
list()
function
cool_list <-
list(
cool_numeric_vector,
cool_character_vector,
cool_matrix
)
cool_list
## [[1]]
## [1] 4 8 15 16 23 42
##
## [[2]]
## [1] "I" "like" "bananas" "and" "rhubarb" "pie"
##
## [[3]]
## [,1] [,2]
## [1,] 4 16
## [2,] 8 23
## [3,] 15 42
as.data.frame()
function .
[[]]
.
cool_data_frame <- as.data.frame(cool_list[[3]])
names(cool_data_frame) <- c("one", "two")
cool_data_frame
## one two
## 1 4 16
## 2 8 23
## 3 15 42