# Base R
fruit_df <- data.frame(
fruit = rep(c('leaves','fruit','bark','none'), 4),
inter.distance = rnorm(16)
)
str(fruit_df)
#> 'data.frame': 16 obs. of 2 variables:
#> $ fruit : Factor w/ 4 levels "bark","fruit",..: 3 2 1 4 3 2 1 4 3 2 ...
#> $ inter.distance: num 0.227 0.844 -0.851 -2.605 -1.332 ...
# Tidyverse
library(tidyverse)
fruit_tbl <- tibble(
fruit = rep(c('leaves','fruit','bark','none'), 4),
inter.distance = rnorm(16)
)
str(fruit_tbl)
#> Classes 'tbl_df', 'tbl' and 'data.frame': 16 obs. of 2 variables:
#> $ fruit : chr "leaves" "fruit" "bark" "none" ...
#> $ inter.distance: num -2.345 -0.234 0.169 -0.83 0.16 ...
Created on 2018-12-21 by the reprex package (v0.2.1)