I am trying to plot significant values in ggplot boxplot I am getting error unable understand why this error is comming
my data
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))
code I used
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")
Can anyone suggest me to resolve the issue
CodePudding user response:
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")