I'm having the same issue reported in a previous post here which received no solution.
When I go to run code chunks from an RMarkdown file an error prompt stating "fatal error:unexpected:bad allocation" pops up and then I am forced to abort R.
Copying the same code into an R Script file and running code there works fine. Running code in the console also works fine. I have opened previous projects where the RMarkdown code used to run and knit, but these now also receive the same error when running code chunks. The code lines I am running are standard e.g.
library(dplyr). Occasionaly, a couple of code chunks will run but then the same error occurs later on e.g. on the 3rd chunk running
str(data). However, interestingly, I am able to knit the .Rmd file without an issue.
I have updated my R studio version to
2023.3.1.446, release name
Cherry Blossom. This did not resolve my issue. I have also tried in R version 4.2.2. and 4.1.2 but no luck.
Any suggestions as to what might have gone wrong and how to resolve this issue?
After spending some time trying different solutions I believe I have resolved my problem by updating the
xfun package. I have tested several code chunks from various .Rmd files and things seems to be running as normal (for now at least). It would still be very useful if someone could enlighten me as to what could have been going wrong as this was quite a worrying issue.
Thank you in advance and happy to provide any additional information.