wcheckle
2012-Jun-09 21:07 UTC
[R] combining different types of graphics (scatterplots, boxplots) using lattice
Dear R users: I have a continuous outcome variable and four predictors, two continuous and two dichotomous. i would like to use the lattice plot to create scatter plots for the continuous predictors and boxplots for the dichotomous predictors. with 4 continuous variables, this is what i have been doing: trial = rbind ( cbind ( cimt$ant.mean, cimt$age, 1 ), cbind ( cimt$ant.mean, cimt$sbp, 2 ), cbind ( cimt$ant.mean, cimt$ldl, 3 ), cbind ( cimt$ant.mean, cimt$hdl, 4 )) trial = as.data.frame(trial) names(trial) = c("cimt","x","group") trial$group.f factor(trial$group,label=c("Age(years)","SBP(mmHg)","LDL(mg/dL)","HDL(mg/dL)")) x11(height=6,width=14) xyplot (cimt~x|group.f, data=trial, scale=list(x=list(relation="free")),as.table=T,col="dark grey", strip=strip.custom(which.given=1, bg="transparent"),ylab="Mean CIMT (mm)",layout=c(4,1),aspect=1:1,xlab="",pch=16) Any recommendations how to use the lattice package in include 2 dichotomous variables with two continuous variables? thank you, William -- View this message in context: http://r.789695.n4.nabble.com/combining-different-types-of-graphics-scatterplots-boxplots-using-lattice-tp4632907.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2012-Jun-10 03:36 UTC
[R] combining different types of graphics (scatterplots, boxplots) using lattice
On Jun 9, 2012, at 5:07 PM, wcheckle wrote:> Dear R users: > > I have a continuous outcome variable and four predictors, two > continuous and > two dichotomous. i would like to use the lattice plot to create > scatter > plots for the continuous predictors and boxplots for the dichotomous > predictors. > > with 4 continuous variables, this is what i have been doing: > > trial = rbind ( > cbind ( cimt$ant.mean, cimt$age, 1 ), > cbind ( cimt$ant.mean, cimt$sbp, 2 ), > cbind ( cimt$ant.mean, cimt$ldl, 3 ), > cbind ( cimt$ant.mean, cimt$hdl, 4 )) > > trial = as.data.frame(trial) > names(trial) = c("cimt","x","group") > > trial$group.f > factor(trial$group,label=c("Age(years)","SBP(mmHg)","LDL(mg/ > dL)","HDL(mg/dL)")) > x11(height=6,width=14) > xyplot (cimt~x|group.f, data=trial, > scale=list(x=list(relation="free")),as.table=T,col="dark grey", > strip=strip.custom(which.given=1, bg="transparent"),ylab="Mean CIMT > (mm)",layout=c(4,1),aspect=1:1,xlab="",pch=16) >Isn't that what splom is supposed to be for? -- David.> > Any recommendations how to use the lattice package in include 2 > dichotomous > variables with two continuous variables? > > thank you, > > William > > -- > View this message in context: http://r.789695.n4.nabble.com/combining-different-types-of-graphics-scatterplots-boxplots-using-lattice-tp4632907.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT