Re: [R] Adding points to a wireframe with conditioning variable

2007-07-05 Thread Mark Lyman
Deepayan Sarkar  gmail.com> writes:

> 
> On 7/5/07, Mark Lyman  gmail.com> wrote:
> > I would like to add points to a wireframe but with a conditioning 
variable. I
> > found a solution for this without a conditioning variable here,
> > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/65321.html. Does anyone 
know
> > how to plot a wireframe conditioned on a variable and add the points
> > conditioned on the same variable, similar to the solution at the link 
above?
> 
> Depends on what form you have your points in. Inside a panel function,
> packet.number() will give you the packet number in sequential order
> (column major order if you think of the conditioning variables as
> defining a multiway cross-tabulation), and which.packet() will give
> you a vector with the current level of each conditioning variable. You
> can use these to extract the appropriate subset of points.
> 
> -Deepayan

Thank you Deepayan. I modified the panel function you wrote in the post 
referenced above according to your suggestion. Here is the panel function, I 
came up with


panel.3dwire.points <- function(x, y, z, xlim, ylim, zlim, xlim.scaled,
ylim.scaled, zlim.scaled, pts, ...)
{
panel.3dwire(x=x, y=y, z=z, xlim=xlim, ylim=ylim, zlim=zlim,
xlim.scaled=xlim.scaled, ylim.scaled=ylim.scaled,
zlim.scaled=zlim.scaled, ...)
pts.sub <- subset(pts, g==levels(g)[which.packet()])
xx <- xlim.scaled[1] + diff(xlim.scaled)*(pts.sub$x - xlim[1])/diff
(xlim)
yy <- ylim.scaled[1] + diff(ylim.scaled)*(pts.sub$y - ylim[1])/diff
(ylim)
zz <- zlim.scaled[1] + diff(zlim.scaled)*(pts.sub$z - zlim[1])/diff
(zlim)
panel.3dscatter(x=xx, y=yy, z=zz, xlim=xlim, ylim=ylim, zlim=zlim,
xlim.scaled=xlim.scaled, ylim.scaled=ylim.scaled,
zlim.scaled=zlim.scaled, ...)
}

where pts is a dataframe with the three dimensional points (x,y,z) and the 
conditioning variable g.

Mark

__
R-help@stat.math.ethz.ch 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] Adding points to a wireframe with conditioning variable

2007-07-05 Thread Deepayan Sarkar
On 7/5/07, Mark Lyman <[EMAIL PROTECTED]> wrote:
> I would like to add points to a wireframe but with a conditioning variable. I
> found a solution for this without a conditioning variable here,
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/65321.html. Does anyone know
> how to plot a wireframe conditioned on a variable and add the points
> conditioned on the same variable, similar to the solution at the link above?

Depends on what form you have your points in. Inside a panel function,
packet.number() will give you the packet number in sequential order
(column major order if you think of the conditioning variables as
defining a multiway cross-tabulation), and which.packet() will give
you a vector with the current level of each conditioning variable. You
can use these to extract the appropriate subset of points.

-Deepayan

__
R-help@stat.math.ethz.ch 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] Adding points to a wireframe with conditioning variable

2007-07-05 Thread Mark Lyman
I would like to add points to a wireframe but with a conditioning variable. I 
found a solution for this without a conditioning variable here, 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/65321.html. Does anyone know 
how to plot a wireframe conditioned on a variable and add the points 
conditioned on the same variable, similar to the solution at the link above?

__
R-help@stat.math.ethz.ch 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.