简体   繁体   中英

How to exclude variables from the output of describeBy in the psych package?

我有一个 describeBy 的输出,它工作正常,但是由于我的数据集有很多我目前不感兴趣的变量,因此很难管理,有没有办法排除变量(或执行 describeBy在特定变量上)?

Subset the data frame by a vector of column numbers (or negative column numbers to exclude), names or a logical vector. Here we only describe columns 2, 3 and 4.

library(psych)
data(sat.act) # test data

describeBy(sat.act[2:4], sat.act$gender)

giving:

 Descriptive statistics by group 
group: 1
          vars   n  mean   sd median trimmed  mad min max range  skew kurtosis   se
education    1 247  3.00 1.54      3    3.12 1.48   0   5     5 -0.54    -0.60 0.10
age          2 247 25.86 9.74     22   24.23 5.93  14  58    44  1.43     1.43 0.62
ACT          3 247 28.79 5.06     30   29.23 4.45   3  36    33 -1.06     1.89 0.32
----------------------------------------------------------------------------------------------------------------------------- 
group: 2
          vars   n  mean   sd median trimmed  mad min max range  skew kurtosis   se
education    1 453  3.26 1.35      3    3.40 1.48   0   5     5 -0.74     0.27 0.06
age          2 453 25.45 9.37     22   23.70 5.93  13  65    52  1.77     3.03 0.44
ACT          3 453 28.42 4.69     29   28.63 4.45  15  36    21 -0.39    -0.42 0.22
describeBy(sat.act[2:4], sat.act$gender, skew= FALSE, range = FALSE)

这将消除偏斜、峰度、最小值、最大值和范围。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM