Process dataframes, matrices, vectors, factors to named tibble
Source:R/entibble.R
dot-to_tibble.Rd
Function called in entibble()
.
Arguments
- .in_data
user data to tibble
- .rowname
user specified rowname; ignored if no rownames
- .vec_name
The name of the expression; passed to
.vector_2_tibble()
Examples
.to_tibble(head(mtcars), 'vehicle')
#> # A tibble: 6 × 12
#> vehicle mpg cyl disp hp drat wt qsec vs am gear carb
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Mazda RX4 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 Mazda RX4 W… 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 Datsun 710 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 Hornet 4 Dr… 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 Hornet Spor… 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 Valiant 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
iris |> .to_tibble()
#> # A tibble: 150 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # ℹ 140 more rows
letters |> .to_tibble()
#> # A tibble: 26 × 1
#> ``
#> <chr>
#> 1 a
#> 2 b
#> 3 c
#> 4 d
#> 5 e
#> 6 f
#> 7 g
#> 8 h
#> 9 i
#> 10 j
#> # ℹ 16 more rows
letters |> rlang::set_names() |> .to_tibble()
#> # A tibble: 26 × 2
#> rowname ``
#> <chr> <chr>
#> 1 a a
#> 2 b b
#> 3 c c
#> 4 d d
#> 5 e e
#> 6 f f
#> 7 g g
#> 8 h h
#> 9 i i
#> 10 j j
#> # ℹ 16 more rows
list(1:10,11:20) |> .to_tibble()
#> # A tibble: 2 × 1
#> ``
#> <list>
#> 1 <int [10]>
#> 2 <int [10]>
as.matrix(list(1:3,11:13,c('a','b','c'))) |> entibble()
#> # A tibble: 3 × 3
#> `1` `2` `3`
#> <int> <int> <chr>
#> 1 1 11 a
#> 2 2 12 b
#> 3 3 13 c