Re: [R] how to combine grouped data and ungrouped data in a trellis xyplot

2012-01-09 Thread Deepayan Sarkar
On Sun, Jan 8, 2012 at 9:45 AM, Mike Dahman mike.dah...@gmail.com wrote:
 I'm hoping the community knowledge can help me out here. I have found great
 value in R, especially using it to generate charts, but I am still scaling
 the learning curve in a number of ways.

 I am looking plot one grouped line and one ungrouped line in a lattice plot.

 I can plot one grouped line like this (the line's color in each panel
 becomes dependent on the newpool value):



 xyp-xyplot(cpucap~date|zone,data=df,type=l,groups=newpool,auto.key=list(points=F,lines=T),
           main=paste(df$server[1], CPU Caps\n,df$date[1], to
 ,df$date[nrow(df)],sep=)
    )
    print(xyp)


 and I can plot two ungrouped lines using a panel=function with subscripts
 like this (maybe not the best way, but I found an example doing it this
 way):

    xyplot(cpu~dt|zone,data=filt_zone_df,ylim=c(0,100),
           main=paste(server, - Zone CPU (Blue)  Memory (Red)
 Util\n,filt_zone_df$ts[1],-,filt_zone_df$ts[nrow(filt_zone_df)],sep=),
           panel=function(x,y,subscripts){
               panel.lines(x,y)
               
 panel.lines(filt_zone_df$dt[subscripts],filt_zone_df$mem[subscripts],col=red)
    }, as.Table=T, subscripts=T)


 but I'm struggling with plotting one line that is grouped and one that
 isn't. When I try to pass group to the first panel.xyplot() function in the
 panel=function it either does nothing or bombs out.

 xyplot(cpu~dt|zone,data=servdf,ylim=c(0,100),groups=pool,auto.key=list(points=F,lines=T),type=l,
           main=test,
           panel=function(x,y,groups,subscripts,...){
               panel.xyplot(x,y,groups,...)                     # would
 like this to be colored based on the groups=pool

Try

              panel.xyplot(x, y, groups = groups, subscripts = subscripts, ...)

-Deepayan


  panel.lines(servdf$dt[subscripts],servdf$mem[subscripts],col=red)
    }, as.Table=T, subscripts=T)


 A little nudge in the right direction is appreciated. I'm getting tripped
 up on how to get the groups definition into the panel function and also
 into the panel.xyplot function within it. I've tried using a number of
 variations in the arguments with the panel=function definition and the call
 to panel.xyplot() within it, but no success. My assumption was that the use
 of '...' would pass it on down, but that doesn't seem to be the
 case, especially since most of the examples I can find from googling show
 folks listing group as an argument, and sometimes have something like
 groups=groups. I've tried a number of things and thought it is time to ask
 for help.

 Regards,

 -mike

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to combine grouped data and ungrouped data in a trellis xyplot

2012-01-09 Thread Mike Dahman
Thanks Deepayan. That did the trick.


xyplot(cpu~dt|zone,data=filt_zone_df,ylim=c(0,100),groups=pool,

 
auto.key=list(columns=min(4,length(unique(filt_zone_df$pool))),lines=T,points=F),
   type=l,
   main=Test Chart,
   ylab=% Utilization,
   panel=function(x,y,groups,subscripts,...){
   panel.xyplot(x,y,groups=groups,subscripts=subscripts,...)

 panel.lines(filt_zone_df$dt[subscripts],filt_zone_df$mem[subscripts],col=red)
}, as.Table=T, subscripts=T)

Regards,

-mike


On Mon, Jan 9, 2012 at 5:06 AM, Deepayan Sarkar
deepayan.sar...@gmail.comwrote:

 On Sun, Jan 8, 2012 at 9:45 AM, Mike Dahman mike.dah...@gmail.com wrote:
  I'm hoping the community knowledge can help me out here. I have found
 great
  value in R, especially using it to generate charts, but I am still
 scaling
  the learning curve in a number of ways.
 
  I am looking plot one grouped line and one ungrouped line in a lattice
 plot.
 
  I can plot one grouped line like this (the line's color in each panel
  becomes dependent on the newpool value):
 
 
 
 
 xyp-xyplot(cpucap~date|zone,data=df,type=l,groups=newpool,auto.key=list(points=F,lines=T),
main=paste(df$server[1], CPU Caps\n,df$date[1], to
  ,df$date[nrow(df)],sep=)
 )
 print(xyp)
 
 
  and I can plot two ungrouped lines using a panel=function with subscripts
  like this (maybe not the best way, but I found an example doing it this
  way):
 
 xyplot(cpu~dt|zone,data=filt_zone_df,ylim=c(0,100),
main=paste(server, - Zone CPU (Blue)  Memory (Red)
 
 Util\n,filt_zone_df$ts[1],-,filt_zone_df$ts[nrow(filt_zone_df)],sep=),
panel=function(x,y,subscripts){
panel.lines(x,y)
 
 panel.lines(filt_zone_df$dt[subscripts],filt_zone_df$mem[subscripts],col=red)
 }, as.Table=T, subscripts=T)
 
 
  but I'm struggling with plotting one line that is grouped and one that
  isn't. When I try to pass group to the first panel.xyplot() function in
 the
  panel=function it either does nothing or bombs out.
 
 
 xyplot(cpu~dt|zone,data=servdf,ylim=c(0,100),groups=pool,auto.key=list(points=F,lines=T),type=l,
main=test,
panel=function(x,y,groups,subscripts,...){
panel.xyplot(x,y,groups,...) # would
  like this to be colored based on the groups=pool

 Try

   panel.xyplot(x, y, groups = groups, subscripts = subscripts,
 ...)

 -Deepayan

 
   panel.lines(servdf$dt[subscripts],servdf$mem[subscripts],col=red)
 }, as.Table=T, subscripts=T)
 
 
  A little nudge in the right direction is appreciated. I'm getting tripped
  up on how to get the groups definition into the panel function and also
  into the panel.xyplot function within it. I've tried using a number of
  variations in the arguments with the panel=function definition and the
 call
  to panel.xyplot() within it, but no success. My assumption was that the
 use
  of '...' would pass it on down, but that doesn't seem to be the
  case, especially since most of the examples I can find from googling show
  folks listing group as an argument, and sometimes have something like
  groups=groups. I've tried a number of things and thought it is time to
 ask
  for help.
 
  Regards,
 
  -mike
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.