0

I am getting the following error:

Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'bball.worksheet.csv': Permission denied

when I run the following line of code:

write.csv(alltms, file = "bball.worksheet.csv")

This entire script has been literally unchanged for months. The only difference was, today when I logged on, R asked me if I wanted to update. Initially I declined; however, upon getting this error I decided to forge ahead with RStudio-2022.02.3-492. And now, after having finished the update, the error persists.

The object is well defined:

> dput(alltms)
structure(list(X = 1:45, Tm = c("BOS", "BOS", "BOS", "BOS", "BOS", 
"BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", 
"BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", "BOS", 
"BOS", "BOS", "BOS", "BOS", "BOS", "GSW", "GSW", "GSW", "GSW", 
"GSW", "GSW", "GSW", "GSW", "GSW", "GSW", "GSW", "GSW", "GSW", 
"GSW", "GSW", "GSW", "GSW"), Name = structure(c(2L, 20L, 7L, 
32L, 43L, 3L, 26L, 22L, 14L, 31L, 28L, 15L, 8L, 27L, 1L, 18L, 
38L, 45L, 40L, 34L, 33L, 37L, 21L, 11L, 6L, 12L, 17L, 42L, 36L, 
9L, 44L, 13L, 4L, 23L, 10L, 29L, 35L, 16L, 24L, 39L, 30L, 25L, 
41L, 5L, 19L), .Label = c("Aaron Nesmith", "Al-Farouq Aminu", 
"Al Horford", "Andre Iguodala", "Andrew Wiggins", "Brodric Thomas", 
"Bruno Fernando", "C.J. Miles", "Chris Chiozza", "Damion Lee", 
"Daniel Theis", "Derrick White", "Draymond Green", "Enes Freedom", 
"Garrison Mathews", "Gary Payton II", "Grant Williams", "Jabari Parker", 
"James Wiseman", "Jaylen Brown", "Jayson Tatum", "Joe Johnson", 
"Jonathan Kuminga", "Jordan Poole", "Juan Toscano-Anderson", 
"Justin Jackson", "Juwan Morgan", "Kelan Martin", "Kevon Looney", 
"Klay Thompson", "Luke Kornet", "Malik Fitts", "Marcus Smart", 
"Matt Ryan", "Moses Moody", "Nemanja Bjelica", "Nik Stauskas", 
"Norvel Pelle", "Otto Porter Jr.", "Payton Pritchard", "Quinndary Weatherspoon", 
"Robert Williams", "Sam Hauser", "Stephen Curry", "Theo Pinson"
), class = "factor"), PlayerID = c("aminual01", "brownja02", 
"fernabr01", "fittsma01", "hausesa01", "horfoal01", "jacksju01", 
"johnsjo02", "kanteen01", "kornelu01", "martike03", "mathega01", 
"milescj01", "morgaju01", "nesmiaa01", "parkeja01", "pelleno01", 
"pinsoth01", "pritcpa01", "ryanma01", "smartma01", "stausni01", 
"tatumja01", "theisda01", "thomabr01", "whitede01", "willigr01", 
"williro04", "bjeline01", "chiozch01", "curryst01", "greendr01", 
"iguodan01", "kuminjo01", "leeda03", "looneke01", "moodymo01", 
"paytoga02", "poolejo01", "porteot01", "thompkl01", "toscaju01", 
"weathqu01", "wiggian01", "wisemja01"), IsActive = c(FALSE, TRUE, 
FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 
FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, 
TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, 
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, 
TRUE, FALSE), GS = c(FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, 
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, 
FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, 
FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 
TRUE, FALSE)), row.names = c(NA, -45L), class = "data.frame")

What is going on? What changed? And why will R no longer write CSVs?

Phil
  • 7,287
  • 3
  • 36
  • 66
DataProphets
  • 156
  • 3
  • 17
  • 3
    "Permission denied" is really an issue with the OS or such, it should have nothing to do with the data itself. Verify `getwd()` returns what you expect, and that your local user (regardless of R) has write permission in that directory (I suggest you verify in some other app to verify if it's an R-specific problem). – r2evans Jun 05 '22 at 01:09
  • `getwd()` does return what I expect. Upon simply opening RStudio, I also get the following error: `WARNING: Failed to restore workspace from '~/R/.RData' Reason: cannot allocate vector of size 708 Kb` I recently also had to update my Windows, could that be at fault? – DataProphets Jun 05 '22 at 02:09
  • https://stackoverflow.com/questions/17779004/cannot-export-data-to-a-file-in-r-write-csv Apparently Microsoft thinks read-only is an upgrade. – DataProphets Jun 05 '22 at 02:43
  • You should also delete that oversize `.Rdata` file and instead start using scripts that initialize a project. – IRTFM Jun 05 '22 at 03:23
  • I am getting the same `cannot allocate vector of size`... error when the script initializes the project. This was not the case yesterday, before the updates. – DataProphets Jun 05 '22 at 04:39
  • 1
    Can you write different (new) files in the same directory? Have you confirmed that nothing else has the file opened? I have often made the mistake of opening a CSV file in Excel (or Calc or whatever) to verify its structure/contents and forgotten to close it, after which subsequent calls to `write.csv(..)` fail with the same error. Unfortunately, once I think I had to reboot the OS to finally convince Windows to drop the file-handle, perhaps rebooting may help you (a horrible "resolution"). – r2evans Jun 05 '22 at 12:13
  • I did have to reboot and the problem has resolved. I am still getting the vector size error when the script compiles the database, but I suspect that's another issue having to with memory. Thanks for your help! – DataProphets Jun 05 '22 at 13:13

0 Answers0