Building R packages for Windows

1. Installing the required tools

To build an R package in Windows, you will need to install some additional software tools. These are summarized at

http://cran.r-project.org/bin/windows/Rtools/

1.1 Essential: Rtools

This is a collection of unix-like tools that can be run from the DOS command prompt. It also contains the MinGW compilers that are used for compiling Fortran and C code. You should download and run the version corresponding to the flavour of R you are using. When asked, choose the default “Package authoring installation” to build add-on packages.

1.2 Optional: MikTeX

MikTeX is used for producing the pdf help files. You can produce an R package without it, but the package will not contain pdf help files. Most of you will have this installed anyway. Download from

http://www.miktex.org

1.3 Essential: Setting PATH variable

The PATH variable tells Windows where to find the relevant programs. To add a directory to your PATH on Windows select

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

The path variable may have already been fixed in step 1.1. In any case, you should check that it looks something like this:

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

The last directory will depend on whether you have a 32-bit or 64-bit operating system. It should be the directory that contains the file Rcmd.exe

  • The precise directories will depend where you have installed the various tools. The above path should work if you have followed the default installation procedure. If the directory names contain spaces, put them in quotation marks.
  • I have assumed R2.15.1. For later versions, simply change the above paths to the relevant R version. It will probably then still work.
  • If there are problems, please read the Rtools.txt file carefully.

2 Creating the package

Information about creating packages is provided in the document “Writing R extensions” (available under the R Help menu) or at

http://cran.r-project.org/doc/manuals/R-exts.html

The main items are summarized below to get you started, but you will almost certainly need to consult the above document if you are to successfully compile a package.

2.1 Use package.skeleton()

The simplest way to create a package is to first create an R workspace containing all the relevant functions and data sets that you want to include in the package. Delete anything from the workspace that you do not want to include in the package. Make sure the current directory is set to whereever you want create the package. Use

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

for example. Then, to create a package called "fred", use the R command

package.skeleton(name="fred")

This will generate a directory fred and several sub-directories in the required structure.

2.2 Editing the files

A package consists of a directory containing a file ‘DESCRIPTION’ and usually has the subdirectories R, data and man. The package directory should be given the same name as the package. The package.skeleton command above will have created these files for you. You now need to edit them so they contain the right information.

2.3 DESCRIPTION file

The DESCRIPTION file contains basic information about the package in the following 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 function and data set are given in “R documentation” (Rd) files in the man subdirectory. These are in a simple markup language closely resembling LaTeX, which can be processed into a variety of formats, including LaTeX, HTML and plain text. As an example, here is the file which documents the function 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 instructions for writing R documentation are at

http://cran.r-project.org/doc/manuals/R-exts.html#Writing-R-documentation-files

2.5 Including C or Fortran code

If your R code calls C or Fortran functions, the source code for these functions needs to be placed in the subdirectory src under fred.

2.6 Compiling the package for Windows

To compile the package into a zip file, go to a DOS prompt in the directory containing your package. (i.e., the directory "C:\My Documents\Rpackages" in the above example. Then type

Rcmd INSTALL --build fred

This will compile all the necessary information and create a zip file which should be ready to load in R.

2.7 Checking the package

To check that the package satisfies the requirements for a CRAN package, use

Rcmd check fred

The checks are quite strict. A package will often work ok even if it doesn’t pass these tests. But it is good practice to build packages that do satisfy these tests as it may save problems later.

2.8 Building a package for other operating systems

To build a package for something other than a Windows computer, use

Rcmd build fred

This creates a tar.gz file which can then be installed on a non-Windows computer. It can also be uploaded to CRAN provided it satisfies the above tests.


Related Posts:


  • Steve

    Rob, thanks for posting this but I am still struggling to make your example 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 chapter ‘Writing R documentation’ in manual ‘Writing R Extensions’.
    * removing ‘C:/Users/eick/AppData/Local/Temp/Rinst1284800485/fred’
    ERROR
    * installation failed

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

    • http://robjhyndman.com Rob J Hyndman

      It sounds like some kind of problem with your Rd files rather than with the software needed to build a package for Windows. build without –binary is just zipping up your directory and not processing any files.

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

    I recommended this post on R-help as being useful. Uwe Ligges rightly pointed out there have been changes since R-2.10.0:

    ” … these instructions are outdated since there is no chm help
    support 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 package on UNIX, and it did not work in Windows. I tried to build R package using above steps.

    But there is no RCMD command on DOS prompt , it show it is not recognized as internal or external command.

    Do you know the reason? My PC os is windows7. Thanks

    • http://robjhyndman.com Rob J Hyndman

      If Rcmd is not recognized at the DOS prompt then you don’t have the path to the R bin directory set up properly (step 1.3). Type “path” at the DOS prompt and check that the directory is listed.

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

        Thank you for your useful comments. I did all steps respectively to build package with name: mypkg
        I instal Rtools and MikTeX 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 Command 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 recogonized as an internal or external command, operable program or batch file.

        I need your help to make package, I have some functions that want to convert them in package. I need your help, if it is possible, 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 provide general help on all things related to R and DOS. Try reading a manual.

  • alex

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

    I cannot find it either , I changed path in way as above.

    Do you have suggestion? Thanks.

    have a good day!

  • alex

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

  • mery

    i have a question.
    when i run R CMD check mypackage, it showed “Installation failed” when it is checking whether package “mypackage” can be installed…ERROR

    • http://robjhyndman.com Rob J Hyndman

      You need to read the rest of the output to figure out what the error is. Try closing R and make sure nothing else is accessing the relevant directory.

  • mery

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

  • mery

    sorry i’ve another problem when i checked mypackage:

    it showed “Found possibly globabl ‘T’ or ‘F’ in the following functios: A, B, C” when it is checking R code for possible errors….NOTE

    • http://robjhyndman.com Rob J Hyndman

      Try reading the manuals.

  • Lxmi

    Hi,
    When I was doing R CMD check mypackage I got an error saying that :
    checking whether the package can be loaded: ERROR
    Error in library(test): there is no package called ‘test’
    Execution halted
    It looks like this package has a loading problem … ”

    Any help is appreciated.
    Thanks in advance..
    –Lxmi

  • Jane

    Hi,
    Thank you for this summary page!
    I have a package I was previously able to compile and use for R 2.6.
    In the newer versions of R it did not work, so I am making it from scratch using Rtools and new R version.

    However, I keep getting error after Rcmd build –binary mypack

    * checking for file ‘mypack/DESCRIPTION’ … OK
    * preparing ‘mypack’:
    * checking DESCRIPTION meta-information … OK
    * removing junk files
    * checking for LF line-endings in source and make files
    * checking for empty or unneeded directories
    * building binary distribution
    * installing *source* package ‘mypack’ …
    ** R
    ** preparing package for lazy loading
    ** help
    Warning: ./man/mypack-package.Rd:34: All text must be in a section
    Warning: ./man/mypack-package.Rd:35: All text must be in a section
    *** installing help indices
    ** building package indices …
    ** testing if installed package can be loaded
    gdata: read.xls support for ‘XLS’ (Excel 97-2004) files ENABLED.

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

    gdata: Run the function ‘installXLSXsupport()’
    gdata: to automatically download and install the perl
    gdata: libaries needed to support Excel XLS and XLSX formats.
    Error in winMenuAdd(menuname, NULL, NULL) :
    Menu functions can only be used in the GUI
    ERROR: loading failed
    * removing ‘C:/DOCUME~1/…/mypack’
    ERROR
    * installation failed

    • http://robjhyndman.com Rob J Hyndman

      Jane. Read the error message. It helpfully says to run the function installXLSXsupport() from the gdata package in order to complete its installation.

  • Jane

    These are just warnings.
    The error comes from:
    Error in winMenuAdd(menuname, NULL, NULL) :
    Menu functions can only be used in the GUI

    Thanks!

  • Vishal Gokhale

    Thanks for the page.
    It helped me to avoid restarting the machine in Ubuntu every time I wanted to make a code change to debug a certain piece of code.
    However I noticed that running just below command results into an error
    ——————————————
    >package.skeleton(name=”fred”)
    Error in !have : invalid argument type
    ——————————————
    Using the command (below) instead works
    You might want to change just that bit to make it perfect :)
    ————————————————————–
    >package.skeleton(name = “fred”, environment = .GlobalEnv, path = “.”, force = FALSE, namespace = FALSE)
    Creating directories …
    Creating DESCRIPTION …
    Creating Read-and-delete-me …
    Saving functions and data …
    Making help files …
    Done.
    Further steps are described in ‘./fred/Read-and-delete-me’.
    ———————————————————————

    • http://robjhyndman.com Rob J Hyndman

      Your additional arguments are just the defaults, so this should not make any difference. I suspect there is another problem, but it is not obvious from the error what it might be.

  • Roger

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

    I followed all the steps outlined here, however, I still got some problems when I try to enter the dos commands.

    If I entered “Rcmd build curves2”, everything is fine, and the package can be installed in R in Mac.
    However, if I entered “Rcmd build –binary curves2”. There seems to be one error. (Though I can still see one package appear after this command is run, however, it’s not installable in R under windows)
    Could you please help me out of this? Thanks so much~~

    The dos results are as follows:

    C:\Users\z4432045>Rcmd build –binary curves2
    * checking for file ‘curves2/DESCRIPTION’ … OK
    * preparing ‘curves2’:
    * checking DESCRIPTION meta-information … OK
    * cleaning src
    * checking whether ‘INDEX’ is up-to-date …Warning in readLines(oldindex) : inc
    omplete final line found on ‘INDEX’
    NO
    * use ‘–force’ to remove the existing ‘INDEX’
    cygwin warning:
    MS-DOS style path detected: C:/Users/z4432045/curves2_1.0.1.tar
    Preferred POSIX equivalent is: /cygdrive/c/Users/z4432045/curves2_1.0.1.tar
    CYGWIN environment variable option “nodosfilewarning” turns off this warning.
    Consult the user’s guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    cygwin warning:
    MS-DOS style path detected: C:/Users/z4432045/curves2_1.0.1.tar
    Preferred POSIX equivalent is: /cygdrive/c/Users/z4432045/curves2_1.0.1.tar
    CYGWIN environment variable option “nodosfilewarning” turns off this warning.
    Consult the user’s guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    * checking for LF line-endings in source and make files
    * checking for empty or unneeded directories
    * building binary distribution
    * installing *source* package ‘curves2’ …

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

    ** libs
    cygwin warning:
    MS-DOS style path detected: C:/PROGRA~1/R/R-212~1.2/etc/i386/Makeconf
    Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-212~1.2/etc/i386/Makec
    onf
    CYGWIN environment variable option “nodosfilewarning” turns off this warning.
    Consult the user’s guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c dcdflib
    .c -o dcdflib.o
    dcdflib.c: In function ‘cdfbin’:
    dcdflib.c:1889:5: warning: suggest parentheses around ‘&&’ within ‘||’
    dcdflib.c: In function ‘cdfgam’:
    dcdflib.c:3551:9: warning: suggest parentheses around ‘&&’ within ‘||’
    dcdflib.c: In function ‘E0000’:
    dcdflib.c:6410:5: warning: suggest parentheses around ‘&&’ within ‘||’
    dcdflib.c:6434:5: warning: suggest parentheses around ‘&&’ within ‘||’
    dcdflib.c:6475:5: warning: suggest parentheses around ‘&&’ within ‘||’
    dcdflib.c: In function ‘E0001’:
    dcdflib.c:6877:5: warning: suggest parentheses around ‘&&’ within ‘||’
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c ipmpar.
    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 function ‘Allocate_Memory’:
    mcmc.c:76:10: warning: unused variable ‘j’
    mcmc.c:76:7: warning: unused variable ‘i’
    mcmc.c: In function ‘Read_In_Prior’:
    mcmc.c:152:7: warning: unused variable ‘i’
    mcmc.c: In function ‘Init_Output’:
    mcmc.c:168:7: warning: unused variable ‘i’
    mcmc.c: In function ‘mui’:
    mcmc.c:186:18: warning: unused variable ‘step’
    mcmc.c:186:14: warning: unused variable ‘up’
    mcmc.c:186:9: warning: unused variable ‘low’
    mcmc.c:185:10: warning: unused variable ‘k’
    mcmc.c: In function ‘fhA’:
    mcmc.c:433:25: warning: unused variable ‘t’
    mcmc.c: In function ‘densPhi’:
    mcmc.c:561:30: warning: unused variable ‘step’
    mcmc.c:561:26: warning: unused variable ‘up’
    mcmc.c:561:21: warning: unused variable ‘low’
    mcmc.c: In function ‘densPhiQ1’:
    mcmc.c:599:30: warning: unused variable ‘step’
    mcmc.c:599:26: warning: unused variable ‘up’
    mcmc.c:599:21: warning: unused variable ‘low’
    mcmc.c: In function ‘gibbs’:
    mcmc.c:775:14: warning: unused variable ‘i’
    mcmc.c: At top level:
    cdflib.h:45:13: warning: ‘E0000’ declared ‘static’ but never defined
    cdflib.h:52:13: warning: ‘E0001’ declared ‘static’ but never defined
    mcmc.c: In function ‘densPhiQ1’:
    mcmc.c:599:43: warning: ‘m_p’ may be used uninitialized in this function
    mcmc.c:599:48: warning: ‘s_p’ may be used uninitialized in this function
    mcmc.c: In function ‘fAC’:
    mcmc.c:472:36: warning: ‘ha’ may be used uninitialized in this function
    mcmc.c:472:40: warning: ‘ma’ may be used uninitialized in this function
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c network
    s.c -o networks.o
    networks.c: In function ‘Get_Distance’:
    networks.c:68:14: warning: unused variable ‘d2’
    networks.c: At top level:
    cdflib.h:45:13: warning: ‘E0000’ declared ‘static’ but never defined
    cdflib.h:52:13: warning: ‘E0001’ declared ‘static’ but never defined
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c profile
    .c -o profile.o
    cdflib.h:45:13: warning: ‘E0000’ declared ‘static’ but never defined
    cdflib.h:52:13: warning: ‘E0001’ declared ‘static’ 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: warning: ignoring #pragma warning
    rand.c: In function ‘pdf_norm_trunc’:
    rand.c:221:10: warning: unused variable ‘u’
    rand.c: At top level:
    cdflib.h:45:13: warning: ‘E0000’ declared ‘static’ but never defined
    cdflib.h:52:13: warning: ‘E0001’ declared ‘static’ but never defined
    rand.c:4:13: warning: ‘is1’ defined but not used
    rand.c:4:28: warning: ‘is2’ defined but not used
    rand.c:5:12: warning: ‘set’ defined but not used
    rand.c: In function ‘mvnS_rand’:
    rand.c:512:5: warning: ‘det_half’ is used uninitialized in this function
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c splines
    .c -o splines.o
    splines.c: In function ‘spline_value’:
    splines.c:114:9: warning: passing argument 1 of ‘REAL’ from incompatible pointer
    type
    C:/PROGRA~1/R/R-212~1.2/include/Rinternals.h:382:10: note: expected ‘SEXP’ but a
    rgument is of type ‘double *’
    gcc -I”C:/PROGRA~1/R/R-212~1.2/include” -O3 -Wall -std=gnu99 -c util.c
    -o util.o
    util.c: In function ‘d_chol_decomp’:
    util.c:72:3: warning: implicit declaration of function ‘dpotrf_’
    util.c: In function ‘cmatrix’:
    util.c:121:10: warning: unused variable ‘j’
    util.c: In function ‘qr_solve’:
    util.c:506:5: warning: implicit declaration of function ‘dqrdc2_’
    util.c:521:5: warning: implicit declaration of function ‘dqrcf_’
    util.c:485:11: warning: unused variable ‘vmax’
    util.c: In function ‘inverse’:
    util.c:544:9: warning: unused variable ‘j’
    util.c: In function ‘invtr’:
    util.c:680:3: warning: implicit declaration of function ‘dtrtri_’
    util.c: At top level:
    util.c:787:1: warning: “/*” within comment
    util.c:788:1: warning: “/*” within comment
    util.c:789:1: warning: “/*” within comment
    util.c:790:1: warning: “/*” within comment
    util.c:791:1: warning: “/*” within comment
    util.c:792:1: warning: “/*” within comment
    util.c:793:1: warning: “/*” within comment
    util.c: In function ‘slice’:
    util.c:816:3: warning: suggest parentheses around comparison in operand of ‘&’
    util.c:825:3: warning: suggest parentheses around comparison in operand of ‘&’
    util.c: In function ‘r_gauss’:
    util.c:948:10: warning: unused variable ‘j’
    util.c: In function ‘moralize’:
    util.c:1040:5: warning: comparisons like ‘X<=Y

  • Roger

    I am sorry that my comment was too long and some dos results are missing. The rest dos results are here(The error is shown in the last line):

    util.c:1040:5: warning: statement with no effect
    util.c: In function ‘min’:
    util.c:858:1: warning: control reaches end of non-void function
    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): undefined reference to `dpotrf_’
    util.o:util.c:(.text+0x1189): undefined reference to `dtrtri_’
    collect2: ld returned 1 exit status
    ERROR: compilation failed for package ‘curves2’
    * removing ‘C:/Users/z4432045/AppData/Local/Temp/RtmpGRtc6x/Rinst2e7d684a/curves
    2’
    ERROR
    Installation failed

    C:\Users\z4432045>

    • http://robjhyndman.com Rob J Hyndman

      When the package does not install, almost always the error messages provided will tell you why. You need to read them. All those warnings point to problems in your C code.

  • Tim

    Dear Sir,

    thank you for the summary provided above,
    I still experience a technical difficulty.

    I installed the package author version and the installer modified the path.

    I created a directory C: MyRpackages
    in this directory is the folder “LGP data” as created by R skeleton-function.

    I made sure i was in this directory, unfortunateley when using the “Rcmd build –binary LGP data” command it does not recognize the command.

    Someone in the above comments also had this trouble, but i did check the path as you recommended.
    If I type path in the DOS command window 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 apologies, I overlooked that.

        Thanks for your help & patience with stupid questions

        :-)

        It works fine now

        Kind Regards

  • Nipesh Bajaj

    Dear sir, I am also having problem in building my package

    1. I have created a folder in C, naming R_PackageBuild
    2. In R console I supplied following codes:
    > setwd(“c:/R_packageBuild”)
    > package.skeleton(“trial1”,namespace = TRUE, code_files = “f:/trial.r”)

    Now a folder naming ‘trial1’ has been created with all package information. I have modified the ‘man’ folder.

    Now I opened cmd. There I have written followings:
    cd C:\R_PackageBuild
    Rcmd build –binary trial1

    But following error pop up:
    Error: unexpected symbol in “tools:::.test_load_package(‘trial1’,….)”
    Execution halted
    ERROR: loading failed

    Can you please favor me some suggestion 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 symbol in your package. Most likely you haven’t completed editing the Rd files.

      • Nipesh Bajaj

        Thanks Rob for your point. However 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 function:
        fn1 <- Vectorize(function(x,y,z) {
        return(x + y +z)
        }, SIMPLIFY = TRUE)

        Once I run the package.skeleton() function, it creates a folder with name trial1, in the working directory. There is man folder and inside that folder there are 2 files with name, 'fn1' & 'trial1-package'. I have modified the contents of those 2 files as follows:

        ****************** for 'fn1':
        \name{fn1}
        \alias{fn1}

        \title{
        A function.
        }

        \description{
        A function.
        }

        \usage{
        A function.
        }

        \arguments{
        A function.
        }

        \value{
        A function.
        }

        \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 package.
        }
        \description{
        this is the package.
        }

        I put both contents in the simplest form because at this point, I just need to build a simple-most package, 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 facing some problems with building an R package under Windows 7. When I check the package, this is the message from MS Dos:

    Warning message:
    In normalizePath(path.expand(path), winslash, mustWork) :
    path[1]=”C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]=”C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[2]=”C:/Programmi/R/R-2.13.0/src/library/ForImp.Rcheck”: Accesso negato
    * installing *source* package ‘ForImp’ …
    Error in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]=”./DESCRIPTION”: Accesso negato
    ERROR: installing package DESCRIPTION failed for package ‘ForImp’
    * removing ‘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 problem! They were due to… the non-operative Windows 7 system (a matter of paths & their translation from English to Italian).
      Thx,
      KtK

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

    Thanks for all your help. I used your instructions to build my first package ( see my blog) and I’m slowly slouching toward submitting to CRAN. I have a few questions. I’ve read all the manuals, sometimes they are a bit dense, so here are my questions.

    1. I get warnings about data objects that are present in the manual 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 package 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 questions about submitting 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 following in for usage \usage{data(yourObject)}
      That causes a warning. \usage{yourObject} fixes that.
      Not sure why that is. Perhaps because I had lazyData set to FALSE.

      2. no answer yet

      3. the 00Index file goes in the ‘demo’ subdirectory.
      the “name” of the demo should not have an R extension.

      • http://robjhyndman.com Rob J Hyndman

        CRAN won’t accept a package if there are any warnings, so you need to fix them.

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

        2. You don’t need to worry about it. CRAN will build for all operating systems. Just upload the tar.gz file to the CRAN incoming directory. (That is, not the binary build.)

        3. I’ve never put demos in my packages, so I don’t know.

  • Ludo

    just came across this post, liked it. But the link to Rtools seems outdated. It is now on CRAN; eg. http://cran.freestatistics.org/bin/windows/Rtools/

    • http://robjhyndman.com Rob J Hyndman

      Thanks Ludo. The link is now fixed.

  • Maria Antonietta

    Hi,
    I have a problem when i execute the command “R CMD check”. You can see the following error log that this command returns to me:

    * checking PDF version of manual … WARNING
    LaTeX errors when creating PDF version.
    This typically indicates Rd problems.
    LaTeX errors found:
    ! LaTeX Error: File `inconsolata.sty’ not found.

    Type X to quit or to proceed,
    or enter new name. (Default extension: sty)

    ! Emergency stop.

            
    l.267
          
    !  ==> Fatal error occurred, no output PDF file produced!
    * checking PDF version of manual without hyperrefs or index … ERROR

    And the check is stopped. My questions is: what is “inconsolata.sty” ?
    Maybe i beliew that this problem is connected to the R version (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 problem and the package is created succesfully.

    I hope that you can help me ^_^

    mery

  • Maria Antonietta

    Hi,
    at the end I found the solutions to my problem. I must install the inconsolata package from the “MIKtex Package Manager”: Start in the Start Menu item for MikTeX 2.8,

    and find the “package manager” item.  Run it, and choose to install the

    “inconsolata” package.Now, the check is OK!!
    Bye,
    mery

  • cmmm7031

    Hi,

    How  Upload the tar.gz le to
    ftp://CRAN.R-project.org/incoming?
    Carlos

    • http://robjhyndman.com Rob J Hyndman

      Use ftp software such as FileZilla

  • cmmm7031

    Thank you, Rob

    Help me, please

    What happened?[To Parent Directory]
    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 submission “my package” in CRAN incoming?
    what is the procedure?

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

  • Josh Bowden

    Hi,
    How do I link to specific windows libraries? I want to include a Lapack function from Intel MKL, for example dgeqrf(). What lines would I need in the Makevars.win file (and do I need Linux libraries or Windows DLLs or static libs?

    • Josh Bowden

      Looks like I found an answer that works:
      – Use Windows librarys.- Add something like the following 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 simple 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()

  • Dissanayake

    how to clean up new r package by ;’rm rf …..’

  • Narges Sharafodin

    thank you so much for your commands. I just encounter a problem while installing a package named ’emmixskew_1.0.16.tar’, the error is:
    compilation failed for package ’emmixskew’.
    please tell me what’s wrong

  • kanchana

    In maxima in order to load graphics if i use the comments load(graphics). I am getting error as loadfile: failed to load C: so and so. I am getting all others comments apart from this.