Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ascii fails on dataframes created by aggregate #1

Open
EmmanuelCharpentier opened this issue May 21, 2021 · 0 comments
Open

ascii fails on dataframes created by aggregate #1

EmmanuelCharpentier opened this issue May 21, 2021 · 0 comments

Comments

@EmmanuelCharpentier
Copy link

The following test code :

CreateDataset <- function(Taille=30, Ncat=3) {
  Cats <- factor(letters[1:Ncat])
  Probs <- runif(Ncat,0,1)
  Probs <- Probs/sum(Probs)
  Cat <- sample(Cats, size=Taille, replace=TRUE, prob=Probs)
  Moys <- 1:Ncat
  Val <- rnorm(Taille, Moys[as.integer(Cats)], 1)
  Res <- data.frame(Cat=Cat, Val=Val)
  return(Res)
}
DS2 <- CreateDataset()
foo <- aggregate(Val ~ Cat, data=DS2,
                 FUN=function(x)
                   c(N=length(x), Nmiss=sum(is.na(x)),
                     Moy=mean(x, na.rm=TRUE),
                     SD=sd(x, na.rm=TRUE)))
ascii(foo, asciiType="org", format="nice", digits=3)

fails with the message :

> ascii(foo, asciiType="org", format="nice", digits=3)
Error in 1:ncol(xx) : l'argument est de longueur nulle

I intend to explore this annoying bug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant