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
On 1/05/2008, at 2:32 PM, Tony Dell wrote:> 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?<snip> You need to ***print*** the output you want to see. Typing ``x'' in an interactive environment causes the value of x to be printed. But in a non-interactive environment (inside a function such as source() or a for loop) it doesn't, and you need to say ``print(x)''. Trap for young players. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
Tony Dell <anthony.dell at jcu.edu.au> [Thu, May 01, 2008 at 04:32:23AM CEST]:> 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: >Please use code and data which is reproducible for us. As we don't have access to your data, we'd have to construct some of our own. This code, however, has the same effect: for (i in 1:100) { sink("./sometext.txt", append=TRUE) summary(rnorm(80)) sink()} When you do the following: for (i in 1:100) { summary(rnorm(80))} what output do you get? And all this output is redirected to your file by sink(), so it works as expected. -- Johannes H?sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:johannes at huesing.name from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, "Life on the Mississippi")
Maybe Matching Threads
- split character string in matrix into character vector and numeric vector
- Replace Function (How to replace numbers in a data frame with a specific number)
- Matrix Row name Compatibility
- ape comparative analysis query
- Re-post data format question (apologies)