
数据结构
|
159
)
#> # A tibble: 19 x 4
#> city county state pop
#> <chr> <chr> <chr> <dbl>
#> 1 Chicago Cook IL 2853114
#> 2 Kenosha Kenosha WI 90352
#> 3 Aurora Kane IL 171782
#> 4 Elgin Kane IL 94487
#> 5 Gary Lake(IN) IN 102746
#> 6 Joliet Kendall IL 106221
#> # ... with 13 more rows
值得注意的是,在前面的示例中,我们无缝地混合了 tibble 和数据框。suburbs 是一
个 tibble,因为我们使用了函数 read_csv,它生成了 tibble,而 newRow 是使用 data.
frame 创建的,它返回一个传统的 R 数据框。请注意,数据框包含因子而 tibble 不包含:
str(suburbs) # a tibble
#> Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 17 obs. of
#> 4 variables:
#> $ city : chr "Chicago" "Kenosha" "Aurora" "Elgin" ...
#> $ county: chr "Cook" "Kenosha" "Kane" "Kane" ...
#> $ state ...