错误无法在数据中找到 y.position 变量 'y.position'

Shr*_*M S 1 r ggplot2

我正在尝试在 ggplot boxplot 中绘制重要值,但出现错误,无法理解为什么会出现此错误

我的数据

structure(list(data1 = c(0.05, 0.068, 0.063, 0.075, 0.047), 
      data2 = c(-0.029,-0.011,0.009,0.117,0.116), 
      data3 = c(-0.048,-0.030,-0.026,-0.049,-0.087), 
      data4 = c(-0.070,-0.072,-0.035,-0.001,-0.021)), 
      class = "data.frame", row.names = c(NA, -5L))
Run Code Online (Sandbox Code Playgroud)

我使用的代码

library(reshape)
library(ggplot2)
library(ggpubr)

regcovMat <- read.table("Test.txt", sep="\t", header=T)
molten.data <- melt(regcovMat)
stat.test <- compare_means(
  value ~ variable, data = molten.data,
  method = "t.test"
)

data=ggplot(molten.data, aes(x=variable, y=value, fill=variable)) + 
  geom_boxplot()+theme_cowplot()+theme(legend.position = "top")
data + stat_pvalue_manual(stat.test, label = "p")
Run Code Online (Sandbox Code Playgroud)

谁能建议我解决这个问题

dan*_*ooo 5

library(reshape)
library(ggplot2)
library(ggpubr)
library(cowplot)
#> 
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:ggpubr':
#> 
#>     get_legend
#> The following object is masked from 'package:reshape':
#> 
#>     stamp

regcovMat <- structure(list(data1 = c(0.05, 0.068, 0.063, 0.075, 0.047), data2 = c(-0.029, -0.011, 0.009, 0.117, 0.116), data3 = c(-0.048, -0.030, -0.026, -0.049, -0.087), data4 = c(-0.070, -0.072, -0.035, -0.001, -0.021)), class = "data.frame", row.names = c(NA, -5L))

molten.data <- melt(regcovMat)
#> Using  as id variables
stat.test <- compare_means(
  value ~ variable,
  data = molten.data,
  method = "t.test"
)

ggplot(molten.data) +
  geom_boxplot(aes(x = variable, y = value, fill = variable)) +
  stat_pvalue_manual(stat.test, label = "p", y.position = 0.15, step.increase = 0.2) +
  theme_cowplot() +
  theme(legend.position = "top")
Run Code Online (Sandbox Code Playgroud)

由reprex 包于 2021 年 9 月 13 日创建(v2.0.1)