On Mon, 2008-11-17 at 15:12 +0100, Wacek Kusnierczyk wrote:
> Duncan Murdoch wrote:
> >
> > paramValue <- 15
> > source("myRfile.R")
> >
> > The quotes are necessary, because source(myRfile.R) would go looking
> > for a variable named myRfile.R, rather than using "myRfile.R" as the
> > filename.
> 
> why?

Because that is how it is written and how R functions in general work;
they evaluate their arguments in the relevant environment. Are you
trying to be obtuse?

source(foo)

is useful as you might have stored the name of the file to source in foo
or built it up from other components via paste() and stored that in foo
to keep the call to source clean. source() accommodates that usage.

[EMAIL PROTECTED] ~]$ touch tmp.R
[EMAIL PROTECTED] ~]$ echo "bar <- rnorm(100)" > tmp.R
[EMAIL PROTECTED] ~]$ cat tmp.R
bar <- rnorm(100)
[EMAIL PROTECTED] ~]$ R

R version 2.7.1 RC (2008-06-16 r45948)
....
Type 'q()' to quit R.

> foo <- "tmp.R"
> source(foo)
> ls()
[1] "bar" "foo"

If you have something useful to say about source() and how it implements
it's behaviour then how about coming up with something constructive then
post it on R-Devel; the appropriate place for discussions about
developing R.

Or are you just trolling?

G

> 
> vQ
> 
> ______________________________________________
> 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
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