Making Simple Packages in R on Windows

[This article was first published on Steven Mosher's Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There are any number of short tutorials on making add on R packages on your Windows machine. This is yet another version of that process. I’ve explained what I did in 10 easy steps on the pages, but I’ll give a brief overview here.

In the first step I spent some time updating my R environment. For me that means getting  the latest copy of R ( 2.13.0) and checking that my RStudio is updated as well. RStudio is a great tool. In the future I hope that they can simplify the process of making R packages. The next step I suggest is getting a little familiar with your Windows system.  In step 2 we look at the Command Prompt and the PATH variable. We also take note of where our R binaries are installed. The reason is this. In order to build a package you use the command prompt and you issue R CMD commands. That means your path has to be aware of  where your R is located. That entails editing your PATH variable. For me that was ancient history. For this exercise I’ve decided to use pure R.  In the next steps we download and install the tools we need to build packages. For this tutorial the source files are PURE R, so there is no need for compiler for other languages. In the future I’ll try that. After we install the tools we have to do some editing of the PATH variable. This is where 50% of your problems will occur, so spent some time understanding that part of the process. After we edit the path we reboot.

The next phase of our process involves writing a sample package. For this step I merely use the example code provided by the function package.skeleton().  After we execute that function we come to the second hardest part of the job. editing help files. Looking at comments people make this step also causes problems. The documentation on editing these files is  rather daunting. If I had to pick one piece of R that could use a more detailed manual and editing tools ( with a built in checker) it would be this.

 

After we edit the files we can then build the package, check the package, and install the package.

 

Enjoy


To leave a comment for the author, please follow the link and comment on their blog: Steven Mosher's Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)