If you trying to install a package in R and get hit with “Error: package ‘foo’ was built before 3.0.0: please re-install it“, or in installation fails because of uninstalled dependencies, then run the following in R or RScript:
update.packages(checkBuilt = TRUE, ask = FALSE)
If this fails because of permissions problems with updating the R library directory, then try again as root.
Thanks to anonymous user3003714 on StackOverflow for that blessed cure.
How I Got There
I am taking a data science course from Coursera. Our homework assignments this week are in R, and learning R has been left as an exercise for the student.
The biggest problem I have had has been getting R to work at all. Package caret was recommended for our assignment, and it would not install because of dependency issues, or because a 2.x rather than 3.x version was installed. When I tried to install the prerequisite packages, I found that they, too, had dependencies.
Google did not immediately turn up a general solution, so I kept inching my way up the dependency tree, one package at a time. For awhile it seemed that I was finding three new dependencies for every one that I resolved. I have not experienced this sort of dependency Hell since the days before wrapping C header files with #ifndef HEADER_NAME .. #endif became standard practice. It was certainly a match for any DLL Hell problem I’ve faced.
After hours of work, the caret library would load. All the while, I kept wondering how could so many people use R when it’s this hard to set up?
So finally I could actually start on the homework. Well into it, a problem description recommended the use of package rpart, and I hit a similar 2.x problem that I’d run into with caret, but worse than before because a simple re-install did not fix it.
It was back to Google, but this time (thank God!), the search struck gold, in the form of the first section of this post.