R code file 0 kb after saving with previous version of R

Hello Team,

I have a similar problem as mentioned in R Code file is becoming 0 KB after saving

Unfortunately, the solutions offered in that post don't work for me (downloading the previous version of R 4.1.3., a new version of Rstudio and I have also tried changing the encoding settings of R).

The problem is specific to a file I made last May. In May, I worked on this file and saved it on my laptop. At the end of the day, I emailed this file to myself as a back-up. The next day I continued working on the file that was saved on my laptop and the code was there. Now I want to check something in that piece of code but the file is empty and it also says 0 kb. What's odd is that the attachment of the email that I sent to myself is also empty while I did continue working on that file that was saved on my laptop the next day. Otherwise I would have noticed an empty file in May already. Previous versions of the code that I saved on my laptop (and also backed-up via email) are also empty. I have the feeling there is something in that file that is not compatible anymore with R or Rstudio but unfortunately downloading previous versions of R does not help.

It would be great if anyone can help.

Thanks,
Hester

Hi @Hester1,
Welcome to the RStudio Community Forum.

Try opening the old R script file in a simple text editor (E.g. Notepad on Windows). From there you can cut-and-paste the commands into a new, clean script file in RStudio. Do not use word-processing software for this (E.g. Microsoft Word) as it will introduce invalid characters (E.g. smart-quotes).

Not an ideal solution but it may work.

Hi DavoWW,
Thank you for the quick reply and for your suggestion. Unfortunately, if I open the file in Notepad it also empty. If you have any other thoughts, I am happy to hear them. Thank you for thinking along!

Hi @Hester1,
See if there is a .Rhistory file in your working directory. Its contents should appear in the History pane in RStudio. It contains commands that have previously been run - they can be highlighted in RStudio and copied via the "send too console" button.

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.