[R] creating a package in R

Duncan Murdoch murdoch at stats.uwo.ca
Sun Apr 19 15:27:29 CEST 2009


On 19/04/2009 9:02 AM, Antonio.Gasparrini at lshtm.ac.uk wrote:
> Dear R users,
>  
> I created some functions I want to convert in a package under Windows (Vista or XP).
> I carefully read both "Writing R extensions" by the R Development Core Team and "Creating R packages: a tutorial" by Friedrich Leisch.
> I've also installed Rtools as suggested.
> These tutorials are very useful, but I'm struggling with the last step of the installation process: after running package.skeleton, creating the directory and modifying the help files, I cannot understand where I should run the commands R CMD INSTALL, check and build.
>  
> Sorry for the stupid question, but I've been stuck for weeks with this problem.

Those commands are meant to be run at the console.  I normally use a 
Cygwin console, but the commands are designed to work fine in the 
Windows CMD console too.

They should also work from within R, if you run them within the system() 
function, and have your system set up properly.  For example:

 > setwd("d:/svn/MyR")
 > system("R CMD build rgl")
* checking for file 'rgl/DESCRIPTION' ... OK
* preparing 'rgl':
* checking DESCRIPTION meta-information ... OK
* cleaning src
make: Nothing to be done for `clean'.
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
WARNING: directory 'rgl/src/ext/GLsdk/GL/codegen' is empty
* building 'rgl_0.85.tar.gz'

(With the usual settings in Rgui, this will be buffered and will appear 
all at once:  you can uncheck the menu item "Misc | Buffered output" to 
have the lines show up reassuringly one at a time.)

The most likely reason for this not to work is that your system path is 
not set correctly.  The relevant path is the one shown by 
Sys.getenv("PATH") while running R.  Mine currently shows

 > Sys.getenv("PATH")
 
 
 
 
         PATH
"c:\\Rtools\\bin;c:\\Rtools\\perl\\bin;c:\\Rtools\\minGW\\bin;f:\\cygwin\\usr\\local\\bin;f:\\cygwin\\bin;f:\\cygwin\\bin;f:\\cygwin\\usr\\X11R6\\bin;c:\\util\\misc;c:\\windows\\system32;f:\\R\\svn\\r-devel\\R\\bin;f:\\texmf\\miktex\\bin;c:\\progra~1\\htmlhe~1;f:\\program 
files\\subversion\\bin"

(If you read it closely, you'll notice some duplication.  It's hard to 
keep a Windows path clean.)

Duncan Murdoch


Duncan Murdoch


> Thanks for your help
>  
> Antonio Gasparrini
> Public and Environmental Health Research Unit (PEHRU)
> London School of Hygiene & Tropical Medicine
> Keppel Street, London WC1E 7HT, UK
> Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
> 
> ______________________________________________
> 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