我正在按照“R in action”P389示例来安排以下点阵图中的hist面板:
library(lattice)
graph1 <- histogram(~ height | voice.part, data = singer,
main = "Heights of Choral Singers by Voice Part")
graph2 <- densityplot(~ height, data = singer, group = voice.part,
plot.points = FALSE, auto.key = list(columns = 4))
plot(graph1, position=c(0, .3, 1, 1))
plot(graph2, position=c(0, 0, 1, .3), newpage = FALSE)
根据本书的说明,我使用index.cond
来更改图表的顺序,例如
plot(graph1, position = c(0, .3, 1, 1),
index.cond = list(c(2, 4, 6, 8, 1, 3, 5, 7)))
但图表中的顺序不会改变。任何人都可以帮助我吗?
我还注意到index.cond
不在?plot
答案 0 :(得分:0)
&#34; index.cond&#34;,因为?xyplot
中描述的其他参数要么传递给创建&#34; trellis&#34;的函数。对象或update
方法。所以,在这种情况下,你可以
创建&#34; graph1&#34;通过&#34; index.cond&#34;到histogram
:
histogram(~ height | voice.part, data = singer,
main = "Heights of Choral Singers by Voice Part",
index.cond = list(c(2, 4, 6, 8, 1, 3, 5, 7)))
,使用update
:
update(graph1, index.cond = list(c(2, 4, 6, 8, 1, 3, 5, 7)))
或使用"["
:
graph1[c(2, 4, 6, 8, 1, 3, 5, 7)]