Getting fatal errors when trying to do a data.table printout

I use R version 4.2.2 on a Windows Server x64. I have a cleaning script that runs without errors (and includes several printouts), but then gives me a few different fatal errors when trying to do a simple printout of a data.table once it's finished running:
View(d[!is.na(var3),])
or
d[!is.na(var3),]

In the first case, the view window will open up but will not display the data. After a few minutes, I get a pop-up that says "Fatal error: Unexpected exception: bad allocation". Once I click OK, I get another pop-up that says "R session disconnected: The browser was disconnected from the R session because another browser connected (only one browser at a time may be connected to an RStudio session). You may reconnect using the button below."

I click reconnect and it restarts my session. I run the script all over again and get the same error.

Meanwhile, when I try a simple printout (in the second example), the error I get is
Error: C stack usage 440484109 is too close to the limit

I work on a massive server with 128 GB of memory (task manager says ~40% is being used by all users) so this shouldn't be a problem.

There is someone else using R on a different account on the server, so maybe that's part of the problem? It's odd to me because I use RStudio on other servers, and as long as it's being used on different accounts, there aren't any issues.

Things I have tried:
resetting RStudio's desktop state as suggested here
Reviewing my code and eliminating this iffy regex expression that didn't throw an error but didn't seem to work:
d$var7 <- gsub("\bCA[.*]\b", NA_character_, d$var7)

Here's my session info:

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] stringi_1.7.12    Hmisc_4.8-0       ggplot2_3.4.1     Formula_1.2-5     survival_3.4-0   
[6] lattice_0.20-45   haven_2.5.1       data.table_1.14.8

loaded via a namespace (and not attached):
 [1] xfun_0.37           splines_4.2.2       colorspace_2.1-0    vctrs_0.5.2        
 [5] htmltools_0.5.4     base64enc_0.1-3     utf8_1.2.3          rlang_1.0.6        
 [9] pillar_1.8.1        foreign_0.8-84      glue_1.6.2          withr_2.5.0        
[13] RColorBrewer_1.1-3  jpeg_0.1-10         lifecycle_1.0.3     stringr_1.5.0      
[17] munsell_0.5.0       gtable_0.3.1        htmlwidgets_1.6.1   latticeExtra_0.6-30
[21] knitr_1.42          forcats_1.0.0       tzdb_0.3.0          fastmap_1.1.1      
[25] fansi_1.0.4         htmlTable_2.4.1     Rcpp_1.0.10         readr_2.1.4        
[29] scales_1.2.1        backports_1.4.1     checkmate_2.1.0     deldir_1.0-6       
[33] interp_1.1-3        gridExtra_2.3
   hms_1.1.2           png_0.1-8          

[37] digest_0.6.31 grid_4.2.2 cli_3.6.0 tools_4.2.2
[41] magrittr_2.0.3 tibble_3.1.8 cluster_2.1.4 crayon_1.5.2
[45] pkgconfig_2.0.3 ellipsis_0.3.2 Matrix_1.5-1 rstudioapi_0.14
[49] R6_2.5.1 rpart_4.1.19 nnet_7.3-18 compiler_4.2.2

I would like to avoid a full reproducible example of my script, if possible, as my data is confidential and has a lot of random entry errors. The script is long-ish and the whole thing would take quite a bit of effort to reproduce.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.