如何有效地管道在ggpubr功能?

问题描述

我正在使用 Text( 'Wow',style: TextStyle(backgroundColor: Colors.red),),为论文制作图形,同时也学习R。我试图将不同的功能组合为一个功能,以便更快地运行该过程。我的代码看起来像这样。

ggpubr

对于ggplot2,您可以使用p <- ggviolin(data,x = "gender",y = "scores") + stat_compare_means(method = "t.test",label = "p.format",label.x = 1.5) p <- add_summary(p,fun = "mean_ci") %>% ggpar(xlab = FALSE,ylab = "rating") # show graph p 运算符来组合不同的功能在这里+似乎是ggpubr+的组合。有没有办法使它成为一个函数,所以我只需要运行一行并避免使用第二行%>%

解决方法

+括在括号中。

(
  ggviolin(data,x = "gender",y = "scores") +
  stat_compare_means(method = "t.test",label = "p.format",label.x = 1.5)
) %>%
  add_summary(fun = "mean_ci") %>% 
  ggpar(xlab = FALSE,ylab = "Rating")