4
What is a tibble
? How she differs from a data.frame
?
The code below creates a data frame..
set.seed(123)
df <- base::data.frame(
id = 1:10,
texto = letters[1:10],
numero = rnorm(10)
)
df
#> id texto numero
#> 1 1 a -0.56047565
#> 2 2 b -0.23017749
#> 3 3 c 1.55870831
#> 4 4 d 0.07050839
#> 5 5 e 0.12928774
#> 6 6 f 1.71506499
#> 7 7 g 0.46091621
#> 8 8 h -1.26506123
#> 9 9 i -0.68685285
#> 10 10 j -0.44566197
class(df)
#> [1] "data.frame"
And this one Tibble with the same data.
set.seed(123)
tbl <- tibble::tibble(
id = 1:10,
texto = letters[1:10],
numero = rnorm(10)
)
tbl
#> # A tibble: 10 x 3
#> id texto numero
#> <int> <chr> <dbl>
#> 1 1 a -0.560
#> 2 2 b -0.230
#> 3 3 c 1.56
#> 4 4 d 0.0705
#> 5 5 e 0.129
#> 6 6 f 1.72
#> 7 7 g 0.461
#> 8 8 h -1.27
#> 9 9 i -0.687
#> 10 10 j -0.446
class(tbl)
#> [1] "tbl_df" "tbl" "data.frame"
Created on 2020-06-17 by the reprex package (v0.3.0)
In addition to Pretty print Tibble carries itself groupings, such as those created by group_by or rowise(), besides Tibble support in a very elegant way df and Tibbles within itself
– Bruno