Ten Steps to Building an R package under Windows

If you’ve spent any amount of time working in R there comes a point when you want to create your own package in R.  I’ve switched back and forth between running R on my MAC and running it on Windows and I thought I’d give package development on Windows a try.  What I’ll try to do on these pages is document that process step by step for the raw beginner.

First off, I need to thank all the R experts who have help put all the tools and documentation in place. Without them none of this would be possible.

How to Build a Package in Windows

Use the guide below to jump to any section you want. I’ll take you through the entire process as I did it.

Step One:  Update your R and other Tools. We will start by updating our version of R and I’ll update my current version of RStudio. Neither of these steps are difficult and you can just skip this section as you should already be familiar with these types of tasks.

Step  Two: Get to know your Windows System

Step Three:  Decide which kind of package  you want to build

Step Four:  Get the tools

Step Five:   Installing the tools

Step Six:  Fixing your Path

Step Seven: Reboot and do some reading

Step Eight;  The Sample Package

Step Nine: Edit some files

Step Ten: Build

  1. David McKeever
    October 9, 2011 at 1:23 PM

    Very interesting and informative. I was wondering if you think that someone (like me) could download comma separated files (.csv) from a horse racing website that has data from past performances using your build steps. I would be interested in doing things like time series, and econometric techniques applied to horse racing. Any comments appreciated.

  2. steven mosher
    October 9, 2011 at 8:50 PM

    yes, but you dont need to build a package. Just get R and download the file

  3. Oleg M
    December 18, 2011 at 4:37 AM

    This is very helpful. I am making my first steps trying to build C code into my R programs. Most other places (like R documentation on CRAN) skip a lot of these, for example the nature of R CMD. Thank you Steve!

  4. Dinesh
    May 2, 2012 at 3:55 AM

    This is the best ever documentation for creating “R packages using Windows”. Simple and to the point. Thanks Steve. This was very helpful.

    • Steven Mosher
      May 2, 2012 at 3:57 AM

      you are welcomed. Let others know if they have problems

  5. January 18, 2013 at 2:40 PM

    Hello to every one, for the reason that I am really keen
    of reading this webpage’s post to be updated regularly. It includes nice information.

  6. July 16, 2013 at 10:12 PM

    Its such as you learn my mind! You seem to understand so much approximately
    this, such as you wrote the ebook in it or something.
    I think that you just could do with a few % to power the message house a little bit,
    but other than that, this is fantastic blog. An excellent read.
    I will definitely be back.

  7. October 18, 2013 at 8:10 PM

    Hi Steve, thanks for the tutorial. I followed your ways and edited the path carefully. However, when I ran “R CMD build mypkg” in command prompt, it said “C:\ Program is not recognized as an external….”. I tried to fix this problem by surfing online, but still got stuck on this. Do you have any idea on this. Thanks!!!

  8. October 27, 2013 at 8:13 AM

    Hi! I found your tutorial very useful. I am writing my dissertation about a package I published thanks to this tutorial. I will acknowledge your work on it. Thank you!

    • Steven Mosher
      October 28, 2013 at 2:04 AM

      Wow thank you

  9. March 20, 2014 at 10:09 PM

    Asking questions are really nice thing if you are not understanding something
    totally, but this paragraph presents fastidious understanding even.

  10. August 7, 2014 at 11:04 PM

    Because the discs are absorbing shock with movement, you would be in pain all day if your discs could cause you pain. They can either soak in a
    nice hot tub of water, or allow warm water from the shower
    to massage the sore area. Daily exercise is
    the key to avoid lower back pain left side or any other strains on your

  11. September 16, 2014 at 3:39 PM

    Nice offer. This offer is really attractive to all. personally I like it.
    windows 7 download

  12. October 6, 2014 at 7:10 PM

    Hey just wantewd to give you a quick heads up.
    The text in your article ssem too be running
    off thee screen in Chrome. I’m not sure if this is a formatting issuee or
    something to do with browser compatibility butt I thought I’d post to
    let you know. The deseign and style look great
    though! Hope you get thhe problem resolved soon. Cheers

  13. jjgasse
    May 25, 2015 at 3:28 PM

    Hello everyone, I would like to ask a question about the construction of a packae in R.
    The functions to be implemented in the package are supported of course other packages.
    How do I import the latter in my package? Excuse my ignorance but is the first time I approach the building of a package.
    Thanks in advance

  14. August 10, 2015 at 6:21 AM

    I too am getting ‘BUILD’ is not recognized as an internal or external command. Thank you for the tutorial but there is definitely missing information. My Environment path is correct. This whole process is completely painless on Linux folks, it takes literary minutes on Ubuntu to not only install the R environment but to also build a package. Unfortunately binary compatibility with packages is not supported (apparently not even if 100% of the code in your package is R code). The authors of R appear to have no regard for Windows developers whatsoever. It’s a real shame.

  15. te
    March 24, 2016 at 10:38 PM


  1. June 9, 2011 at 12:20 AM
  2. May 23, 2012 at 9:17 PM
  3. August 11, 2012 at 8:53 PM
  4. March 2, 2013 at 5:03 AM
  5. June 22, 2014 at 9:32 PM
  6. September 9, 2015 at 12:18 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: