[R] summary/ returning variables from subfunction

S.McClatchie s.mcclatchie at niwa.cri.nz
Thu Jan 18 23:29:16 CET 2001


Colleagues

----------------------------------
System info:
R version rw1020 on NT
ESS using emacs ver. 20.4

----------------------------------
Below is a summary on returning variable from subfunction, Thanks to 
Brian Ripley and Douglas Bates:

To access the variables within a function, return a list or data structure 
assigned to a variable in the calling function. For more than one varaible, 
assign them to a list variable and separate the components in the calling 
function using listname$variablename.

"test" <-
    function()
  {
    "hello" <-
      function()    
        {
          x <- 1:3
          y <- 23:34
          z <- cbind(x,y)
          return(x,y,z)              
        }
    c <- hello()
    return(c$z,c$x, c$y)
  }

----------------------------

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



More information about the R-help mailing list