Hello,

I am running R under Ubuntu 8.04.  I am trying to do numerous linear
fits to various subsets of my data set.  I am having trouble convincing
R to send the output from these fits to text files from within a script.
When I run my script, all the plots are created as postscript files in
the correct directory, and text files appear with the correct names for
all the summaries of the fits.  However, all of these files are blank!
If I copy/paste the "sink" commands from my script manually into the
command line, the files are created correctly, but if the same commands
are executed from within my script, no output is generated.

The output section of my script, which correctly creates the plots I
want, but not the text, is:

x_seq1_fit=lm(xagb$X5mag[x_seq1_filt]~x1per)
x_seq2_fit=lm(xagb$X5mag[x_seq2_filt]~x2per)

setwd("/home/driebel/sage/output/pl_fits/R/5mag/chem")
postscript(file="x_seq1_fit.ps")
plot(x1per,xagb$X5mag[x_seq1_filt],ylim=c(13,7))
abline(x_seq1_fit,col="red")
dev.off()
postscript(file="x_seq1_resid.ps")
plot(x1per,x_seq1_fit$res)
abline(h=0,col="red")
dev.off()

postscript(file="x_seq2_fit.ps")
plot(x2per,xagb$X5mag[x_seq2_filt],ylim=c(13,7))
abline(x_seq2_fit,col="red")
dev.off()
postscript(file="x_seq2_resid.ps")
plot(x2per,x_seq2_fit$res)
abline(h=0,col="red")
dev.off()

sink(file="x_seq2_fit.dat")
summary(x_seq2_fit)
sink()
sink(file="x_seq1_fit.dat")
summary(x_seq1_fit)
sink()


Is there something else one must do with "sink" from within a script?
Thanks for your help,

Dave

______________________________________________
R-help@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.

Reply via email to