Unable to Open R File - File Corrupted

Hi All,

I am in desperate need of some help. All of a sudden 2 of my files got corrupted for no apparent reason. A few hours ago I was using them, and the next thing I know, I got this message...

WARNING: Failed to restore workspace from 'D:/R/R_HOME/.RData'
Reason: bad restore file magic number (file may be corrupted) -- no data loaded

The file is now completely blank even though the file size remains the same.

Can someone please help me restore these files. These files amount to months of my hard work. Pleas help me.

Rayja, You have my sympathies, it must be a very distressing issue to face.

Can you clarify, you mention 2 files, but the warning message you posted relates to a single file ?

Hi nirgrahamuk,

Thank you for your response. The message that I received was common for both. As soon as I opened the R Workspace, I got that message in the console. In normal circumstances those two files are alwalys saved and restored as soon as I open the R session. But this time around, instead of showing me the content, R displayed this error, along with these 2 R files with content fully erased.

ok, it would be good to see both, and is it the full message, or have you ommitted any part, sometimes it can say 'in addition' and tell you more ?

also it would be good to know your operating system, and whether you can restore from backups etc.

The message I posted above, is the full message. I did not omit anything.
Also, my operating system is Windows 10

Alright then. Lets assume that you don't have backups or the ability to restore the file to a previous state. so it may be the unfortunate case that this workspace is truly corrupted and therefore gone for all intents and purposes.

However, the workspace is a snapshot of a sessions contents, thus if you have code that made the sessions contents, presumably you could rerun the code and regenerate the data that was in the old session ?

Losing work, is always a painful lesson, those of us working with R/Rstudio long enough have had to learn to protect ourselves in various ways. I recommend using git to not only version control code, but to reliably restore it as needed. Also, I disable automatic workspace saving/loading. As I like to be in control of what is saved and loaded, and I treat project work that needs to be reproducible in such a way that I can generate the outputs assuming the inputs are available, and then I can reduce the requirements to back up large amounts of data, to just key input datasets that can not be replaced.

I'm sorry that this future looking advice is the best I can offer you with regard to the workspace session you have seemingly lost.

I have never had this problem but there may be some hope if the file size remains the same. What is D:? A personal drive or off-site/cloud storage?

When did you get the warning? Are the files loading automatically on start-up of the R session or are you issuing a load() command?

When you say the file is blank, what program did you use to open it?

Is this of any use?

On the off-chance that you are running into a local problem and assuming the files are not confidential you might want to upload one or both to a file hostingsite such as Dropbox https://www.dropbox.com or MediaFire https://www.dropbox.com and post a download link here.

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.