[R] simple linear plots with a loop
David Winsemius
dwinsemius at comcast.net
Mon Apr 7 03:34:53 CEST 2014
On Apr 6, 2014, at 6:07 PM, Kristi Glover wrote:
> Hi R users,
> I was trying to plot with a fixed y with many independet variables.
It looks like you are plotting with a fixed x.
> I tried this loop but it did not work. any suggestions?
Yes. Explain what "did not work" means. Error? Then post the error
message. Different results than expected? Then describe.
> I wanted to make 9 plots. This is a just an example data.
>
> dat1<- as.data.frame(matrix(sample(1:20,100,replace=TRUE),ncol=10))
> lapply(seq_len(ncol(dat1)),function(i)
> {
> par(mfrow=c(3,3)),
> plot(dat1[,1],dat1[,i+1],
> z[,i]<-lm(dat1[,1]~dat1[,i+1]),
What were you expecting to happen to "dat1[,i+1]" when "i" was at its
max?
> abline(z),
> summary(z[,i])
> }
> here first column is dependent variable and other V2 to V10s are
> independent variables. Also wanted look the summary (linear model)
> with each variable.
> Thanks for your suggestions
> KG
> ===
Please post in plain text.
>
> [[alternative HTML version deleted]]
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list