tags:

views:

1613

answers:

4

A friend sent me along this great tutorial on webscraping NYtimes with R. I would really love to try it. However, the first step is to installed a package called RJSONIO from source.

I know R reasonable well, but I have no idea how to install a package from source.

I have a mac OSX, if that is meaningful.

+3  A: 

If you have the file locally, then use install.packages() and set the repos=NULL:

install.packages(file_name_and_path, repos = NULL, type="source")

Where file_name_and_path would represent the full path and file name. On windows this will look something like this: "C:\RJSONIO_0.2-3.tar.gz". On unix this would look like this: "\usr\blah\RJSONIO_0.2-3.tar.gz".

Shane
It looks like installing from a windows binary (under Windows so it won't work on Mac OS).
Marek
Thanks. Just clarified my answer.
Shane
+2  A: 

Download the source package, open Terminal.app and execute

R CMD INSTALL RJSONIO_0.2-3.tar.gz
rcs
I tried this and got an error:Madjoro-MacBook-Pro:~ Madjoro$ R CMD INSTALL RJSONIO_0.2-3.tar.gzWarning: invalid package ‘RJSONIO_0.2-3.tar.gz’Error: ERROR: no packages specified
Madjoro
You have to specify the correct path to the .tar.gz file and the XCode tools (http://developer.apple.com/TOOLS/Xcode/) are required.
rcs
Is there a way to build the binary .zip from the source?
haridsv
Found the solution, you need to use --binary option.
haridsv
+9  A: 

You can install directly from the repository (note the type="source"):

install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
Eduardo Leoni
I tried this and got an error:* Installing *source* package ‘RJSONIO’ ...** libs** arch - i386sh: make: command not foundERROR: compilation failed for package ‘RJSONIO’RMate stopped at line 3* Removing ‘/Library/Frameworks/R.framework/Versions/2.9/Resources/library/RJSONIO’The downloaded packages are in ‘/private/var/folders/Ey/EyzhYjoKESmsmsZ6K87PeU+++TI/-Tmp-/Rtmpe3C96p/downloaded_packages’Updating HTML index of packages in '.Library'Warning message:In install.packages("RJSONIO", repos = "http://www.omegahat.org/R", : installation of package 'RJSONIO' had non-zero exit status
Madjoro
Do you have the developer tools installed? They come in the Mac OS X installation dvd. Since this package has C code you will need a compiler to install it from source.
Eduardo Leoni
I suspect I do not have the developer tools installed. Atleast, I don't remember installing them. Thanks!
Madjoro
If you are doing this on windows, you can get the developer tools from http://www.murdoch-sutherland.com/Rtools/ ... make sure when installing you check the box that says to update your path (may be a bit hard to read .... just checked the unchecked box that comes up)
Dan Goldstein
A: 

In addition, you can build the binary package using the --binary option.

R CMD build --binary RJSONIO_0.2-3.tar.gz
haridsv