---------------------- Forwarded by Pan Yuming/Extern/AAM on 18.10.2000 12:58 --------------------------- Pan Yuming 18.10.2000 11:41 To: Prof Brian Ripley <ripley at stats.ox.ac.uk> cc: Subject: Help oo sink (Document link: Pan Yuming) Dear professor, continue with the example i used, i want to save the prediction results but when i run a R file containing the following code, it just created an empty file. but when i type the cmd line by line in R, it worked. can you help on this? Thanks very much for your kind help. Pan yuming library(tree) data(iris) attach(iris) nobs <- nrow(iris) N <- 1 #while (N + 99 < nobs) { learn <- iris[N:(N+99),] test <- iris[N + 100,] iris.tr <- tree(Species~ . ,learn) sink("test123.txt", append = TRUE) predict(iris.tr, test) sink() #N<-N+1 #} -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Pan Yuming, try something along the lines [Just the significant lines]> iris.tr <- tree(Species~ . ,learn) > sink("test123.txt", append = TRUE) > pred.iris<-predict(iris.tr, test) > print(pred.iris) #this forces a print which is piped by sink to the named#file> sink()I'm sure there are more elegant ways, but this one worked for me pretty well. (To all the experts: Am I right to think that this behaviour is due to the fact that in interactive work on the console the default ist stdout but this is not the case when R is run as a batch job?) Regards, Winfried ---------------------------------- E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de> Date: 18-Oct-00 Time: 14:51:30 Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg "Angewandte Statistik" Universität Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ---------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._