-1

I have split a data set into two different data frames.

I want to use both data frames making a 2 panel plot using lattice. I need to know if this is possible?

Or do I have to keep 1 data frame and create a factor variable?

user3648688
  • 69
  • 1
  • 5
  • 1
    It's helpful if you make a reproducible example with a more specific definition of your problem. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – MrFlick May 17 '14 at 23:40

1 Answers1

0

Generally speaking, Lattice likes everything to be in one data.frame. Lattice includes the make.groups(...) function to make this process easier. For example:

d1<-data.frame(x=runif(20), y=rnorm(20))
d2<-data.frame(x=runif(20,.5,1.5),y= rnorm(20, 0, 2))

xyplot(y~x, make.groups(d1=d1, d2=d2), groups=which, auto.key=T)
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • im trying to create a 2 panel plot, one panel per data frame – user3648688 May 17 '14 at 23:42
  • Then just change it to `xyplot(y~x|which, make.groups(d1=d1, d2=d2))` – MrFlick May 17 '14 at 23:46
  • maybe you could give me some insight on creating a factor variable. I have a vector of days of the week. I need to make a variable that labels weekdays M-F and weekends – user3648688 May 17 '14 at 23:56
  • @user3648688 That seems like a completely different question so it's not a good idea to bring that up in comments. If you like, you can start a new question. But it's likely you can learn a lot about R factors just by doing some more searching. – MrFlick May 17 '14 at 23:59