Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重要注释合并,而不是在R中单独显示_R_Ggplot2_Geom Bar_Significance - Fatal编程技术网

重要注释合并,而不是在R中单独显示

重要注释合并,而不是在R中单独显示,r,ggplot2,geom-bar,significance,R,Ggplot2,Geom Bar,Significance,当重要注释相同且相互重叠打印时,它们将合并,而不是单独打印。我怎样才能解决这个问题 data <- tibble::tibble( value = c(1.63, 1.39,1.22,1.14,1.98,-1.34,-1.34,-1.29,-1.11,-1.23), variable = c("A", "B","C","D", "E", "F", "G", "H", "I" , "J"), type = c(rep("p",5),rep("n",5))) ggplot(dat

当重要注释相同且相互重叠打印时,它们将合并,而不是单独打印。我怎样才能解决这个问题

data <- tibble::tibble(
  value = c(1.63, 1.39,1.22,1.14,1.98,-1.34,-1.34,-1.29,-1.11,-1.23),
  variable = c("A", "B","C","D", "E", "F", "G", "H", "I" , "J"),
  type = c(rep("p",5),rep("n",5)))

ggplot(data, aes(x=variable, y=value) )+
  geom_bar(stat="identity", width = 0.8)+
  theme_classic() + scale_fill_grey()+
   geom_signif(stat="identity",
              data=data.frame(x=c(0.875, 1.875, 2.875, 3.875, 4.875, 5.875, 6.875, 7.875, 8.875, 9.875), xend=c(1.125, 2.125, 3.125, 4.125, 5.125, 6.125,7.125,8.125,9.125, 10.125),
                               y=c(0.1, 0.1, 0.1, 0.1, 0.1, -0.1, -0.1,-0.1,-0.1,-0.1), annotation=c("NS", "*", "***", "***","***",  "**", "*", "*", ".", "***")),
              aes(x=x,xend=xend, y=y, yend=y, annotation=annotation))

data如果您更改x值以匹配因子级别,则似乎效果良好:

ggplot(data, aes(x = variable, y = value)) +
  geom_bar(stat = "identity", width = 0.8) +
  theme_classic() + 
  scale_fill_grey() +
   geom_signif(stat = "identity",
              data = data.frame(x = LETTERS[1:10], 
                                xend = 1:10 + 0.125,
                                y = rep(0.1, -0.1, each = 5), 
                                annotation = c("NS", "*", "***", "***","***",  "**", "*", "*", ".", "***")),
              aes(x = x, xend = xend, y = y, yend = y, annotation = annotation))

              aes(x=x,xend=xend, y=y, yend=y, annotation=annotation))

如果您更改x值以匹配因子级别,似乎效果良好:

ggplot(data, aes(x = variable, y = value)) +
  geom_bar(stat = "identity", width = 0.8) +
  theme_classic() + 
  scale_fill_grey() +
   geom_signif(stat = "identity",
              data = data.frame(x = LETTERS[1:10], 
                                xend = 1:10 + 0.125,
                                y = rep(0.1, -0.1, each = 5), 
                                annotation = c("NS", "*", "***", "***","***",  "**", "*", "*", ".", "***")),
              aes(x = x, xend = xend, y = y, yend = y, annotation = annotation))

              aes(x=x,xend=xend, y=y, yend=y, annotation=annotation))

我不得不将y=rep(0.1,-0.1,每个=5)
替换为y=c(rep(0.1,5),rep(-0.1,5))然后工作,谢谢!是否有办法在
geom_signif
中引用x,而不是
data=data.frame(x=LETTERS[1:10]
?这是一个可重复的示例,没有关于我的数据的所有变量的名称,我尝试过
x=data$variable
,但没有work@Ecg您可以尝试
x=levels(data$variable)
x=unique(data$variable)
我一直有这个错误:
as.data.frame.default(x[[I]],optional=TRUE,stringsAsFactors=stringsAsFactors)中的错误:无法强制类的“uneval”'对于一个data.frame
来说,看不到数据是很困难的,但通常这个错误是因为忘记在新的数据框之前放置
data=
。我必须替换
y=rep(0.1,-0.1,each=5)
y=c(rep(0.1,5),rep(-0.1,5))然后成功了,谢谢!有没有办法在
geom_signif
中引用x,而不是
data=data.frame(x=LETTERS[1:10]
?这是一个可重复的例子,我的数据中没有所有变量的名称,我尝试过
x=data$variable
,但没有work@Ecg您可以尝试
x=levels(data$variable)
x=unique(data$variable)
我一直有这样的错误:
as.data.frame.default(x[[I]],optional=TRUE,stringsAsFactors=stringsAsFactors):无法强制类的“uneval”'对于一个data.frame
来说,看不到数据是很困难的,但是这种错误通常是由于忘记在新的数据帧之前放置
data=