Jørgen K. Kanters
Jørgen K. Kanters

Reputation: 868

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?

Upvotes: 0

Views: 487

Answers (1)

Jørgen K. Kanters
Jørgen K. Kanters

Reputation: 868

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)

Upvotes: 0

Related Questions