[R] using the sink() function in a for-look
Johannes Hüsing
johannes at huesing.name
Thu May 1 06:40:25 CEST 2008
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")
More information about the R-help
mailing list