I am using compareGroups to analyze a dataset (please see below my data frame).
An error message appears like:
"Error in compareGroups.default(X = X, y = y, include.label = include.label, : None variable can be computed."
I use R-3.3.2
Could you please help me?
Thank you in advance.
David
group gender episod mother father
1 2 0 0 0
1 1 2 0 0
0 1 4 0 0
1 2 4 0 0
0 2 0 0 0
0 2 2 0 0
0 1 3 0 0
0 1 3 0 0
0 1 0 0 0
1 2 2 0 0
1 2 0 0 0
1 1 0 0 0
1 1 3 0 0
1 1 1 0 0
0 2 0 0 0
0 1 0 0 0
0 2 1 0 0
0 1 4 0 0
1 1 0 0 0
1 1 4 0 0
1 1 3 0 0
0 1 1 0 0
1 2 1 0 0
1 2 2 0 0
0 2 0 0 0
0 1 2 0 0
1 2 0 0 0
1 1 1 0 0
1 1 2 0 0
0 2 1 0 0
0 1 4 0 0
0 2 4 0 0
1 2 0 0 0
1 2 4 0 0
1 2 1 0 0
0 1 3 0 0
0 1 1 0 0
1 1 4 0 0
0 1 4 0 0
1 1 1 0 0
0 1 2 0 0
0 2 0 0 0
1 2 0 0 0
0 1 2 0 0
1 2 3 0 0
1 2 3 0 0
1 2 1 0 0
1 2 1 0 0
0 2 3 1 0
1 1 1 0 0
0 2 2 0 0
0 2 2 0 0
1 1 3 0 0
1 1 3 0 0
0 2 1 0 0
0 2 3 0 0
1 2 1 0 0
0 2 1 0 0
1 2 2 0 0
1 2 4 0 0
1 1 0 0 0
1 2 1 1 0
1 2 4 0 0
0 1 3 0 0
0 2 2 0 0
1 2 4 0 0
0 2 3 0 0
0 1 2 1 0
0 1 1 0 0
0 2 4 0 0
1 1 1 0 0
1 2 2 0 0
0 1 4 0 0
1 1 2 0 0
1 1 3 0 0
1 2 3 0 0
1 2 2 0 0
1 1 1 0 0
1 1 3 0 0
1 1 3 0 0
1 1 0 0 0
0 2 3 0 0
0 2 2 0 0
1 2 2 1 0
0 2 0 1 0
0 2 1 0 0
1 2 3 0 0
0 2 1 0 0
0 1 1 0 0
1 2 4 0 0
1 1 0 0 0
1 2 4 1 0
1 2 3 0 0
1 1 0 0 0
0 2 3 0 0
David
Sorry for adding a new question to this thread.
I am running a comparison between two groups, and when I run the code, I get the exact Warning Message as the one mentioned above.
This is what I get:
Warning messages:
1: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
2: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
3: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
4: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
5: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
6: In chisq.test(xx, correct = correction) :
Chi-squared approximation may be incorrect
Although I can then obtain the table of comparisons, I wonder how to interpret these error messages. In particular I want to make sure that I don't end up showing results that should be invalid.
Thank you for your time! Any help will be much appreciated.
Best,
Tomas
I just ran into a very similar problem and it may be linked to using 'data.frame' like objects (such as the 'tbl_df' object, used commonly in dplyr).
I tracked the error down to line 66 and 67 here (https://github.com/cran/compareGroups/blob/master/R/compareGroups.formula.R).
I think the issue is that subsetting a tbl_df using row.names (which returns a character vector) does not work so the X and Xext objects only contain NAs.
I was able to fix this issue by simply calling 'as.data.frame' on my data before passing to compareGroups.
If the maintainers think it appropriate, they could add a check to the beginning of the compareGroups call that converts the data object to a data.frame.