我有多个网站,我多次采样(不同的日期),我运行时间序列实验,以获得该系列中每个时间点的值(对于每个网站有4个时间点)。我想绘制每个时间序列($ Time..hours。)(x轴)与其各自日期的每个站点的值(Sample.N2O.gas ... ppm。)(y轴)的关系图。多个图表一次查看所有这些数据。
我是R的新手,所以我不确定附加我的数据图像是否有用。 Data
到目前为止我发现的是:
plots <- data %>% group_by(Site, Date, Treatment, Rep) %>% do(plots=ggplot(data=.)) +
aes(x=Time..hours., y=Sample.N2O.gas...ppm.) + geom_point()
但是当我运行情节时,我只得到一个输出表'#A Tibble 149x5'。
这是我从dput输出中复制的内容:
data = structure(list(Site = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("QA1", "QA1 ",
"QA2", "W1", "W2", "W3", "W4"), class = "factor"), Date = structure(c(1462860000,
1462860000, 1462860000, 1462860000, 1462860000, 1462860000, 1462860000,
1462860000, 1462860000, 1462860000, 1462860000, 1462860000, 1462860000,
1462860000, 1462860000, 1462860000, 1462860000, 1462860000, 1462860000,
1462860000, 1462860000, 1462860000, 1462860000, 1462860000, 1462860000,
1462860000, 1462860000, 1462860000, 1462860000, 1462860000, 1462860000,
1462860000), class = c("POSIXct", "POSIXt"), tzone = ""), Treatment = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Control",
"DEA", "Denit"), class = "factor"), Rep = c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), Time..hours. = c(0.333333333,
1.166666667, 2, 2.833333333, 0.333333333, 1.166666667, 2, 2.833333333,
0.333333333, 1.166666667, 2, 2.833333333, 0.333333333, 1.166666667,
2, 2.833333333, 0.333333333, 1.166666667, 2, 2.833333333, 0.333333333,
1.166666667, 2, 2.833333333, 0.333333333, 1.166666667, 2, 2.833333333,
0.333333333, 1.166666667, 2, 2.833333333), Sample.N2O.gas...ppm. = c(0.02536993437111,
0.02539270198174, 0.0258252865837, 0.02236460976796, 0.01136785383374,
0.00886341666446, 0.01291605135657, 0.01583030551719, 0.05517273668559,
0.15960776664476, 0.12206397671612, 0.10999714308229, 0.08618222236346,
0.062344534034, 0.0527366023482, 0.05845127261629, 0.03570642959706,
0.05093796110844, 0.04784156606278, 0.05763163863362, 24.1815481999959,
43.9535598867979, 76.0087551511654, 97.5847143861169, 26.1044322512172,
42.2811119155545, 82.8088875655402, 109.127381921808, 24.9257144556248,
46.2630281688243, 84.5042194191463, 102.597585589484)), .Names = c("Site",
"Date", "Treatment", "Rep", "Time..hours.", "Sample.N2O.gas...ppm."
), row.names = c(NA, 32L), class = "data.frame")
答案 0 :(得分:1)
那是因为你已经创建了一个图表列表(技术上是一组图表)。要查看列表中的第一个图表,您需要执行plots[[1]]
附录:实际上,您当前表单中的代码不能正常工作。你的意思是做什么?
plots <- data %>% group_by(Site, Date, Treatment, Rep) %>% do(plots=ggplot(data=.) +
aes(x=Time..hours., y=Sample.N2O.gas...ppm.) + geom_point())
如果是这样,那么(奇怪的是),这些情节被埋在一个叫做情节的清单中。您可以使用plots$plots[[1]]
访问第一个,只需转到plots$plots
即可显示所有这些内容。