[R] system.time behavior using source

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 18 08:19:48 CEST 2007


You need to print the result of an expression if used from source().
Autoprinting only occurs at the top level.
E.g.

% cat > systest.R
print(system.time(for(i in 1:100) mad(runif(1000))))

> source("systest.R")
    user  system elapsed
    0.14    0.00    0.20

On Mon, 17 Sep 2007, Leeds, Mark (IED) wrote:

> If I type the line below at my Rprompt, it works fine. But, if I put the
> same line in a file called systest.R and then source that file at
> the prompt, nothing happens. IF I use R CMD BATCH, it also works in that
> the system.time info is the .Rout file. Is there something I
> can do so that this line also works when I source it ?  Thanks. My
> information is below.
>
> system.time(for(i in 1:100) mad(runif(1000)))
>
>
>
> My information :
>
> R version 2.5.0 (2007-04-23)
> i686-pc-linux-gnu
>
> locale:
> C
>
> attached base packages:
> [1] "datasets"  "utils"     "stats"     "graphics"  "grDevices"
> "methods"   "base"
>
> other attached packages:
> lattice filehash  reshape      zoo    chron     MASS
> "0.15-8"    "1.0"  "0.7.4"  "1.3-1" "2.3-11" "7.2-33"
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
>
> ______________________________________________
> R-help at 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list