相当于Lattice中的facet_wrap [英] What is the equivalent of facet_wrap in Lattice

查看:74
本文介绍了相当于Lattice中的facet_wrap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我们有一些像这样的数据:

Say we have some data like this:

dta <- data.frame(
   group = rep(letters[1:8], each=1000), 
   x = runif(8000), y=runif(8000)
)

我想生成一个每组包含y〜x的格子图.但是,第一行有a-d组,第二行有e-h组.即,我想做的等同于

I would like to produce a Lattice plot containing y ~ x for each group. But, with groups a-d on the first row, and e-h on the second row. i.e., I would like to do the equivalent of

 qplot(x=x, y=y, data=dta) + facet_wrap(~ group, nrow=2)

但是在莱迪思.做这个的最好方式是什么?

But in Lattice. What is the best way to do this?

推荐答案

library(lattice)
xyplot(y ~ x | group, dta, layout=c(4,2), as.table = TRUE)

如@BenBarnes所建议,as.table = TRUE保持构面的顺序.

As suggested by @BenBarnes, as.table = TRUE keeps the order of the facets.

这篇关于相当于Lattice中的facet_wrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆