sumtable throws Error since package update
L3ft2di3 opened this issue · comments
Hey,
so far the sumtable() function worked great! However, since I updated the vtable package, the function throws the following Error message:
"Error in aggregate.data.frame(lhs, mf[-1L], FUN = FUN, ...) :
no rows to aggregate"
I got so far, that this error message emerge when the input dataframe is empty (has zero rows). However, the input table is not empty and as I said, the code worked with the very same inputs before updating the package.
Any ideas how to fix this?
Currently installed is version: vtable_1.4.2
Edit: Before, had vtable_1.4.1 installed, which worked w/o problems.
Cheers
Thorben
Hmm, shoot. It is working for me - does it produce this error with every data set for you, or just sometimes? Can you give an example of some data/code that throws the error?
So my data look like this:
Group <- c("A", "A", "B","A", "B", "A", "B", "B", "B", "A", "C", "C", "C", "C", "C")
Num <- floor(runif(15, min =31, max = 87))
Class <- rep(c("large", "small" , NA), each = 5)
df.test <- data.frame(Group, Num, Class)
I have some variables where I have NAs for the whole group. Oddly, in the real data, for some variables this seems to be okay and the sumtable function can handle the data, but for some variables its not okay and it throws the error described above. Coulnd't really create data that make the error reproducible.
The format should be okay, both variables that are behaving differently are characters, not factors.
So this code throws the error:
tab.test <- sumtable(df.test, group = 'Group', group.test = TRUE, factor.numeric = FALSE, factor.percent = TRUE, factor.counts=TRUE)
"Error in aggregate.data.frame(lhs, mf[-1L], FUN = FUN, ...) :
no rows to aggregate"
And this works:
tab.test <- sumtable(head(df.test, n =10), group = 'Group', group.test = TRUE, factor.numeric = FALSE, factor.percent = TRUE, factor.counts=TRUE)
Sorry, that I could create data that make the error reproducible. Can't hand over the real data, as they are of clinical nature.
Cheers
T
Thank you! I will take a look. For now you may want to revert to the older version.
Going back to v1.4.1 fixed it for now.
This should be fixed with 6addf93
Please try the dev version using remotes::install_github('NickCH-K/vtable')
and let me know if it works for you. Planning to upload to CRAN in a few days.
The dev version works as expected. Thank you for fixing!