[R] is that possible to graph 4 dimention plot

Ryan rhafen at purdue.edu
Wed Oct 7 21:34:22 CEST 2009


> 
> Suppose there are 4 variables
> d is a function of a , b and c
> I want to know how a, b and c change will make d change
> It will be straightforward to see it if we can graph the d surface
> 
> if d is only a function of a and b, I can use 'persp' to see the surface of
> d. I can easily see at what values of a and b, d will get the maxium or
> minium or multiple modes, etc
> 
> But for 4 dimention graph, is there a way to show the surface of d
> Will use color help
> 
> Thanks a lot

Not sure what your data looks like, but you might also 
consider looking at a 2 dimensional version.  See ?coplot
for example:

coplot(lat ~ long | depth * mag, data = quakes)

Or you can make 2 or 3-dimensional plots using the lattice 
package conditioning on some of the variables - e.g. d ~ a | b * c,
etc.  

If a, b, and c are "continuous", you can use equal.count.  Here is
an uninteresting example, considering a, b, and c as points along
a grid:

a <- b <- c <- seq(1:10)
dat <- data.frame(expand.grid(a, b, c))
names(dat) <- letters[1:3]

dat$d <- with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2)

library(lattice)
# 2-d:
xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type="l")
# etc.

# 3-d:
contourplot(d ~ a * b | equal.count(c), data=dat)
wireframe(d ~ a * b | equal.count(c), data=dat)




More information about the R-help mailing list