[R] Sourcing my file does not print command outputs
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Thu Feb 7 21:09:12 CET 2013
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of John Kane
> Sent: Thursday, February 07, 2013 10:57 AM
> To: James Jong; r-help at r-project.org
> Subject: Re: [R] Sourcing my file does not print command outputs
>
> From ?source
> "Note that running code via source differs in a few respects from
> entering it at the R command line. Since expressions are not executed
> at the top level, auto-printing is not done. So you will need to
> include explicit print calls for things you want to be printed"
>
> John Kane
> Kingston ON Canada
>
>
> > -----Original Message-----
> > From: ribonucleico at gmail.com
> > Sent: Thu, 7 Feb 2013 13:36:56 -0500
> > To: r-help at r-project.org
> > Subject: [R] Sourcing my file does not print command outputs
> >
> > I looked at the documentation of source() and summary(), and I could
> not
> > find the reason why calling something like:
> >
> >> summary(resamps)
> >
> > from the command line, works (it prints the summary)
> >
> > whereas calling
> >
> > summary(resampls)
> >
> > from a file that I source with source("my_file.r") does not print
> > anything.
> >
> > How can I get summary(resamps) to print when I source a file with
> this
> > command?
> >
> > Thanks,
> >
> > James
> >
James,
You might also want to look at ?source for the echo or print.eval parameters to the source() function. Using
source("my_file.r", echo=TRUE)
or
source("my_file.r", print.eval=TRUE)
may get you what you want without adding explicit print statements to your script file.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
More information about the R-help
mailing list