[R] how to use the function from another package

Tuszynski, Jaroslaw W. JAROSLAW.W.TUSZYNSKI at saic.com
Tue Aug 9 21:13:54 CEST 2005


> Thanks very much for your help. Do I still have to write library( ) to
load the library in my code after I add a "depends" field in the DESCRIPTION
file? 

No, 

First when user of your package downloads it (at least on Windows machines)
all required packages are also downloaded (this mechanism sometimes needs
manual help, but that is another story). Then when he loads your package (by
calling library(YourPackage)) all required packages are loaded into R.

One good way to research this kind of questions (other than documentation
and R-Help) is to study source code of other people packages.
   
Jarek
====================================================\=======

 Jarek Tuszynski, PhD.                           o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192                                   ">   \
 Jaroslaw.W.Tuszynski at saic.com                     `    \


-----Original Message-----
From: peterwyang at gmail.com [mailto:peterwyang at gmail.com] 
Sent: Tuesday, August 09, 2005 2:57 PM
To: Tuszynski, Jaroslaw W.
Subject: Re: [R] how to use the function from another package

Thanks very much for your help. Do I still have to write library( ) to load
the library in my code after I add a "depends" field in the DESCRIPTION
file? Thanks.

Peter


On 8/9/05, Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI at saic.com> wrote:
> See "Writing R Extensions" / Creating R package / Description file / 
> "depends" field (section 1.1.1).
> 
> Jarek
> ====================================================\=======
> 
>  Jarek Tuszynski, PhD.                           o / \
>  Science Applications International Corporation  <\__,|
>  (703) 676-4192                                   ">   \
>  Jaroslaw.W.Tuszynski at saic.com                     `    \
> 
> 
> 
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Peter Yang
> Sent: Tuesday, August 09, 2005 1:56 PM
> To: R-help at stat.math.ethz.ch
> Subject: [R] how to use the function from another package
> 
> Hi, I am trying to write a package(A) for myself and need to use a 
> function from another package(B) which is in R already(need to install 
> it before use). Could anyone tell me how to implement that? Also I 
> hope that my package gives an ERROR message(something like "STOP, 
> please install package B first") if the package B is not installed 
> yet.  It is my first time to write a package. Thanks very much for your
help.
> 
> Peter
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list