A blog by Rob J Hyndman 

Twitter Gplus RSS

Building R packages for Windows

Published on 14 July 2009

1. Installing the required tools

To build an R pack­age in Win­dows, you will need to install some addi­tional soft­ware tools. These are sum­ma­rized at

http://​cran​.​r​-project​.org/​b​i​n​/​w​i​n​d​o​w​s​/​R​t​ools/

1.1 Essen­tial: Rtools

This is a col­lec­tion of unix-​​like tools that can be run from the DOS com­mand prompt. It also con­tains the MinGW com­pil­ers that are used for com­pil­ing For­tran and C code. You should down­load and run the ver­sion cor­re­spond­ing to the flavour of R you are using. When asked, choose the default “Pack­age author­ing instal­la­tion” to build add-​​on packages.

1.2 Optional: MikTeX

Mik­TeX is used for pro­duc­ing the pdf help files. You can pro­duce an R pack­age with­out it, but the pack­age will not con­tain pdf help files. Most of you will have this installed any­way. Down­load from

http://​www​.mik​tex​.org

1.3 Essen­tial: Set­ting PATH variable

The PATH vari­able tells Win­dows where to find the rel­e­vant pro­grams. To add a direc­tory to your PATH on Win­dows select

Control Panel -> System -> Advanced -> Environment Variables

The path vari­able may have already been fixed in step 1.1. In any case, you should check that it looks some­thing like this:

 C:\Rtools\bin;C:\Program files\R\R-2.15.1\bin\x64;

The last direc­tory will depend on whether you have a 32-​​bit or 64-​​bit oper­at­ing sys­tem. It should be the direc­tory that con­tains the file Rcmd.exe

  • The pre­cise direc­to­ries will depend where you have installed the var­i­ous tools. The above path should work if you have fol­lowed the default instal­la­tion pro­ce­dure. If the direc­tory names con­tain spaces, put them in quo­ta­tion marks.
  • I have assumed R2.15.1. For later ver­sions, sim­ply change the above paths to the rel­e­vant R ver­sion. It will prob­a­bly then still work.
  • If there are prob­lems, please read the Rtools.txt file carefully.

2 Cre­at­ing the package

Infor­ma­tion about cre­at­ing pack­ages is pro­vided in the doc­u­ment “Writ­ing R exten­sions” (avail­able under the R Help menu) or at

http://​cran​.​r​-project​.org/​d​o​c​/​m​a​n​u​a​l​s​/​R​-​e​x​t​s​.html

The main items are sum­ma­rized below to get you started, but you will almost cer­tainly need to con­sult the above doc­u­ment if you are to suc­cess­fully com­pile a package.

2.1 Use package.skeleton()

The sim­plest way to cre­ate a pack­age is to first cre­ate an R work­space con­tain­ing all the rel­e­vant func­tions and data sets that you want to include in the pack­age. Delete any­thing from the work­space that you do not want to include in the pack­age. Make sure the cur­rent direc­tory is set to whereever you want cre­ate the pack­age. Use

setwd("C:/My Documents/Rpackages")

for exam­ple. Then, to cre­ate a pack­age called "fred", use the R command

package.skeleton(name="fred")

This will gen­er­ate a direc­tory fred and sev­eral sub-​​directories in the required structure.

2.2 Edit­ing the files

A pack­age con­sists of a direc­tory con­tain­ing a file ‘DESCRIPTION’ and usu­ally has the sub­di­rec­to­ries R, data and man. The pack­age direc­tory should be given the same name as the pack­age. The package.skeleton com­mand above will have cre­ated these files for you. You now need to edit them so they con­tain the right information.

2.3 DESCRIPTION file

The DESCRIPTION file con­tains basic infor­ma­tion about the pack­age in the fol­low­ing format:

 Package: pkgname
 Version: 0.5
 Date: 2007-06-05
 Title: My first collection of functions
 Author: Joe Developer , with
 contributions from A. User .
 Maintainer: Joe Developer
 Depends: R (>= 2.0.0), forecast
 Suggests: tseries
 Description: A short (one paragraph) description of what
 the package does and why it may be useful.
 License: GPL version 2 or newer
 URL: http://www.another.url

2.4 Rd files

The help files for each func­tion and data set are given in “R doc­u­men­ta­tion” (Rd) files in the man sub­di­rec­tory. These are in a sim­ple markup lan­guage closely resem­bling LaTeX, which can be processed into a vari­ety of for­mats, includ­ing LaTeX, HTML and plain text. As an exam­ple, here is the file which doc­u­ments the func­tion seasadj in the forecast package.

\name{seasadj}
\alias{seasadj}
\title{Seasonal adjustment}
\usage{
seasadj(object)
}
 
\arguments{
\item{object}{Object created by \code{\link[stats]{decompose}}
or \code{\link[stats]{stl}}.}
}
 
\description{Returns seasonally adjusted data constructed
by removing the seasonal component.}
 
\value{Univariate time series.}
 
\seealso{\code{\link[stats]{stl}}, \code{\link[stats]{decompose}}}
 
\author{Rob J Hyndman}
 
\examples{
plot(AirPassengers)
lines(seasadj(decompose(AirPassengers,"multiplicative")),col=4)
}
 
\keyword{ts}

Detailed instruc­tions for writ­ing R doc­u­men­ta­tion are at

http://​cran​.​r​-project​.org/​d​o​c​/​m​a​n​u​a​l​s​/​R​-​e​x​t​s​.​h​t​m​l​#​W​r​i​t​i​n​g​-​R​-​d​o​c​u​m​e​n​t​a​t​i​o​n​-​files

2.5 Includ­ing C or For­tran code

If your R code calls C or For­tran func­tions, the source code for these func­tions needs to be placed in the sub­di­rec­tory src under fred.

2.6 Com­pil­ing the pack­age for Windows

To com­pile the pack­age into a zip file, go to a DOS prompt in the direc­tory con­tain­ing your pack­age. (i.e., the direc­tory "C:\My Documents\Rpackages" in the above exam­ple. Then type

Rcmd INSTALL --build fred

This will com­pile all the nec­es­sary infor­ma­tion and cre­ate a zip file which should be ready to load in R.

2.7 Check­ing the package

To check that the pack­age sat­is­fies the require­ments for a CRAN pack­age, use

Rcmd check fred

The checks are quite strict. A pack­age will often work ok even if it doesn’t pass these tests. But it is good prac­tice to build pack­ages that do sat­isfy these tests as it may save prob­lems later.

2.8 Build­ing a pack­age for other oper­at­ing systems

To build a pack­age for some­thing other than a Win­dows com­puter, use

Rcmd build fred

This cre­ates a tar.gz file which can then be installed on a non-​​Windows com­puter. It can also be uploaded to CRAN pro­vided it sat­is­fies the above tests.


Related Posts:


 
Tags:
53 Comments  comments 
  • Steve

    Rob, thanks for post­ing this but I am still strug­gling to make your exam­ple work. All the steps work up to

    Rcmd build –binary fred

    *** installing help indices
    Error in Rd_info(db[[i]]) : Rd files must have a non-​​empty \title.
    See chap­ter ‘Writ­ing R doc­u­men­ta­tion’ in man­ual ‘Writ­ing R Exten­sions’.
    * remov­ing ‘C:/Users/eick/AppData/Local/Temp/Rinst1284800485/fred’
    ERROR
    * instal­la­tion failed

    My \title is fine and Rcmd build works fine if I take out the –binary but the result­ing fred_1.0.tar.gz won’t install.

    • http://robjhyndman.com Rob J Hyndman

      It sounds like some kind of prob­lem with your Rd files rather than with the soft­ware needed to build a pack­age for Win­dows. build with­out –binary is just zip­ping up your direc­tory and not pro­cess­ing any files.

  • http://www.stat.auckland.ac.nz/showperson?firstname=David&surname=Scott David Scott

    I rec­om­mended this post on R-​​help as being use­ful. Uwe Ligges rightly pointed out there have been changes since R-2.10.0:

    ” … these instruc­tions are out­dated since there is no chm help
    sup­port for R-2.10.x, for example.”

    You may wish to update

    • http://robjhyndman.com Rob J Hyndman

      Thanks David. I’ve updated the instructions.

  • alex

    I have done my R pack­age on UNIX, and it did not work in Win­dows. I tried to build R pack­age using above steps.

    But there is no RCMD com­mand on DOS prompt , it show it is not rec­og­nized as inter­nal or exter­nal command.

    Do you know the rea­son? My PC os is windows7. Thanks

    • http://robjhyndman.com Rob J Hyndman

      If Rcmd is not rec­og­nized at the DOS prompt then you don’t have the path to the R bin direc­tory set up prop­erly (step 1.3). Type “path” at the DOS prompt and check that the direc­tory is listed.

      • http://y.mehrali.tripod.com yaser

        Thank you for your use­ful com­ments. I did all steps respec­tively to build pack­age with name: mypkg
        I instal Rtools and Mik­TeX and I did step 1.3 to add this paths:
        C:\Rtools\bin
        C:\Rtools\perl\bin
        C:\Rtools\MinGW\bin
        C:\Program Files\R\R-2.11.1\bin

        By using this prompts in R, I make mypkg folder in: C:\Users\Yaser\Documents
        > require(stats)
        > f package.skeleton(list=“f”, name=“mypkg”)

        So I changed MS-​​Dos Com­mand prompt to: C:\Users\Yaser\Documents>_
        But when I run “Rcmd build –binary mypkg” or “Rcmd build mypkg” in , I see this Error:
        ’Rcmd’ is not reco­go­nized as an inter­nal or exter­nal com­mand, oper­a­ble pro­gram or batch file.

        I need your help to make pack­age, I have some func­tions that want to con­vert them in pack­age. I need your help, if it is pos­si­ble, I want from you to make a graphic or video view of all above steps.
        With many thanks
        Good luck

        • http://robjhyndman.com Rob J Hyndman

          It looks like you ignored my last advice. I really can’t pro­vide gen­eral help on all things related to R and DOS. Try read­ing a manual.

  • alex

    Thank you for your quick respose. I found it in C:\Program Files (x86)\R\R-2.10.1\bin. How­ever, when I run Rcmd install mypack­age. it showed it can’t open perl script “C:\PROGRA~2\R\R-210~1.1\bin\install”.

    I can­not find it either , I changed path in way as above.

    Do you have sug­ges­tion? Thanks.

    have a good day!

  • alex

    Sorry. I installed it in R GUI. Thanks you for your help.

  • mery

    i have a ques­tion.
    when i run R CMD check mypack­age, it showed “Instal­la­tion failed” when it is check­ing whether pack­age “mypack­age” can be installed…ERROR

    • http://robjhyndman.com Rob J Hyndman

      You need to read the rest of the out­put to fig­ure out what the error is. Try clos­ing R and make sure noth­ing else is access­ing the rel­e­vant directory.

  • mery

    Thanks, one error is in DESCRIPTION file! Now i’ll hope that it’s all ok!

  • mery

    sorry i’ve another prob­lem when i checked mypackage:

    it showed “Found pos­si­bly glob­abl ‘T’ or ‘F’ in the fol­low­ing func­tios: A, B, C” when it is check­ing R code for pos­si­ble errors.…NOTE

    • http://robjhyndman.com Rob J Hyndman

      Try read­ing the manuals.

  • Lxmi

    Hi,
    When I was doing R CMD check mypack­age I got an error say­ing that :
    check­ing whether the pack­age can be loaded: ERROR
    Error in library(test): there is no pack­age called ‘test’
    Exe­cu­tion halted
    It looks like this pack­age has a load­ing problem … ”

    Any help is appre­ci­ated.
    Thanks in advance..
    –Lxmi

  • Jane

    Hi,
    Thank you for this sum­mary page!
    I have a pack­age I was pre­vi­ously able to com­pile and use for R 2.6.
    In the newer ver­sions of R it did not work, so I am mak­ing it from scratch using Rtools and new R version.

    How­ever, I keep get­ting error after Rcmd build –binary mypack

    * check­ing for file ‘mypack/​DESCRIPTION’ … OK
    * prepar­ing ‘mypack’:
    * check­ing DESCRIPTION meta-​​information … OK
    * remov­ing junk files
    * check­ing for LF line-​​endings in source and make files
    * check­ing for empty or unneeded direc­to­ries
    * build­ing binary dis­tri­b­u­tion
    * installing *source* pack­age ‘mypack’ …
    ** R
    ** prepar­ing pack­age for lazy load­ing
    ** help
    Warn­ing: ./man/mypack-package.Rd:34: All text must be in a sec­tion
    Warn­ing: ./man/mypack-package.Rd:35: All text must be in a sec­tion
    *** installing help indices
    ** build­ing pack­age indices …
    ** test­ing if installed pack­age can be loaded
    gdata: read.xls sup­port for ‘XLS’ (Excel 97–2004) files ENABLED.

    gdata: Unable to load perl libaries needed by read.xls()
    gdata: to sup­port ‘XLSX’ (Excel 2007+) files.

    gdata: Run the func­tion ‘instal­lXL­SX­sup­port()‘
    gdata: to auto­mat­i­cally down­load and install the perl
    gdata: libaries needed to sup­port Excel XLS and XLSX for­mats.
    Error in winMenuAdd(menuname, NULL, NULL) :
    Menu func­tions can only be used in the GUI
    ERROR: load­ing failed
    * remov­ing ‘C:/DOCUME~1/…/mypack’
    ERROR
    * instal­la­tion failed

    • http://robjhyndman.com Rob J Hyndman

      Jane. Read the error mes­sage. It help­fully says to run the func­tion instal­lXL­SX­sup­port() from the gdata pack­age in order to com­plete its installation.

  • Jane

    These are just warn­ings.
    The error comes from:
    Error in winMenuAdd(menuname, NULL, NULL) :
    Menu func­tions can only be used in the GUI

    Thanks!

  • Vishal Gokhale

    Thanks for the page.
    It helped me to avoid restart­ing the machine in Ubuntu every time I wanted to make a code change to debug a cer­tain piece of code.
    How­ever I noticed that run­ning just below com­mand results into an error
    ——————————————
    >package.skeleton(name=“fred”)
    Error in !have : invalid argu­ment type
    ——————————————
    Using the com­mand (below) instead works
    You might want to change just that bit to make it per­fect :)
    ————————————————————–
    >package.skeleton(name = “fred”, envi­ron­ment = .Glob­alEnv, path = “.”, force = FALSE, name­space = FALSE)
    Cre­at­ing direc­to­ries …
    Cre­at­ing DESCRIPTION
    Cre­at­ing Read-​​and-​​delete-​​me …
    Sav­ing func­tions and data …
    Mak­ing help files …
    Done.
    Fur­ther steps are described in ‘./​fred/​Read-​​and-​​delete-​​me’.
    ———————————————————————

  • Roger

    Hi, thank you so much for this sum­mary. It’s very nice and clear.

    I fol­lowed all the steps out­lined here, how­ever, I still got some prob­lems when I try to enter the dos commands.

    If I entered “Rcmd build curves2”, every­thing is fine, and the pack­age can be installed in R in Mac.
    How­ever, if I entered “Rcmd build –binary curves2”. There seems to be one error. (Though I can still see one pack­age appear after this com­mand is run, how­ever, it’s not instal­lable in R under win­dows)
    Could you please help me out of this? Thanks so much~~

    The dos results are as follows:

    C:\Users\z4432045>Rcmd build –binary curves2
    * check­ing for file ‘curves2/​DESCRIPTION’ … OK
    * prepar­ing ‘curves2’:
    * check­ing DESCRIPTION meta-​​information … OK
    * clean­ing src
    * check­ing whether ‘INDEX’ is up-​​to-​​date …Warn­ing in readLines(oldindex) : inc
    omplete final line found on ‘INDEX
    NO
    * use ‘–force’ to remove the exist­ing ‘INDEX
    cyg­win warn­ing:
    MS-​​DOS style path detected: C:/Users/z4432045/curves2_1.0.1.tar
    Pre­ferred POSIX equiv­a­lent is: /cygdrive/c/Users/z4432045/curves2_1.0.1.tar
    CYGWIN envi­ron­ment vari­able option “nodos­file­warn­ing” turns off this warn­ing.
    Con­sult the user’s guide for more details about POSIX paths:
    http://​cyg​win​.com/​c​y​g​w​i​n​-​u​g​-​n​e​t​/​u​s​i​n​g​.​h​t​m​l​#​u​s​i​n​g​-​p​a​t​h​names
    cyg­win warn­ing:
    MS-​​DOS style path detected: C:/Users/z4432045/curves2_1.0.1.tar
    Pre­ferred POSIX equiv­a­lent is: /cygdrive/c/Users/z4432045/curves2_1.0.1.tar
    CYGWIN envi­ron­ment vari­able option “nodos­file­warn­ing” turns off this warn­ing.
    Con­sult the user’s guide for more details about POSIX paths:
    http://​cyg​win​.com/​c​y​g​w​i​n​-​u​g​-​n​e​t​/​u​s​i​n​g​.​h​t​m​l​#​u​s​i​n​g​-​p​a​t​h​names
    * check­ing for LF line-​​endings in source and make files
    * check­ing for empty or unneeded direc­to­ries
    * build­ing binary dis­tri­b­u­tion
    * installing *source* pack­age ‘curves2’ …

    Using auto-​​selected zip option ‘–use-​​zip-​​data’

    ** libs
    cyg­win warn­ing:
    MS-​​DOS style path detected: C:/PROGRA~1/R/R-212~1.2/etc/i386/Makeconf
    Pre­ferred POSIX equiv­a­lent is: /cygdrive/c/PROGRA~1/R/R-212~1.2/etc/i386/Makec
    onf
    CYGWIN envi­ron­ment vari­able option “nodos­file­warn­ing” turns off this warn­ing.
    Con­sult the user’s guide for more details about POSIX paths:
    http://​cyg​win​.com/​c​y​g​w​i​n​-​u​g​-​n​e​t​/​u​s​i​n​g​.​h​t​m​l​#​u​s​i​n​g​-​p​a​t​h​names
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c dcd­flib
    .c –o dcdflib.o
    dcdflib.c: In func­tion ‘cdf­bin’:
    dcdflib.c:1889:5: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    dcdflib.c: In func­tion ‘cdfgam’:
    dcdflib.c:3551:9: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    dcdflib.c: In func­tion ‘E0000’:
    dcdflib.c:6410:5: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    dcdflib.c:6434:5: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    dcdflib.c:6475:5: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    dcdflib.c: In func­tion ‘E0001’:
    dcdflib.c:6877:5: warn­ing: sug­gest paren­the­ses around ‘&&’ within ‘||’
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c ipm­par.
    c –o ipmpar.o
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c mcmc.c
    –o mcmc.o
    mcmc.c: In func­tion ‘Allocate_​Memory’:
    mcmc.c:76:10: warn­ing: unused vari­able ‘j’
    mcmc.c:76:7: warn­ing: unused vari­able ‘i’
    mcmc.c: In func­tion ‘Read_​In_​Prior’:
    mcmc.c:152:7: warn­ing: unused vari­able ‘i’
    mcmc.c: In func­tion ‘Init_​Output’:
    mcmc.c:168:7: warn­ing: unused vari­able ‘i’
    mcmc.c: In func­tion ‘mui’:
    mcmc.c:186:18: warn­ing: unused vari­able ‘step’
    mcmc.c:186:14: warn­ing: unused vari­able ‘up’
    mcmc.c:186:9: warn­ing: unused vari­able ‘low’
    mcmc.c:185:10: warn­ing: unused vari­able ‘k’
    mcmc.c: In func­tion ‘fhA’:
    mcmc.c:433:25: warn­ing: unused vari­able ‘t’
    mcmc.c: In func­tion ‘den­sPhi’:
    mcmc.c:561:30: warn­ing: unused vari­able ‘step’
    mcmc.c:561:26: warn­ing: unused vari­able ‘up’
    mcmc.c:561:21: warn­ing: unused vari­able ‘low’
    mcmc.c: In func­tion ‘densPhiQ1’:
    mcmc.c:599:30: warn­ing: unused vari­able ‘step’
    mcmc.c:599:26: warn­ing: unused vari­able ‘up’
    mcmc.c:599:21: warn­ing: unused vari­able ‘low’
    mcmc.c: In func­tion ‘gibbs’:
    mcmc.c:775:14: warn­ing: unused vari­able ‘i’
    mcmc.c: At top level:
    cdflib.h:45:13: warn­ing: ‘E0000’ declared ‘sta­tic’ but never defined
    cdflib.h:52:13: warn­ing: ‘E0001’ declared ‘sta­tic’ but never defined
    mcmc.c: In func­tion ‘densPhiQ1’:
    mcmc.c:599:43: warn­ing: ‘m_​p’ may be used unini­tial­ized in this func­tion
    mcmc.c:599:48: warn­ing: ‘s_​p’ may be used unini­tial­ized in this func­tion
    mcmc.c: In func­tion ‘fAC’:
    mcmc.c:472:36: warn­ing: ‘ha’ may be used unini­tial­ized in this func­tion
    mcmc.c:472:40: warn­ing: ‘ma’ may be used unini­tial­ized in this func­tion
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c net­work
    s.c –o networks.o
    networks.c: In func­tion ‘Get_​Distance’:
    networks.c:68:14: warn­ing: unused vari­able ‘d2’
    networks.c: At top level:
    cdflib.h:45:13: warn­ing: ‘E0000’ declared ‘sta­tic’ but never defined
    cdflib.h:52:13: warn­ing: ‘E0001’ declared ‘sta­tic’ but never defined
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c pro­file
    .c –o profile.o
    cdflib.h:45:13: warn­ing: ‘E0000’ declared ‘sta­tic’ but never defined
    cdflib.h:52:13: warn­ing: ‘E0001’ declared ‘sta­tic’ but never defined
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c rand.c
    –o rand.o
    rand.c:15:0: warn­ing: ignor­ing #pragma warn­ing
    rand.c: In func­tion ‘pdf_​norm_​trunc’:
    rand.c:221:10: warn­ing: unused vari­able ‘u’
    rand.c: At top level:
    cdflib.h:45:13: warn­ing: ‘E0000’ declared ‘sta­tic’ but never defined
    cdflib.h:52:13: warn­ing: ‘E0001’ declared ‘sta­tic’ but never defined
    rand.c:4:13: warn­ing: ‘is1’ defined but not used
    rand.c:4:28: warn­ing: ‘is2’ defined but not used
    rand.c:5:12: warn­ing: ‘set’ defined but not used
    rand.c: In func­tion ‘mvnS_​rand’:
    rand.c:512:5: warn­ing: ‘det_​half’ is used unini­tial­ized in this func­tion
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c splines
    .c –o splines.o
    splines.c: In func­tion ‘spline_​value’:
    splines.c:114:9: warn­ing: pass­ing argu­ment 1 of ‘REAL’ from incom­pat­i­ble pointer
    type
    C:/PROGRA~1/R/R-212~1.2/include/Rinternals.h:382:10: note: expected ‘SEXP’ but a
    rgu­ment is of type ‘dou­ble *‘
    gcc –I“C:/PROGRA~1/R/R-212~1.2/include” –O3 –Wall –std=gnu99 –c util.c
    –o util.o
    util.c: In func­tion ‘d_​chol_​decomp’:
    util.c:72:3: warn­ing: implicit dec­la­ra­tion of func­tion ‘dpotrf_​’
    util.c: In func­tion ‘cma­trix’:
    util.c:121:10: warn­ing: unused vari­able ‘j’
    util.c: In func­tion ‘qr_​solve’:
    util.c:506:5: warn­ing: implicit dec­la­ra­tion of func­tion ‘dqrdc2_​’
    util.c:521:5: warn­ing: implicit dec­la­ra­tion of func­tion ‘dqrcf_​’
    util.c:485:11: warn­ing: unused vari­able ‘vmax’
    util.c: In func­tion ‘inverse’:
    util.c:544:9: warn­ing: unused vari­able ‘j’
    util.c: In func­tion ‘invtr’:
    util.c:680:3: warn­ing: implicit dec­la­ra­tion of func­tion ‘dtrtri_​’
    util.c: At top level:
    util.c:787:1: warn­ing: “/​*” within com­ment
    util.c:788:1: warn­ing: “/​*” within com­ment
    util.c:789:1: warn­ing: “/​*” within com­ment
    util.c:790:1: warn­ing: “/​*” within com­ment
    util.c:791:1: warn­ing: “/​*” within com­ment
    util.c:792:1: warn­ing: “/​*” within com­ment
    util.c:793:1: warn­ing: “/​*” within com­ment
    util.c: In func­tion ‘slice’:
    util.c:816:3: warn­ing: sug­gest paren­the­ses around com­par­i­son in operand of ‘&
    util.c:825:3: warn­ing: sug­gest paren­the­ses around com­par­i­son in operand of ‘&
    util.c: In func­tion ‘r_​gauss’:
    util.c:948:10: warn­ing: unused vari­able ‘j’
    util.c: In func­tion ‘mor­al­ize’:
    util.c:1040:5: warn­ing: com­par­isons like ‘X<=Y

  • Roger

    I am sorry that my com­ment was too long and some dos results are miss­ing. The rest dos results are here(The error is shown in the last line):

    util.c:1040:5: warn­ing: state­ment with no effect
    util.c: In func­tion ‘min’:
    util.c:858:1: warn­ing: con­trol reaches end of non-​​void func­tion
    gcc –shared –s –static-​​libgcc –o curves2.dll tmp.def dcdflib.o ipmpar.o mcmc.o n
    etworks.o profile.o rand.o splines.o util.o –LC:/PROGRA~1/R/R-212~1.2/bin/i386 -
    lR
    util.o:util.c:(.text+0x221): unde­fined ref­er­ence to ‘dpotrf_​’
    util.o:util.c:(.text+0x1189): unde­fined ref­er­ence to ‘dtrtri_​’
    collect2: ld returned 1 exit sta­tus
    ERROR: com­pi­la­tion failed for pack­age ‘curves2’
    * remov­ing ‘C:/Users/z4432045/AppData/Local/Temp/RtmpGRtc6x/Rinst2e7d684a/curves
    2′
    ERROR
    Instal­la­tion failed

    C:\Users\z4432045>

    • http://robjhyndman.com Rob J Hyndman

      When the pack­age does not install, almost always the error mes­sages pro­vided will tell you why. You need to read them. All those warn­ings point to prob­lems in your C code.

  • Tim

    Dear Sir,

    thank you for the sum­mary pro­vided above,
    I still expe­ri­ence a tech­ni­cal difficulty.

    I installed the pack­age author ver­sion and the installer mod­i­fied the path.

    I cre­ated a direc­tory C: MyR­pack­ages
    in this direc­tory is the folder “LGP data” as cre­ated by R skeleton-​​function.

    I made sure i was in this direc­tory, unfor­tu­nate­ley when using the “Rcmd build –binary LGP data” com­mand it does not rec­og­nize the command.

    Some­one in the above com­ments also had this trou­ble, but i did check the path as you rec­om­mended.
    If I type path in the DOS com­mand win­dow it gives the following:“PATH=c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;C:WINDOWS\system32;C:WINDOWS;C:WINDOWS\System32\Wbem“
    I think this is what it should say, no ?

    Any help would be much appreciated,

    Thanks in advance

    • http://robjhyndman.com Rob J Hyndman

      Your path does not include where the R binary files are stored.

      • Tim

        My apolo­gies, I over­looked that.

        Thanks for your help & patience with stu­pid ques­tions
        :-)

        It works fine now

        Kind Regards

  • Nipesh Bajaj

    Dear sir, I am also hav­ing prob­lem in build­ing my package

    1. I have cre­ated a folder in C, nam­ing R_​PackageBuild
    2. In R con­sole I sup­plied fol­low­ing codes:
    > setwd(“c:/R_packageBuild”)
    > package.skeleton(“trial1”,namespace = TRUE, code_​files = “f:/trial.r”)

    Now a folder nam­ing ‘trial1’ has been cre­ated with all pack­age infor­ma­tion. I have mod­i­fied the ‘man’ folder.

    Now I opened cmd. There I have writ­ten fol­low­ings:
    cd C:\R_PackageBuild
    Rcmd build –binary trial1

    But fol­low­ing error pop up:
    Error: unex­pected sym­bol in “tools:::.test_load_package(‘trial1’,.…)“
    Exe­cu­tion halted
    ERROR: load­ing failed

    Can you please favor me some sug­ges­tion how can I fix this error.

    Thank you very much for your time.

    • http://robjhyndman.com Rob J Hyndman

      It looks like there is a weird sym­bol in your pack­age. Most likely you haven’t com­pleted edit­ing the Rd files.

      • Nipesh Bajaj

        Thanks Rob for your point. How­ever still I could not find out where I have done wrong. In file code_​files (i.e. the ‘trial.r’ file), there is only a func­tion:
        fn1 <- Vectorize(function(x,y,z) {
        return(x + y +z)
        }, SIMPLIFYTRUE)

        Once I run the package.skeleton() func­tion, it cre­ates a folder with name trial1, in the work­ing direc­tory. There is man folder and inside that folder there are 2 files with name, ‘fn1’ & ‘trial1-​​package’. I have mod­i­fied the con­tents of those 2 files as follows:

        ****************** for ‘fn1’:
        \name{fn1}
        \alias{fn1}

        \title{
        A func­tion.
        }

        \descrip­tion{
        A func­tion.
        }

        \usage{
        A func­tion.
        }

        \argu­ments{
        A func­tion.
        }

        \value{
        A func­tion.
        }

        \author{
        \bold{Me}
        \cr
        \email{​Me@​me.​com}
        }

        ****************** for trial1-​​package:
        \name{trial1-package}
        \alias{trial1-package}
        \alias{trial1}
        \docType{package}
        \title{
        This is the pack­age.
        }
        \descrip­tion{
        this is the pack­age.
        }

        I put both con­tents in the sim­plest form because at this point, I just need to build a simple-​​most pack­age, as it is my 1st attempt.

        Can you please tell me where I have done wrong?

        Thanks for your time.

        • http://robjhyndman.com Rob J Hyndman

          I’ve no idea. This is not an R help service.

          • Nipesh Bajaj

            okay, no probs

  • Krusty The Klown

    Hi, I’m fac­ing some prob­lems with build­ing an R pack­age under Win­dows 7. When I check the pack­age, this is the mes­sage from MS Dos:

    Warn­ing mes­sage:
    In normalizePath(path.expand(path), winslash, must­Work) :
    path[1]=“C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    Warn­ing in normalizePath(path.expand(path), winslash, must­Work) :
    path[1]=“C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    Warn­ing in normalizePath(path.expand(path), winslash, must­Work) :
    path[2]=“C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    * installing *source* pack­age ‘ForImp’ …
    Error in normalizePath(path.expand(path), winslash, must­Work) :
    path[1]=”./DESCRIPTION”: Accesso negato
    ERROR: installing pack­age DESCRIPTION failed for pack­age ‘ForImp’
    * remov­ing ‘C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck/ForImp’

    Any idea on what it means?

    Thanks,
    KtK

    • Krusty The Klown

      Guys, I’ve solved the prob­lem! They were due to… the non-​​operative Win­dows 7 sys­tem (a mat­ter of paths & their trans­la­tion from Eng­lish to Ital­ian).
      Thx,
      KtK

  • http://stevemosher.wordpress.com Steven Mosher

    Thanks for all your help. I used your instruc­tions to build my first pack­age ( see my blog) and I’m slowly slouch­ing toward sub­mit­ting to CRAN. I have a few ques­tions. I’ve read all the man­u­als, some­times they are a bit dense, so here are my questions.

    1. I get warn­ings about data objects that are present in the man­ual but not in the code. They dont need to be in the code. how do I remove them, or will CRAN accept with warnings?

    2. I built for win 64, how do I build for both 32 and 64. My pack­age is pure R, no other source

    3. I want to include demos. This entails a demo folder and an 00index file. Where do I put that index file?

    I’ve also got some ques­tions about sub­mit­ting to CRAN, but for now lets look at those.

    • http://stevemosher.wordpress.com Steven Mosher

      Well, I answered some of my questions.

      1. When R builds a .Rd file for a data object they put the fol­low­ing in for usage \usage{data(yourObject)}
      That causes a warn­ing. \usage{yourObject} fixes that.
      Not sure why that is. Per­haps because I had lazy­Data set to FALSE.

      2. no answer yet

      3. the 00Index file goes in the ‘demo’ sub­di­rec­tory.
      the “name” of the demo should not have an R extension.

      • http://robjhyndman.com Rob J Hyndman

        CRAN won’t accept a pack­age if there are any warn­ings, so you need to fix them.

        1. I don’t under­stand why your change would fix the prob­lem, or why there would be a prob­lem with \usage{data(yourObject)}. That’s what I use in my Rd files for data objects. I also use lazy­Data set to “yes”.

        2. You don’t need to worry about it. CRAN will build for all oper­at­ing sys­tems. Just upload the tar.gz file to the CRAN incom­ing direc­tory. (That is, not the binary build.)

        3. I’ve never put demos in my pack­ages, so I don’t know.

  • Ludo

    just came across this post, liked it. But the link to Rtools seems out­dated. It is now on CRAN; eg. http://​cran​.freesta​tis​tics​.org/​b​i​n​/​w​i​n​d​o​w​s​/​R​t​ools/

    • http://robjhyndman.com Rob J Hyndman

      Thanks Ludo. The link is now fixed.

  • Maria Antoni­etta

    Hi,
    I have a prob­lem when i exe­cute the com­mand “R CMD check”. You can see the fol­low­ing error log that this com­mand returns to me:

    * check­ing PDF ver­sion of man­ual … WARNING
    LaTeX errors when cre­at­ing PDF ver­sion.
    This typ­i­cally indi­cates Rd prob­lems.
    LaTeX errors found:
    ! LaTeX Error: File ‘inconsolata.sty’ not found.

    Type X to quit or to pro­ceed,
    or enter new name. (Default exten­sion: sty)

    ! Emer­gency stop.

            
    l.267
          
    !  ==> Fatal error occurred, no out­put PDF file pro­duced!
    * check­ing PDF ver­sion of man­ual with­out hyper­refs or index … ERROR

    And the check is stopped. My ques­tions is: what is “inconsolata.sty” ?
    Maybe i beliew that this prob­lem is con­nected to the R ver­sion (now is installed R-2.14.1 or R-2.14.2) that is installed to my pc. Infact in another pc which is installed R-2.8.1, there isn’t this prob­lem and the pack­age is cre­ated succesfully.

    I hope that you can help me ^_^

    mery

  • Maria Antoni­etta

    Hi,
    at the end I found the solu­tions to my prob­lem. I must install the incon­so­lata pack­age from the “MIK­tex Pack­age Man­ager”: Start in the Start Menu item for Mik­TeX 2.8,

    and find the “pack­age man­ager” item.  Run it, and choose to install the

    incon­so­lata” package.Now, the check is OK!!
    Bye,
    mery

  • cmmm7031

    Hi,

    How  Upload the tar.gz le to
    ftp://​CRAN​.​R​-project​.org/​i​n​c​oming?
    Carlos

    • http://robjhyndman.com Rob J Hyndman

      Use ftp soft­ware such as FileZilla

  • cmmm7031

    Thank you, Rob

    Help me, please

    What happened?[To Par­ent Direc­tory]
    19.04.2012 03:02 2632 00check.log
    19.04.2012 03:02 406 00install.out
    19.04.2012 03:02 examples_​and_​tests
    19.04.2012 03:02 117515 TestSurvRec_1.0.zipHow, Do I sub­mis­sion “my pack­age” in CRAN incom­ing?
    what is the procedure?

  • Pingback: How to create R extensions / packages [resources] | Pairach Piboonrungroj

  • Josh Bow­den

    Hi,
    How do I link to spe­cific win­dows libraries? I want to include a Lapack func­tion from Intel MKL, for exam­ple dge­qrf(). What lines would I need in the Makevars.win file (and do I need Linux libraries or Win­dows DLLs or sta­tic libs?

    • Josh Bow­den

      Looks like I found an answer that works:
      – Use Win­dows librarys.- Add some­thing like the fol­low­ing for using Intel MKL to Makevars.win :PKG_​LIBS = (shell "{R_HOME}/bin{R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")  -L(MKLROOT)/lib/ia32   –lmkl_​rtPKG_​CPPFLAGS = –m32 –I
      (MKLROOT)/include(although, I put in the full path instead of(MKLROOT)Compile with R CMD INSTALL…Quite sim­ple once you have got rid of  the 300 other possibilities.

  • Pingback: R CMD on Windows 7 Error – “R” is not recognized as an internal or external command, | PHP Developer Resource

  • Pingback: R CMD on Windows 7 Error – "R" is not recognized as an internal or external command,

  • Pingback: R « Zhenglei

  • Dis­sanayake

    how to clean up new r pack­age by ;‘rm rf .….’

  • Narges Sharafodin

    thank you so much for your com­mands. I just encounter a prob­lem while installing a pack­age named ‘emmixskew_1.0.16.tar’, the error is:
    com­pi­la­tion failed for pack­age ‘emmixskew’.
    please tell me what’s wrong