Messing with R packages

[This article was first published on Nathan VanHoudnos » rstats, 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.

This was really frustrating. I’m trying to modify a package from Matt Johnson and although I could get the package he sent me to install flawlessly, I couldn’t un-tar it, make a change, re-tar it, and then R CMD INSTALL it. I was about to pull out my hair. The error I got was:
ERROR: cannot extract package from ‘hrm-rev9.tar.gz’

The secret: you have to have the name correct.
R CMD INSTALL hrm-rev9.tar.gz
barfs. But
R CMD INSTALL hrm_0.1-9.tar.gz
works fine. I’m sure it’s somewhere in the docs. I just couldn’t find it.

As always, I made a script to do it for me: (Updated 6/17/2010 15:41)
#!/bin/bash # Quick script to tar & gzip the package, remove the old one, and install the new one # I'll add options automatically tag and release it later. #Set the library that I'm using LIB="/home/vanhoudn/R/i486-pc-linux-gnu-library/2.10/" #Commit svn commit -m "Build commit" #get the revision number from svn REV=`svn info -R | grep Revision | cut -d: -f 2 | sort -g -r | head -n 1 | sed 's/ //g'` #Build the filename FILENAME="hrm_0.1-$REV.tar.gz" # I need to tar up the pkg so I can install it. # Jump to the parent directory and work from there. cd .. # Exclude any hidden files under the directories (svn has a bunch) # and add the named files tar czf $FILENAME --exclude '.*' hrm/DESCRIPTION hrm/NAMESPACE hrm/src hrm/R # Remove the old version of the package R CMD REMOVE -l $LIB hrm # Install the new package R CMD INSTALL $FILENAME # Clean up rm $FILENAME # Go back to our previous directory cd hrm

To leave a comment for the author, please follow the link and comment on their blog: Nathan VanHoudnos » rstats.

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)