【发布时间】:2018-07-17 13:58:58
【问题描述】:
默认情况下,使用函数 skim()(在 R 包 skimr 中)创建的对象的 print 方法按字母顺序对变量进行排序。我怎样才能让这种方法按照它们在汇总数据集中出现的顺序打印变量?
# Default (desired) order of variable names
names(iris)
#> [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width"
#> [5] "Species"
# `skim()` sorts variables alphabetically
skimr::skim_with(numeric = list(hist = NULL))
skimr::skim(iris)
#> / ... the output was truncated manually ... /
#>
#> -- Variable type:numeric ---------------------------------------------
#> variable missing complete n mean sd p0 p25 p50 p75 p100
#> Petal.Length 0 150 150 3.76 1.77 1 1.6 4.35 5.1 6.9
#> Petal.Width 0 150 150 1.2 0.76 0.1 0.3 1.3 1.8 2.5
#> Sepal.Length 0 150 150 5.84 0.83 4.3 5.1 5.8 6.4 7.9
#> Sepal.Width 0 150 150 3.06 0.44 2 2.8 3 3.3 4.4
【问题讨论】: