R Script Content Lost but File Still Shows 112KB – How to Recover?

I'm facing a serious issue with one of my R scripts and desperately need help recovering its content. Here's what happened:

  1. Problem Description
  • After force rebooting my Windows PC, one critical R script (.R file) shows blank/empty content when opened in RStudio
  • However, Windows Explorer still shows the file size as 112KB (original size)
  • The file appears intact, but content is missing when opened
  1. What I've Tried
    ✓ Attempted to reopen with different encodings (UTF-8, ANSI, etc.)
    ✓ Verified file isn't hidden or read-only
    ✓ Tried opening in Notepad++/VS Code - same empty result

I also tried updating RStudio to the latest version (2024.12.1+563) and R to version 4.5.0, but the issue still persists. Does any one can help me? Any other suggestions would be appreciated

Can you post the file (or a link to it) here?

Thank you for your prompt reply! I’ve shared the file on GitHub for download: https://github.com/williamshell/R-script/issues/1

That link produces a 404 error for me.

Can you download the "total.R" file with the following link https://github.com/williamshell/Wan-et-al-2024-16S_paper-code.

This one also gives a 404 error

1 Like

Please visit the following link, and download the "total.R" file.

This file was saved in ​UTF-8 encoding in RStudio.

GitHub - williamshell/Wan-et-al-2024-16S_paper-code

Thank you for letting me know. Due to a GitHub account issue earlier, the file linked previously was temporarily unavailable. The issue has now been resolved, and the link should be accessible again. This file was saved in ​UTF-8 encoding in RStudio. Please try it once more, and let me know if you encounter any further problems.

The file does not appear to be UTF-8. It seems to be binary encoding. Most of it is zeros. If you source the file, nothing is added to the R environment. Sorry, this is a dead end.

I tried opening your first file in Emacs and I am getting nothing but 114.3 kb of \0

I agree with prubin, the file is lost.

I understand—it seems this might not be fixable. Still, I truly appreciate you taking the time to look into it. Thanks again!

Thank you for verifying this. I understand the file is corrupted, and I appreciate you taking the time to check it. I’ll reach out to the RStudio developers for further assistance. I really appreciate your time and help!

For future reference, there is a command line tool called strings (on linux, Mac). Running this even on a binary will return ASCII strings only from the binary. I don't know that would work here, but it is something to try if you still have the file.

Good tip. I ran strings against the total.R file but unfortunately got no output.

Thanks for the suggestion about the strings command. I did try running strings on this binary file, but it returned no output.

After further analysis with xxd, I confirmed the file consists entirely of null bytes (0x00) from offset 0001bde0 to 0001be70. This explains why strings found nothing—there are no ASCII characters to extract. @sbanville-delfi @prubin