data.frame()
get_help() docs
The data.frame() function comes with R and is part of the Base R {base} package.
We use this function to create new data frames from scratch.
Note that the {tidyverse} introduced a variant on the data frame, known as the tibble, which prints more visibly and is generally nicer to work with. We can also directly create tibbles with the {tibble} package functions tibble() or tribble() (use get_help("tibble") to learn more!).
new_data_frame <- data.frame(
first_column_name = values for first column,
second_column_name = values for second column,
...etc for more columns...)# Define a data frame with two columns `a` and `b`,
# making sure the values for a and b columns have the same length.
new_df <- data.frame(a = 12:17,
b = c('a', 'e', 'i', 'o', 'u', 'y') )
new_df## a b
## 1 12 a
## 2 13 e
## 3 14 i
## 4 15 o
## 5 16 u
## 6 17 y