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

Tony Dell anthony.dell at jcu.edu.au
Thu May 1 04:32:23 CEST 2008


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



More information about the R-help mailing list