Lost code in Rstudio- r script is blank after computer crash - r

I was working in Rstudio and had previously successfully saved a file/Rscript. Sometime later, i was working on the same file and the computer froze, so I turned it off because I hadn't made much progress on the original work. When i reopen R, this file still exists on my computer but when loaded into R, the file is blank except for one line of: "........................................", i.e. a really long elipsis, which was highlighted in red.. Any help on how I can get my original code back?

Related

R won't recognize updated CSV

so this is a super basic question that I'm hoping someone can help me with (I'm super new to R, so my troubleshooting is remedial at best).
I noticed there were some spelling errors in my data, so I went back to the CSV file, made the changes to the file, saved, closed out, and re-read in the data using read.csv(). Everything showed up and worked as normal until I wanted to simply run a count of the entries in three of the columns (I've done this numberous times with the exact same code and exact same CSV file with the exact same working directory, no spelling errors), but for whatever reason I got the following error message:
Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'FFS_TargetingEventsAllCSV2.csv': No such file or directory
I restarted everything, reset the working directory, doublechecked spelling and used getwd(), but encountered the same problem.
So I decided to use an older backup version of the same dataset. I was able to read it in as normal, and I was able to run my counts. However, I noticed there were similar spelling errors. So I went back to the CSV, made the necessary changes, re-read in the CSV. Everything looked normal until I ran the counts again and saw the exact same spelling errors, unchanged.
So I decided to start fresh and re-save the file (Save As) under a new name, new CSV, same working directory...same. exact. issue.
Every time I opened the CSV file on my desktop, it shows me the most up to date version, but I can't figure out why R isn't recognizing any changes. I even made new, subtle spelling changes in a different column to see if that would make a difference, but nope.
To clarify, the data in the three colums of interest are just 2-3 letters (i.e. FSP). It's only text, sometimes with a hypthen (i.e. HTBR-DA). I'm not trying to run any stats/tests or anything, I just want summary statistics. I also updated my R/RStudio last Thursday, so I have the most recent version of the software as well.
Any advice on this would be much appreciated.

I have issues with saving my script in R x64 on my windows 10 pc, with crashing etc

Every time I work on a script in R I come across the problem, that R isn't able to save my script, although I don't use problematic file names and put an .R in the name. I get an error message where the pathname is displayed, as to show me that there is a problem with that. I tried copy-pasting my script into a new one, but the problem persists with the new script file. Furthermore, when I try to copy the text and paste it after having restarted R (the console), it does not work. The scripts, the original one which has stayed blank, as saving did not work, or a new blank one, stay blank when trying to past text.
I should add that R seems to crash when it tries to save the original script that is not savable. When I close the console, R warns me that I have not saved the script, so I press on save before closing. Then R seems to save it, but ultimately crashes.
Later on, I realized that the copy-pasting does not work on my computer at all. I think this problem only started from the moment on I could not save my script in R.
I would be grateful for support from the community.
I'll have an exam where we need to upload our script, so I really need the saving to work.
Greetings,
J.C.

My R script has been turned entirely into blank spaces. Is this recoverable?

If I knew how to reproduce this then I would, but I have never encountered this before. I saved my work using RStudio as I normally would, saving the progress of writing my R script. But when I opened it the next day, the entire script has been blanked. It still has the same file size as before, but nothing appears when I open it in RStudio. It just has a blank line 1.
If I open the script in Notepad++ I can see that the entire file has NUL characters. What has happened here? Is this recoverable?

Knitr Getting "Stuck" When Adding Any Code to a R Markdown File

Although recently I have been encountering an issue with the Knit function "stalling" as in the output in the consul only makes it through 66% of the first "unnamed code chunk" and never progresses any further (screenshot).
With the above screen shot I downloaded a .RMD file and it Knit just fine the first time when I just added my name (but no code), but when I add anything for code (as I have in the screenshot) it gets "stuck" and never progresses past what you see in markdown console. (Sorry this screenshot is an example .RMD File I am using from my grad stats class.)
The other week I had this issue with some data and resolved it by changing the folder where the .RMD file was saved and that seemed to fix it that time. Although now I am encountering the issue again and I cannot seem to fix it this time.
The first time it seemed to be due to me storing all my files on google drive which synchronizes with my computer and maybe R struggles with processing the intermediate files? Thus that time once I saved the file to my desktop and directed the output file there it worked. Although I have also tried to save the files all in a folder on my desktop this time and it seems to not resolve the issue.
Has anyone had this issue of knitr stalling indefinitely or know what the root cause may be. This has been happening to all my .RMD files lately (and I have uninstalled and reinstalled r/rstudio).
Cheers!
-Nathan

Generating Excel file with XLConnect-Removed Feature: Format from /xl/styles.xml part (Styles)

I am using XLConnect in R for the purpose of daily report generation. I have a program that runs automatically at specific time to append the data for most recent date daily into an excel file (Excel 2007). The program works fine to do this task. But, sometimes when i open the excel file it says that "Excel found unreadable content. do you want to recover the content of this workbook?"
The best part of this issue is that i can't reproduce this issue again to know the exact root cause for the problem. It arises in a random manner. Because, when i try to run the program again it works fine. Can somebody help me to identify the root cause?

Resources