Tag Archives: R Language Error

[Solved] R Language Error: Error in file(out, “wt“) : cannot open the connection

I recently processed some large files of biological data. After writing the code, I found that the code was a bit wrong and needed to be modified, so I terminated the operation. However, since this process should take a long time to run and suddenly terminated, R will clear the archive. the error will be report:

Error in file(out, “wt“) : cannot open the connection

Solution: use the following command to generate temporary Archive

dir.create(tempdir())

I tried to restart it, but it seems to restart will not work.

[Solved] R Language Error: Discrete value supplied to continuous scale

Error: discrete value supplied to continuous scale

#Simulation data

set.seed(123)
my_df1 <- data.frame(a=rnorm(100), b=runif(100), c=rep(1:10, 10))
my_df2 <- data.frame(a=rnorm(100), b=runif(100), c=factor(rep(LETTERS[1:5], 20)))

#Error: Discrete value supplied to continuous scale

ggplot() +
  geom_point(data=my_df1, aes(x=a, y=b, color=c)) +
  geom_polygon(data=my_df2, aes(x=a, y=b, color=c), alpha=0.5)

#Solution:

Use the fill parameter;

ggplot() +
  geom_point(data=my_df1, aes(x=a, y=b, color=c)) +
  geom_polygon(data=my_df2, aes(x=a, y=b, fill=c), alpha=0.5)

[Solved] R Language Error: Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error)

R Language Error: Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error)

 

Solution:

Solution 1: Ctrl + Shift + F10 to restart your session
solution 2: run the following code directly to regenerate the temporary file without restarting (recommended)

dir.create(tempdir())