我想进行一次重要的三向互动。这三个因素是收集,品种和灌溉,响应变量是Gluc。我目前的想法(可以接受其他建议)是制作一个条形图,在Y轴上显示Gluc响应,在X轴上显示灌溉。在X轴上的每次灌溉处理中,每种品种处理都会有一个条。最后,我将为每个集合制作其中一个图表。
这似乎是显示此数据的明智方法吗?如果是这样,我该如何编写代码?我认为使用ggplot
及其facetwrap
函数是有意义的,或者也许对单个图形使用ggplot
并将它们与基于R的gridExtra
组合起来(如果可能的话)。 )
这是我当前的数据集:
dput(head(dataAvgGlucCVI))
structure(list(Collection = structure(c(1L, 1L, 1L, 1L, 1L, 1L
), .Label = c("1", "2", "3"), class = "factor"), Variety = structure(c(1L,
1L, 1L, 1L, 1L, 2L), .Label = c("Hodag", "Lamoka", "Snowden"), class = "factor"),
Irrigation = structure(c(1L, 2L, 3L, 4L, 5L, 1L), .Label = c("Rate1",
"Rate2", "Rate3", "Rate4", "Rate5"), class = "factor"), meanGlucCVI = c(0.03475,
0.03475, 0.0455, 0.047, 0.061, 0.04275)), row.names = c(NA,
-6L), groups = structure(list(Collection = structure(c(1L, 1L
), .Label = c("1", "2", "3"), class = "factor"), Variety = structure(1:2, .Label = c("Hodag",
"Lamoka", "Snowden"), class = "factor"), .rows = list(1:5, 6L)), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
如果有帮助,这是我用于双向绘图的一个示例
dataAvgSucCI$Collection <- as.factor(dataAvgSucCI$Collection)
str(dataAvgSucCI$Collection)
sucPlotFacetCI <-ggplot(dataAvgSucCI, aes(x=Collection, y=meanSuc, group=Irrigation)) + geom_bar(stat="identity") +
ylab("Sucrose (mg/gFW)") + facet_wrap(.~Irrigation)
sucPlotFacetCI
感谢您的帮助或建议!