[R] using the sink() function in a for-look

From: Tony Dell <anthony.dell_at_jcu.edu.au>
Date: Thu, 01 May 2008 12:32:23 +1000


hi all,

i wanted to use the sink function to sequentially output regression summaries within a for-loop. i must have something wrong somewhere (or be using the sink function incorrectly), but can anyone help?

the code I am using is:

where data.x is a data.frame of independents, and data.y is a data.frame of dependents.

> for (i in 1:length(data.y)){
> taxa.i <- names(data.y[i])
>


jpeg(file=paste(taxa.i,".multiple.regress.residuals.1.RAW.jpeg",sep=""), quality=90, width=1000, height=1000)
> par(mfrow=c(2,2), lwd=0.5, mar=c(3,4,3,1), bty="o", oma=c(0,3,2,0))
> attach(data.x)
> mult.reg.raw.i <- lm(data.y[,i] ~ CURRENT + LITTER + PERCURR + SUBST)
> plot(mult.reg.raw.i, ask=FALSE)
> mtext(names(data.y[i]), side=3, line=-1.5, adj=0.48, cex=0.75,

outer=TRUE)
> dev.off()
> sink("mulptiple regression - summary RAW.txt", append=TRUE)
> summary(mult.reg.raw.i)
> sink()
> }

cheers,

tony


tony dell
department of marine and tropical biology james cook university townsville, qld 4811 australia

[p] 07 47815751 or 47814520
[e] anthony.dell_at_jcu.edu.au
[skype] anphony


Checked by AVG.

6:27 PM



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. Received on Thu 01 May 2008 - 02:41:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 01 May 2008 - 05:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive