[R] Cbind() on the right-side of a formula in xYplot()

Dylan Beaudette debeaudette at ucdavis.edu
Mon Oct 26 18:55:38 CET 2009


Hi,

Using the latest rms package I am able to make nice plots of model predictions 
+/- desired confidence intervals like this:

# need this
library(rms)

# setup data
d <- data.frame(x=rnorm(100), y=rnorm(100))
dd <- datadist(d)
options(datadist='dd')

# fit model
l <- ols(y ~ rcs(x), data=d)

# predict along original limits of data
l.pred <- Predict(l)

# plot of fit and conf. int.
xYplot(Cbind(yhat, lower, upper) ~ x, data=l.pred, method='filled', 
col.fill=grey(0.9), col=1, type='l')

Is there any way in which I can turn this figure on its side, by plotting x ~ 
y... something like this:

# doesn't work
xYplot(x ~ Cbind(yhat, lower, upper), data=l.pred, method='filled', 
lable.curves=FALSE, col.fill=grey(0.9), col=1, type='l')

# standard lattice, but without the fancy filled area
xyplot(x ~ yhat + lower + upper, data=l.pred, type='l', lty=c(1,2,2), col=1)

Any suggestions? If it is not possible, then I will try and manually make the 
figure with basic lattice functions.

Cheers,
Dylan


-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341




More information about the R-help mailing list