R friends,

I'm running R 2.7.2 on Windows XP SP2.

I have some data that's amenable to smoothing, and some that's not. I'm
trying to plot smoothed lines for the former along with just points for the
latter in a single panel. The problem comes when trying to break out the
points by group. My sample code follows.

 data1 <-
data.frame(Names=c(rep("Jon",9),rep("Karl",9)),Measurements=c(2,4,16,25,36,49,64,81,100,1,2,5,12,17,21,45,54,67),PlotAt=c(1:9,1:9))

 data2 <-
data.frame(Names=c(rep("Jonah",9),rep("Beth",9)),Measurements=c(1:5,1,1,1,1,rep(20,9)),PlotAt=c(1:9,1:9))

Assume data1 looks good when smoothed and that data2 does not.

Plot the smoothed lines:
xyplot(
  Measurements ~ PlotAt,
  data = data1,
  groups=Names,
  type="smooth",
  span=0.75,
  degree=1,
  panel = function(...) {
    panel.superpose(...);
    },
  )

Try to alter the panel function to include groups for data2's points:

xyplot(
  Measurements ~ PlotAt,
  data = data1,
  groups=Names,
  type="smooth",
  span=0.75,
  degree=1,
  panel = function(...) {
    panel.superpose(...);
    panel.xyplot(data2$PlotAt,data2$Measurements,groups=data2$Names)
    },
  )

and I get a "subscripts" missing error. If I omit the "groups" argument all
the points plot with the same plotting character. I suspect if I were
smarter I'd be able to easily fix this, so I'm hoping someone here can help.


Thanks,
Alex

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

Reply via email to