RStudio R File Corruption

后端 未结 2 757
抹茶落季
抹茶落季 2021-01-03 04:42

I had a R script open in RStudio. The file was saved many times over the course of several weeks and worked perfectly fine when RStudio was opened and closed. However, today

相关标签:
2条回答
  • 2021-01-03 05:17

    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.

    0 讨论(0)
  • 2021-01-03 05:25

    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.

    0 讨论(0)
提交回复
热议问题