带格子的堆积条形图:我的数据太大了吗?

时间:2010-07-21 20:04:42

标签: r graph lattice

我想要一个类似于lattice docs中给出的示例的图表:

#EXAMPLE GRAPH, not my data
> barchart(yield ~ variety | site, data = barley,
+          groups = year, layout = c(1,6), stack = TRUE, 
+          auto.key = list(points = FALSE, rectangles = TRUE, space = "right"),
+          ylab = "Barley Yield (bushels/acre)",
+          scales = list(x = list(rot = 45))) 

melt编辑了我的数据以获取这个“长”表单数据框:

> str(MDist)
'data.frame':   34560 obs. of  6 variables:
$ fCycle   : Factor w/ 2 levels "Dark","Light": 2 2 2 2 2 2 2 2 2 2 ...
$ groupname: Factor w/ 8 levels "rowA","rowB",..: 1 1 1 1 1 1 1 1 1 1 ...
$ location : Factor w/ 96 levels "c1","c10","c11",..: 1 1 1 1 1 1 1 1 1 1 ...
$ timepoint: num  1 2 3 4 5 6 7 8 9 10 ...
$ variable : Factor w/ 3 levels "inadist","smldist",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value    : num  0 55.7 75.3 99.2 45.9 73.8 79.3 73.5 69.8 67.6 ...

我想为每个groupname和fCycle创建一个堆叠条形图。我试过这个:

barchart(value~timepoint|groupname*fCycle, data=MDist, groups=variable,stack=T) 

它没有抛出任何错误,但它仍然在30分钟后思考。这是因为它不知道如何处理对每个柱子有贡献的36个值?如何使条形图更容易理解这些数据?

1 个答案:

答案 0 :(得分:1)

我不太了解格子,但可能是因为你的timepoint变量是数字,而不是因素?