RStudio behaves weirdly

Dear RStudio Community
My RStudio Application on OSX 10.12.5 behaves weirdly. I have some code that I want to execute (not shown here as it is complex and involves non-public packages). RStudio sometimes runs the entire code without problems and at other times stops execution, giving an error message. Interestingly, the code always runs smoothly after restarting RStudio, but keeps failing thereafter. The R.app command-line application always executes the same code without an error (using the source() function). That's why I think the problem can't be in the code but must be with RStudio.
For this reason, I tried updating RStudio to the newest version. When clicking on "Help > Check for Updates" inside RStudio, it first said that there is a new Version available (1.2.1335). When clicking once more a little while later, it said that RStudio is on the newest version, even though it obviously wasn't. So I deleted RStudio and installed the newest version manually. However, also with the newest version, running the code inside RStudio results in the same problems as before. I also tried updating R (now the newest version 3.5.3 installed), but this did not help either.
Any ideas on what might be the problem and how to fix it?

What is the error message you are getting? This could be causes by you running out of RAM memory, but with out more details I'm just guessing.

I get the following error message (translated to english by google translate):

Error in readChar (con, 5L, useBytes = TRUE):
can not open connection
Additionally: Warning message:
In readChar (con, 5L, useBytes = TRUE):
Can not open compressed file 'NA'. Reason maybe 'No such file or directory'

However, I know why I get this error message: I have a list.files()-command that should read a series of files and store the file names as a character vector. However, this list.files()-command sometimes works and sometimes does not, with no apparent pattern or reason. When it does not work, it returns an empty vector (character(0)). The code subsequently tries to read the elements of the vector using the load() function, but with an empty vector, this results in the error message given above.

I also checked the issue with the RAM using activity monitor, but everything seems fine there (memory pressure displays green all the time). Anyway, is there a more sophisticated way to check for memory overload?

Does your code run consistently on a stand alone R console (not in RStudio)? It's hard to figure out the reason for this without a reproducible example, any chance you could try to isolate the problematic part of your code and make one?

Yes, in the R console (R.app) the code runs consistently. I will try to make a reproducible example.

I tried making a reproducible example. However, as I simplify the code, I fail to reproduce the error message. Sometimes even tiny details seem to affect whether the code works or not, even deleting code sections that were commented out before. So it seems totally random to me (random in the sense that the problem can't be in the R code).
It could be though that my computer does not have enough RAM, is there a more elegant way to check memory overload than looking at Activity Monitor?
The CPU load does not seem to be the problem as the computations are done quite quickly, even though i am computing PCAs on some pretty big matrices (using prcomp).

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.