简体   繁体   中英

How do I get summary statistics where I can decide the precision (number of digits) in R?

When I use

describe(combi$pca1)

from the psych package I get to few digits (values close to zero)

when I use describeBy also from the psych package it works by the subgroups

describeBy(combi$pca1, group=combi$realdeath, mat = TRUE, digits = 5)

However when I try to do it without group

describeBy(combi$pca1, mat = TRUE, digits = 5)

I got the error message:

Error in matrix(NaN, ncol = ncol, nrow = n.var * n.groups) :
invalid 'nrow' value (too large or NA)
In addition: Warning message:
In describeBy(combi$pca1, mat = TRUE, digits = 5) :
no grouping variable requested

When I try to follow the documentation

describeBy(combi$pca1, group=NULL, mat = TRUE, digits = 5)

I got identical error message

Error in matrix(NaN, ncol = ncol, nrow = n.var * n.groups) :
invalid 'nrow' value (too large or NA)
In addition: Warning message:
In describeBy(combi$pca1, group = NULL, mat = TRUE, digits = 5) :
no grouping variable requested

How can I get the desired precision of digits for the whole dataset without grouping?

As stated by @aosmith the solution is the simple workaround to include a dummy group

which fools describeBy into believing that groups exist

combi@dummy <- 1 describeBy(combi$pca1, group= combi$dummy,mat=TRUE,digits=5)

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