Skip to content

r help message

2 messages · S.McClatchie, Brian Ripley

#
Colleagues

----------------------------------
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.

e.g.

"test.smooth.opc.time.series" <-
  function()             

{
  load.opc.ascii.files()
}

Within the sub-function "load.opc.ascii.files" I have tried two ways of
assigning variables for use by the calling function
"test.smooth.opc.time.series":

 dir <<- c('h:/data/nov99_tan9913/opc/')

This works but clutters the workspace.

assign(dir,  c('h:/data/nov99_tan9913/opc/')), envir = 
test.smooth.opc.time.series)          

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.

Any suggestions? Help will be appreciated.
Thanks

Sam

Sam McClatchie, Research scientist (fisheries acoustics))))))))))
NIWA (National Institute of Water & Atmospheric Research Ltd)
PO Box 14 901, Kilbirnie, Wellington, New Zealand
s.mcclatchie at niwa.cri.nz 

                    /\
...>><xX(?> // \\
                 /// \\\   
                //// \\\\
               ///  <?)Xx><<
              /////  \\\\\\
        ><(((?>   
  >><(((?>   ...>><xX(?>O<?)Xx><<

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 18 Jan 2001, S.McClatchie wrote:

            
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.