I updated my R studio version from R 1.4.1717 to R 4.3.0 and I lost code from my file that I was working with for more than 6 months! [I saw a couple of similar posts in the past which are closed now, that I have linked at the end of my post.] Worst thing is that I do not have a copy of it anywhere and surprisingly only that specific R script (.R file) has been erased. All other R scripts are there but only the specific R script file has been damaged. The total file size shows as 0 Kb and I also cannot see its contents when I open it in Word or Notepad. I think the R script which got damaged was open when I updated the Rstudio version.
I tried running the R script which got erased in another PC with the older version of R (1.4.1717) but that did not work. I am petrified of installing the previous version of R from the original computer from which I lost the data, as I am fearing if that does not work, it might be even difficult to retrieve the data from it. The R script that got erased is the only one in which I had brought dataset from SPSS using foreign package, so, I did try changing the encoding settings of R in the previous computer from which the data got erased, but that did not work!
The only other thing that I have done recently is to use a malicious USB drive on my laptop. But I do not know if it would hamper a particular R file. So, I think the issue has arised because of the update in the R studio version.
Please let me know if you have any suggestions!