R won't recognize updated CSV - r

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.

Related

OfficeR error: "Docx is already edited", but file doesn't even exist yet. What could be going on?

I have a problem that would be difficult to replicate, thats why i just want ideas of what could be behind this error. When i create a docx an want to save it in the NAS in my office, i would get this error (where doc2 is the docx and Direc4 is my direction):
Error in print.rdocx(doc2, target = Direc4) :
H:\DpProMon\DPM\Programa Monetario Diario\2021\Actas\23 Ago Informe
comité monetario y cambiario.docx is already edited. You must close
the document in order to be able to write the file.
Nevertheless, the File dont exist yet. what could be going on?
Sometimes when im triying to save an actual Word using office, i could get an error that someone else is editing the file (while thats not actually true), and that error would dissapear after a couple seconds. But in R this error doesnt stops. Some help?
In my case I couldn't find the temp file. I deleted cache, temp files from word and local, hidden files in my folder..etc. Could be because in my case I'm using GitHub desktop and also Dropbox so maybe that adds more temp files. The only solution was to change the name of the printed file each time you want to save it. Silly but works.

Cannot open the file after writing xlsx file using R openxlsx package

At first, I tried to read and write xlsx files in R (while comparing the output between the xlsx and openxlsx packages).
I work on mac os.
It worked well to read xlsx files using the read.xlsx() from both packages.
However, when it comes to writing a new file, only the xlsx::write.xlsx() worked.
To be more exact, the openxlsx::write.xlsx() command gave no error, and an xlsx file was successfully saved, but when I tried to open the file using Numbers (by double clicking on the file in the folder), an error message popped up telling me the file cannot be opened.
I tried different data frames, but the results remained the same. To show an example, please refer to the following line which I took directly from R help page. It should work but does not work for me.
write.xlsx(iris, file = "writeXLSX1.xlsx", colNames = TRUE, borders = "columns")
Anyone tell me what the problem is? I tried to google for old threads but it seems no one is discussing this problem. I know in many similar threads people suggested changing packages, okay...before that, can you tell me what the limitations of openxlsx are?

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

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?

Load an .RData file triggers `Error: embedded nul in string:` error

I am sorry about posting a not reproducible error but the task is with huge and not splittable files (.RData ones to be precise).
There are several similar questions, like this one or this other one but they all are made for importing .csv files which is not my case.
As title, I am trying to load with the load function an .RData files but this triggers this error:
load("trip.Rdata")
Error: embedded nul in string: ''<div id=BOD,socationid="7278708">\0\004\0\t\0\0\0\037<span ->\0\004\0\t\0\0\0.<div id="MAINWRAP" c'
I've also tried with attach that, by documentation, is able to handle .RData files but the error is always the same.
Now, this is awkward because and .RData file is the last one from which I would expect an error triggered.
To be honest I do not even know how to ask this question properly because of its awkwardness (I can understand the downvote).
Maybe a solution might rely on the fact that the file is been saved under windows OS and I'm trying to load it on a Mac OS but I can't figure out a way, a possible cause nor a possible solution.
Any help is appreciated.

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