Reputation: 31
I seem to be unable to save any files in R after a longer sequence of errors.
First: I was not able to generate plots or any graphs and given an error. I tried restarting R (multiple times) and that did not help. I then cleared some space on my computer and this solved that issue.
Next: I was given errors regarding autosaving and told that I may need to restart R. I then restarted R again and then when trying to manually save my file I was given the error "Error Saving File Error Saving ~/Desktop/Stats/FileName.R: Invalid Argument".
I had been working on a project for a few hours before the error occurred. I am running OS Catalina 10.15.7 and RStudio: 2022.07.1+554
Full version description:
RStudio 2022.07.1+554 "Spotted Wakerobin" Release (7872775ebddc40635780ca1ed238934c3345c5de, 2022-07-22) for macOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.10 Chrome/69.0.3497.128 Safari/537.36
For now I will keep copy and pasting my code into a google docs file to save. What can be done to address this?
Thank you.
I cleared storage on my computer assuming that my computer didn't have the storage to create plots (this was accurate as I only had a few MB left. Now I have 3GB). I restarted RStudio multiple times per the prompt instructions and this did not do anything. Now the problem has shifted from not being able to produce graphs to being unable to autosave and save manually either. It seems that code execution is fine - so far.
Code below:
setwd("/Users/name/Desktop/Stats")
data <-read.table("RealEstateSales.txt", header=T)
attach(data)
data
Age <- 2002 - X7
Age
Df2 <- data.frame(Y,X1,X6,X9,Age) #Create D.f. omitting
# irrelevant variables
Df2
#X9 is coded 1-11 for architecture style
#X6 is coded 1/0. 1 for having a pool, 0 for not having a
#pool
#Y is sales price, X1 is square footage
plot(X1, Y)
table(X6)
table(X9)
plot(Age,Y)
library(caTools)
set.seed(1234567890)
inx <- sample.split(seq_len(nrow(Df2)), 400)
traind <- Df2[inx, ]
nrow(traind)
testd <- Df2[!inx, ]
nrow(testd)
table(X6)
table(X9)
hist(X9)
plot(X1, Y)
f1 <- factor(X6)
plot(X1, Y, pch = 20, col = c("red", "blue")[f1])
f2 <- factor(X9)
plot(X1, Y, pch = 20, col = c("red", "blue", "black",
"green", "purple", "orange", "cyan", "maroon",
"cyan1","brown1","chocolate4")[f2])
interaction.plot(X1, Age, Y, lwd = 3)
plot(Age, Y)
plot(Age, Y, pch = 20, col = c("red", "blue")[f1])
plot(Age, Y, pch = 20, col = c("red", "blue", "black",
"green", "purple","orange", "cyan", "maroon",
"cyan1","brown1","chocolate4")[f2])
boxplot(Y ~ X6)
tapply(Y, X6, mean)
t.test(Y ~ X6)
boxplot(Y ~ X9)
tapply(Y, X9, mean)
summary(aov(Y ~ X9))
tapply(Df2$Y, list(Df2$X6,Df2$X9), mean)
plot(X9,Y,pch = 20, col = c("red", "blue")[f1])
Dfsub1 <- subset(Df2, select= c('Y', 'X1', 'Age'))
cor(Dfsub1)
a <- table(X9,X6)
fisher.test(a)
chisq.test(a,simulate.p.value = TRUE)
Upvotes: 3
Views: 5735
Reputation: 135
There is an, admittedly, not very thoroughly explained answer here, but it did work for me several times when I got this error.
When it happened to me, I quit the R session (since there was no other option), but I did save my script temporarily in another file (simply copy-pasting it).
When I reopened the project and the associated script files, I did not need to use the backup script to update my work --- however, I must say I would always make a backup.
So, in brief, RStudio should be able to restore your script without loss, at least if you reopen the session immediately, but, regretfully, I cannot tell you why, and you should make a backup whenever possible.
Upvotes: 0
Reputation: 1
I had the same problem, and what worked for me was to abort the RStudio session by closing the "rsession" icon in the Dock. I suppose you could also do this via "Session" > "Quit Session...", but make sure to save your code temporarily before that. This is because some of my most recent changes were lost after that.
Upvotes: 0