I'm trying to learn how to use R version 1.1.0 under Mandrake Linux version 6.1. Using R interactively, I get good results. However, when I attempt to execute commands from a file (following the directions in section 1.10 of An Introduction to R, version 1.10) my output disappears. As a default or after a sink() command, I would expect to see output on the console, but none appears. After a sink("record.lis") command, I would expect to find the output in the record.lis file, but it is empty. The commands in my input file (e.g., summary(fm)) produce output in interactive mode, so I don't understand why no output appears in batch mode. Any error in the input file produces an error message on the console. But when I correct the error, there is still no visible output. Any help would be appreciated. -- John P. Burkett Department of Economics University of Rhode Island 10 Chafee Road, Suite 3 Kingston, RI 02881-0808 phone: (401) 874-4122 fax: (401) 874-2858 -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20000727/0fec9a0a/attachment.html
On Thu, 27 Jul 2000, John P. Burkett wrote:> I'm trying to learn how to use R version 1.1.0 under Mandrake Linux > version 6.1. Using R interactively, I get good results. However, when > I attempt to execute commands from a file (following the directions in > section 1.10 of An Introduction to R, version 1.10) my output > disappears.This should probably be added to the FAQ. Short answer: source(infile.R,echo=T) or R BATCH infile.R outfile or R --no-save <infile.R >outfile & Long answer: When code is run with source() there is only one way for information to appear on the screen: it gets explicitly printed with print() or cat() or a similar function. If your file contains the line 1+2 R will compute the value 3 but nothing will be printed because there is no print() function. If it contains print(1+2) then 3 will be printed. In interactive mode, when you type in an expression, the value of that expression is computed and then printed by the user interface If you type 1+2 R will compute and return the value 3, and the user interface will print it. If you type print(1+2) then the expression is evaluated (causing "3" to be printed) and then the user interface prints the returned value of "print(1+2)", which is also 3, so the output would appear twice. The fact that source() doesn't normally print everything on the output is a feature, not a bug. The main use of source() is to load code. When you type eg, library(nlme), literally hundreds of functions are read in. You really don't want them appearing on the screen. -thomas Thomas Lumley Assistant Professor, Biostatistics University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"John P. Burkett" <burkett at uriacc.uri.edu> writes:> I'm trying to learn how to use R version 1.1.0 under Mandrake Linux > version 6.1. Using R interactively, I get good results. However, when > I attempt to execute commands from a file (following the directions in > section 1.10 of An Introduction to R, version 1.10) my output > disappears. As a default or after a sink() command, I would expect to > see output on the console, but none appears. After a sink("record.lis") > command, I would expect to find the output in the record.lis file, but > it is empty. The commands in my input file (e.g., summary(fm)) produce > output in interactive mode, so I don't understand why no output appears > in batch mode. Any error in the input file produces an error message on > the console. But when I correct the error, there is still no visible > output. Any help would be appreciated.I.e. you're using source(), which is not actually batch mode. (See help(BATCH) for the real thing). The default for source() is not to print commands and their output, try setting echo=T. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._