[R] Newbie: Examples on functions callling a library etc.

Ben Bolker bolker at ufl.edu
Fri Aug 29 04:43:32 CEST 2008


Eduardo M. A. M.Mendes <emammendes <at> gmail.com> writes:

> R is pretty new to me. I need to write a function that returns three
> matrices of different dimensions.  In addition, I need to call a function
> from a contributed package with the function.   I have browsed several
> manuals and docs but the examples on them are either very simple or
> extremely hard to follow.
> 
> Many thanks
> 
> Ed
> 

  I think you need to try to specify your needs a little bit
more carefully.  Here is a function that technically meets
your needs:

library("example_pkg")  ## to load the contributed package
myfunction <- function() {  ## function with no arguments
   foo()                    ## assuming the function "foo" is in the package
   list(matrix(nrow=2,ncol=2),matrix(nrow=3,ncol=3),matrix(nrow=4,ncol=4)
}

  But I suspect that doesn't really do what you need ...

  Ben Bolker



More information about the R-help mailing list