Error in crosstable with fisher.test in R: How to Increase Workspace Size?

62 Views Asked by At

I've been working with the crosstable package in R and encountered an issue when performing contingency table analysis using Fisher's exact test. When executing the command:

crosstable(database, by = variable, test = TRUE)


I receive the following error message:
ℹ In index: 6.
ℹ With name: diagnostico_estadio.
Caused by error in `fisher.test()`:
! FEXACT error 6 (f5xact). LDKEY=621 is too small for this problem: kval=4932139.
Try increasing the size of the workspace.

I've tried to look into the documentation to find a way to increase the workspace size for the fisher.test within the crosstable function but to no avail. Since I'm not accustomed to working directly with source code, modifying the package's internal functions is a bit out of my league.

Has anyone encountered this issue before? How can I increase the workspace size for fisher.test when using crosstable? Any suggestions or guidance on how to approach this would be greatly appreciated.

Thanks in advance for your help!

1

There are 1 best solutions below

0
mfg3z0 On

This issue is addressed in the crosstable documentation on the options page. In summary, you can change the global options to fix this error with the crosstable_fishertest_B parameter. According to the documentation, this parameter controls the "number of simulations to perform when fisher.test() is failing (FEXACT error 7)."

To fix the error, run something like this (you may have to test different values for this parameter, this is just my best guess):

crosstable_options(crosstable_fishertest_B = 5000000)