Error message when using ggcorrplot() and cor_pmat() - r

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.

Related

Error when using ggstatsplot - Error in 'mutate()': Caused by error in vapply()':

Just installed ggstatsplot and tried running the Example in the Documentation to just see what inputs it requires and how to manipulate the function.
library(ggstatsplot)
ggbetweenstats(mtcars, am, mpg)
I was immediately met with the error:
Error in `mutate()`:
! Problem while computing `n_label = paste0(am, "\n(n = ", .prettyNum(n), ")")`.
Caused by error in `vapply()`:
! values must be length 1,
but FUN(X[[1]]) result is length 3
I have tried multiple examples I found online of how to use the package and all result in the same error. I also tried ggwithinstats and received the same error. I updated all of my packages and have restarted R Studio at each step.
Any help would be appreciated, please let me know if I can provide any other information.
Sorry for the troubles.
This is due to update to insight package (https://github.com/IndrajeetPatil/ggstatsplot/issues/749).
EDIT on 21 May 22:
Both statsExpressions and ggstatsplot updates are now on CRAN, so all these issues should go away.
I get the exact same error.
#for reproducibility and data
set.seed(123)
library(WRS2)
library(ggstatsplot)
ggwithinstats(
data = bugs_long,
x = condition,
y = desire
)
May it is a bug?

load data error (Read10X, Seurat - Guided Clustering Tutorial)

I am trying to follow the tutorial from Seurat website.
https://satijalab.org/seurat/v3.1/pbmc3k_tutorial.html
I got an error when loading the data.
Load the PBMC dataset
pbmc.data <- Read10X("1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz")
Error in Read10X("1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz") :
Directory provided does not exist
I have set my working directory as the image showed. Can anyone let me know what is the problem? Thank you!
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("multtest")
library(dplyr)
library(Seurat)
library(patchwork)
# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz")
I was trapped with this problem few minutes before, and I find the solution now.
Try to use these codes:
install.packages("Seurat")
library(Seurat)
install.packages(c('dplyr','patchwork'))
library(dplyr)
library(Seurat)
library(patchwork)
in order to install the environment for scRNA analysis

Error in seas(AirPassengers) : no output has been generated

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)

Error in plot.new() : internal read error in PDF_endpage

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.

Error in ls(envir = envir, all.names = private)?

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.

Resources