tibble: Construct a data frame

View source: R/tibble.R

tibbleR Documentation

Construct a data frame

Description

Combine column vectors to form a tibble.

Details

The column vectors must be named and they must have the same length.

tibble(...)

See Also

Other R data structures: c(), list()

Examples

tibble(
  x = c(4, 0, 1),
  y = c("apple", "banana", "economics"),
  z = c(TRUE, TRUE, FALSE)
)

#> # A tibble: 3 x 3
#>     x y         z
   <dbl> <chr>     <lgl>
#>     4 apple     TRUE
#>     0 banana    TRUE
#>     1 economics FALSE

-----------------------------------

# Create a data frame of statistics
# from European countries:

tibble(
  country = c("Hungary", "Norway", "Czech Republic", "Montenegro"),
  lifeExp = c(73.3, 80.2, 76.5, 74.5),
  pop = c(9956108, 4627926, 10228744, 684736),
  gdpPercap = c(18009, 49357, 22833, 9254)
)

#> # A tibble: 4 x 4
#>   country        lifeExp      pop gdpPercap
     <chr>            <dbl>    <dbl>     <dbl>
#> 1 Hungary           73.3  9956108     18009
#> 2 Norway            80.2  4627926     49357
#> 3 Czech Republic    76.5 10228744     22833
#> 4 Montenegro        74.5   684736      9254


cobriant/qelp documentation built on July 1, 2022, 7:24 a.m.