开发者

stacked barchart with lattice: is my data too big?

I want a graph that looks similar to the example given in the 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))) 

I melted my data to obtain this "long" form dataframe:

> 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 ...

I want to create a stacked barchart for each groupname and fCycle. I tried this:

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

It doesn't throw any errors, but it's still thinking after 30 minutes. Is this because it doesn't know how to deal with the 36 values that contribute to each bar? How can I make this data easier for barchart to digest?


I don't know lattice well, but could it be because your timepoint variable is numeric, not a factor?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜