kaz-yos / tableone

R package to create "Table 1", description of baseline characteristics with or without propensity score weighting
https://cran.r-project.org/web/packages/tableone/index.html
217 stars 41 forks source link

R crashes when using strata option #40

Open devonboyne opened 6 years ago

devonboyne commented 6 years ago

Hi there,

I've noticed that R will sometimes crash when using the strata option in the CreateTableOne() function. I've been unable to replicate the issue consistently. The problem seems to come and go depending on the number of variables included. I'm not sure if it will help but below is the problem signature provided by R. This issue occurs both in base R and R Studio. I've tried re-installing all packages to their latest version. Any thoughts on what could be the source of this issue?

Problem signature: Problem Event Name: APPCRASH Application Name: rsession.exe Application Version: 1.1.447.0 Application Timestamp: 5ad67649 Fault Module Name: stats.dll Fault Module Version: 3.41.7329.0 Fault Module Timestamp: 59563b37 Exception Code: c0000005 Exception Offset: 00000000000045d3 OS Version: 6.3.9600.2.0.0.16.7 Locale ID: 1033 Additional Information 1: 1d45 Additional Information 2: 1d4536b9e7e18a05ea8687f97e5e4e03 Additional Information 3: 46da Additional Information 4: 46da746a32162c90f7b8cd6fcb5e1f64

rhockney commented 6 years ago

Hello, I have been having the same issue also. It will allow me to create the basic TableOne, however once I try to stratify this by a variable R will state - Not Responding and then crash. I have tried multiple different codes, checked and changed my data format, reinstalled and updated R and tried with multiple different variables and the same issue continues. Has anyone managed to resolve this? Thanks, Rochelle

kaz-yos commented 6 years ago

Is your dataset large? Do you have variables with many categories? It could be fisher.test crashing on a large dataset or a large NxM table.

devonboyne commented 6 years ago

Thank you for the follow-up. My dataset is of moderate size (~1500 obs). There were many categorical variables (~20) and comparisons were made across four strata. Most of the categorical variables were dichotomous but there were some with more than two levels. I suspect that you're right that the issue is with the fisher.test. The issue no longer persists when turning off the test option (test = FALSE). To address the issue, perhaps you could change the default to test = FALSE and implement a warning message when the number of categorical variables or "NxM" comparisons exceeds some sort of threshold that would trigger R to crash (I'm not sure how easy it would be to identify the approximate location of this threshold). Alternatively, perhaps you could supress the Fisher test and solely report the p-value from the Chi-square test (along with a warning message) when some sort of threshold is reached. Thanks again, your package is excellent.

vanthemi commented 3 years ago

Thank you so much! I add test = FALSE and it works!!