使用interaction.ABC.plot(dea package)在3因子interacton plot中打印标题和误差线

时间:2016-02-29 22:36:10

标签: r plot ggplot2

我使用来自dea包的interaction.ABC.plot来显示来自EEG(脑电图)数据的相互作用,我将其用于glm。它工作得很好,但标题和y轴标题没有显示在绘图上(使用标题的默认值),线宽不会改变设置lwd参数,此外,我想添加错误栏到情节,但目前没有线索,怎么做。据我所知,这可以通过使用ggplotFuncs参数来完成,但我还没有成功。

我使用R版本3.2.0,Windows 8.1,Rstudio 0.99.489,软件包 - dae(版本2.7-6),ggplot2。

示例数据:

mV = c(runif(16,20,40))
site = rep(c("Fz", "Pz","Fz", "Pz","Fz", "Pz","Fz", "Pz"),2)
gender = rep(c("m","m","f","f","m","m","f","f"),2)
group = rep(c("A","A","A","A","B","B","B","B"),2)
al<-data.frame(mV,site,gender,group)

以下是我对interaction.ABC.plot的使用代码 - 它非常简单:

library(dae)
library(ggplot2)
interaction.ABC.plot(mV,site,gender,group,data=al, fun="mean", title="Interaction between main factors in alpha-band", xlab("Groups"), ylab("µV"), lwd=10)

1 个答案:

答案 0 :(得分:0)

虽然我没有找到完全针对 interaction.ABC.plot 的解决方案,但我已经通过使用标准ggplot2选项和Rmisc库(创建数据汇总表)创建了必要的绘图。 这是代码:

library(Rmisc)
alsum<-summarySE(al,measurevar = "mV", groupvars = c("site","gender","group"))
# setting position dodge to avoid error bars overlapping
pd <- position_dodge(0.1)
# creating plot; several plots in one area created 
# by using ggplot2 facet_grid() parameter
ggplot(alsum, aes(x=site, y=mV, colour=group)) +
geom_errorbar(aes(ymin=mV-se, ymax=mV+se, group=group),
width=.5, size=1,
position=pd) +
geom_line(aes(group=group), size=1) +
geom_point() +
facet_grid(. ~ gender) 

结果情节: Three-factor interaction plot