RStudio R File Corruption

回眸只為那壹抹淺笑 提交于 2019-12-04 12:08:49

It's not clear what happened to corrupt your file (and thus how to fix it if possible) and it is kind of ominous that you're just seeing 0's in other text editors, but I'll give you my best suggestion and some tips.

Suggestions for Attempting Recovery

  1. Since your other R files were unaffected, you should have a messy record of your code in the history. Use the history to reconstruct your code.

  2. Access a copy of your file from any version control, cloud, or offline backup you may have used -- git, SVN, iCloud, SugarSync, Dropbox, etc (I realize you probably wouldn't have posted this question if that were an option, but I had to throw it out there).

  3. Use a Hex or sector editor to try to recover the data.

  4. Use a data recover program to find an old version of your file.

  5. Inspect your trash or recycling bin to see if it has an old version. Depending on your OS and the settings of how you (insecurely or securely) delete files, then you may be able to undelete a deleted version, even if it's not immediately available.

  6. Try different methods of recovering text data from corrupted text files like OpenOffice's and Microsoft's suggestions.

Tips for the Future

I know that hindsight is 20/20, but a few quick tips for good measure:

  1. Use version control. Git is supported in RStudio's GUI interface.

  2. Have more than one version of your file. Many professors and professionals recommend writing/storing code in a text editor and using your IDE only for the working copy.

  3. Make backups. Distinct from #2, you should backup your files to a hard drive, flash drive, or cloud service like Dropbox or Spideroak.

It might be an old thread and it might have been covered in 'user4458796' answer in suggestion #1 ("Use the history..."), but:

My friend had the same problem and we managed to recover the code from a 'history_database' files located on Windows at: 'C:\Users\%user%\AppData\Local\RStudio-Desktop\'

I assume there is an equivalent location in Linux in general.

Hopefully I won't get downvoted, just sharing my 2cents.

Ben.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!