I'm trying to plot a correlation matrix of my data.
Here's my code:
data <- read.table("path/to/data", header=T, sep='\t')
cor <- cor(data)
corrplot(cor, method="color", type="upper")
And i'm getting this error:
Error in plot.new() : internal read error in PDF_endpage
I've never seen this error before and there isn't much on google. Any help?
I had this error just after cleaning up some temp files and solved it by updating my packages:
update.packages()
To me it happened after I removed some temp R files. Not sure why does pdf() files live in temp folders, though.
I had this issue and was finally able to resolve it by using graphics.off(). I had to run the command twice but then plotting worked again.
Related
I have trouble with the following code:
library(ggplot2)
library(ggcorrplot)
data(USArrests)
correlation_matrix <- round(cor(USArrests),1)
corrp.mat <- cor_pmat(USArrests)
ggcorrplot(correlation_matrix, hc.order =TRUE, type ="lower",
p.mat = corrp.mat)
When I run the code, execution stops at ggcorrplot(...) and I get this error:
"Error in Math.data.frame(x = list(Assault = c(0.0695, 1.36e-07,
2.6e-12, : non-numeric-alike variable(s) in data frame: rowname"
I tried to run the code in an online R runner and it worked, but in RStudio it doesn´t.
I have no clue whats going on, has somebody an idea?
Thank you #Quinten for your suggestion. Unloading the unnecessary packages helped. The package rstatix seemed to interfere with the cor_pmat() command.
I am getting this error when I run:
library(seasonal)
m <- seas(AirPassengers)
I have installed the package.
I have uninstalled R, Rstudio, reinstalled and tried again, same error.
Could someone help?
Thanks
I can't reproduce exactly the same error now but I remember following error after I installed the seasonal package:
Error in seas(AirPassengers) : could not find function "seas"
After cleaning up my workspace the error was gone.
Following code is working for me and resulting in the plot below:
library(seasonal)
head(AirPassengers)
m <- seas(AirPassengers, regression.aictest = c("td", "easter"))
plot(m)
I'm trying to do a confirmatory factor analysis on R for the first time.
I've researched this error and nothing helped so far (changing the working directory and so on).
Creating my model worked. But when I try to run the "fit" I get the error with
"Error in file(file, "r"): cannot open connection".
My first data frame is saved in "downloads" folder of my Mac. But I'm working with data Frame "data4" which is saved in a different folder. data4 is in the same folder as the whole project. It seems like the error has something to do with the path.
I also tried:
fit <- cfa(model, data = "~/Documents/BACHELORARBEIT/Daten/data4.RData, missing = "ML")
instead of:
fit <- cfa(model, data = data4, missing = "ML")
but I still get the same error message.
thank you in advance!!!
It seems you have set up the wrong working direction.
The easiest Solution would be to put all your files and the script in the same folder and just use on the toolbar:
Session -> Set working direction ->to source file.
Or check this post and see it can
help.
I am attempting to use the plot() function in the biomod2 package, following a vignette here (http://finzi.psych.upenn.edu/usr/share/doc/library/biomod2/doc/Simple_species_modelling.pdf). Below is the error I am getting:
getwd()
# [1] "/home/gjanzen/Documents/Hufford/Drought/Data/Layers"
plot(myBiomodData)
Error in getExportedValue(pkg, name) : cannot open file
'~/R/x86_64-pc-linux-gnu-library/3.3/viridisLite/data/Rdata.rdb': No
such file or directory In addition: Warning message: In
getExportedValue(pkg, name) : restarting interrupted promise
evaluation
I have confirmed that the Rdata.rdb exists, in the following directory:
f <- file.choose()
f
# [1] "/home/gjanzen/R/x86_64-pc-linux-gnu-library/3.3/viridisLite/data/Rdata.rdb"
So, to me, it looks like the plot() function is looking in the wrong place. How can I change where this function looks for Rdata.rdb? Can I alter the path somehow? Or would changing my working directory fix this?
PS - This is my first post on Stack Overflow, so please forgive any mistakes in etiquette, and/or feel free to point them out to me so that I do not repeat them.
I think that the first thing to try is to reinstall the package viridisLite that seems to be the one that is causing troubles.
install.packages('viridisLite', dep = TRUE)
If this not solves the issue you should try to open a new plotting device threw x11() to check if the issue is not coming from the R (resp. RStudio) plotting device itself.
The below error keeps coming up inconsistently when I try to read excel files into R using the 'XLConnect' package.
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
I have actually run into this error while even using other packages that read excel files like package 'xlsx' and 'xlsReadWrite'. Many times restarting the R session solves this problem, which leads me to think that something else I am doing in my R session is changing the environment and not allowing me to load excel files anymore. Below is the latest example of code that is causing this error. In this case I know that the following coding sequence is causing the error to appear - but why is that happening? And how can I get past this error if I need the chron package.
library("XLConnect")
wb2 <- loadWorkbook("excel_file", create = FALSE)
library(chron)
wb2 <- loadWorkbook("excel_file", create = FALSE)
Anyone else run into this issue before? Any help on this issue is greatly appreciated!
Before reopening the workbook try removing the reference to previously opened one, so:
rm(wb2)
wb2 <- loadWorkbook("excel_file", create = FALSE)
Also, make sure that "excel_file" is not open by excel or any other program while you run the R test.
I've seen the same error come up when using XLConnect and the above seemed to help.
Had this problem a couple of times and the call stack looks like this message is generated when a "OutOfMemory" Exception is thrown.
To solve this problem I used:
options( java.parameters = "-Xmx4g" )
to increase the heap size rJava is able to use.
Debugging with options(error=utils::recover) helped a lot, because the R error messages are not very specific.