[R] r help message
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Thu Jan 18 08:13:31 CET 2001
On Thu, 18 Jan 2001, S.McClatchie wrote:
> System info:
> R version rw1020 on NT
> ESS using emacs ver. 20.4
> To keep my scripts short and tidy, I want to call sub-functions and return
> variables from these for subsequent use in the calling function.
> "test.smooth.opc.time.series" <-
> Within the sub-function "load.opc.ascii.files" I have tried two ways of
> assigning variables for use by the calling function
> dir <<- c('h:/data/nov99_tan9913/opc/')
> This works but clutters the workspace.
> assign(dir, c('h:/data/nov99_tan9913/opc/')), envir =
> Which returns an odd error telling me there is an invalid first argument
> in assign. I don't see why, after reading the help on this function.
The first argument should be a character vector naming the object.
The help page says:
x: a variable name (given as a quoted string).
and dir is not a quoted string, is it? What's odd?
You don't need the c() in either case.
Also, test.smooth.opc.time.series is not an environment: you need
parent.frame(), I think.
Is this really a good idea? The normal idea is to collect return variables
into a list and return that. Explicit use of assign or <<- in S/R
user code is normally a sign of design problems, although they are needed
in system 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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
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
More information about the R-help