[R] How to pack my stuff into a package (library, collection)?

Duncan Murdoch murdoch at stats.uwo.ca
Mon Apr 7 13:02:51 CEST 2008


Tribo Laboy wrote:
> Hi Simon,
>
> I did the example given in package.skeleton
>
> f <- function(x,y) x+y
> g <- function(x,y) x-y
> d <- data.frame(a=1, b=2)
> e <- rnorm(1000)
>
> package.skeleton(list=c("f","g","d","e"), name="mypkg")
>
>
> then tried:
>
> library(mypkg)
>
> Error in library(mypkg) : there is no package called 'mypkg'
>
>
> After checking the directory structure, I found the "package" 'mypkg'
> placed under 'bin' sub-directory. I moved it to 'library', where all
> of the CRAN downloaded packages are and this is what I get:
>
>   
>> library(mypkg)
>>     
> Error in library(mypkg) :
>   'mypkg' is not a valid package -- installed < 2.0.0?
>
>
> What am I missing?
>
>   
You created the source code for a package, but it needs some work to 
install it.  On Windows that means installing the Rtools collection and 
running "Rcmd INSTALL pkgdir" from the Windows command line (what some 
people call "the DOS box").

At some point I'm sure we'll include those tools with R, but it will 
more or less double the size of the download.  We've been reluctant when 
a lot of our users are on slow connections, and most won't need those tools.

Duncan Murdoch
> Regards,
>
> TL
>
>
> On Mon, Apr 7, 2008 at 3:49 PM, Simon Blomberg <s.blomberg1 at uq.edu.au> wrote:
>   
>> On Mon, 2008-04-07 at 15:13 +0900, Tribo Laboy wrote:
>>  > Hello,
>>  >
>>  > I am new useR, I have written some functions, which I currently use by
>>  > "source"-ing them from the files.
>>  > That's OK, but when I my functions start counting in the tens and
>>  > hundreds I'd be glad to be able to type
>>  > "help.search("my_obscure_fun")" and get a sensible reply. I also want
>>  > to be able to load them as a package at startup and not have to
>>  > "source" each one individually. I read through the "Writing R
>>  > Extensions" file, but I am overwhelmed with the vast amount of
>>  > prescribed detail that Extension Authors must follow - directory
>>  > structure, file structure, etc. Luckily, I found the "prompt"
>>  > function, which helps in writing of help-files in the form of "fill-in
>>  >  the blanks". But that's only for the help-files. Reading further, it
>>  > gets even more complicated. The user is referred to the "R
>>  > Installation and Administration" document, which says that:
>>  >
>>  > If you want to build R or add-on packages from source in Windows, you
>>  > will need to collect, install and test an extensive set of tools.
>>  >
>>  > These seem to include among others Perl and compiler. But R is an
>>  > interpreted and cross-platform language, I don't understand the need
>>  > for additional platform specific tools just to call a user collection
>>  > of R-files. Anyone knows of a smooth introduction to these topics?
>>  >
>>
>>  Have a look at ?package.skeleton. It should get you started. If you just
>>  want to build packages with pure R (no shared libraries etc.), I think
>>  you won't need the other tools.
>>
>>  Cheers,
>>
>>  Simon.
>>
>>
>>  > Rgards,
>>  > TL
>>  >
>>  > ______________________________________________
>>  > R-help at r-project.org mailing list
>>  > https://stat.ethz.ch/mailman/listinfo/r-help
>>  > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>  > and provide commented, minimal, self-contained, reproducible code.
>>  --
>>  Simon Blomberg, BSc (Hons), PhD, MAppStat.
>>  Lecturer and Consultant Statistician
>>  Faculty of Biological and Chemical Sciences
>>  The University of Queensland
>>  St. Lucia Queensland 4072
>>  Australia
>>  Room 320 Goddard Building (8)
>>  T: +61 7 3365 2506
>>  http://www.uq.edu.au/~uqsblomb
>>  email: S.Blomberg1_at_uq.edu.au
>>
>>  Policies:
>>  1.  I will NOT analyse your data for you.
>>  2.  Your deadline is your problem.
>>
>>  The combination of some data and an aching desire for
>>  an answer does not ensure that a reasonable answer can
>>  be extracted from a given body of data. - John Tukey.
>>
>>
>>     
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list