Search code examples
mysqlrubuntu-12.04rmysql

Cannot load library RMySQL


I've been trying to access a MySQL database using R (using Ubuntu 12.04), which I feel should be a rather natural thing to do as R is a statistical language. Yet, it seems like pulling teeth. It seems that the only library that does not run into dependency errors is RMySQL, but even then it seems it can only be accessed by installing it outside of R:

sudo apt-get install r-cran-rmysql

However, I was unable to run it in R because I would run into the following error:

package 'RMySQL' was built before 3.0.0, please re-install it

Not being one to question orders, I went ahead and re-installed all of R. However, I found myself right back at square one, this time with almost the exact opposite error:

package 'RMySQL' is not available (for R version 3.2.4 Revised)

In other words, the first error I got seemed to say "I won't run unless R is updated", now this new error says "I can't run if R is updated".

To make a long story short, how do I accomplish this rather simple task of accessing MySQL with R?


Solution

  • Cute.

    So you insist on current R (3.2.4 as you state) but you insist on an operating system flavour and version already once, and soon twice, deprecated by its vendor? Why?

    The error that you have is precisely due to this mismatch: you have an R version many years newer than the R version corresponding to the binary RMySQL package (aka r-cran-rmysql) you want to install. Round hole, square peg.

    So the answer is to go with the R you have and to install RMySQL from source (ie from within R via install.packages()) for which you'd need the MySQL headers via, say, sudo apt-get libmysqlclient-dev. That is what it is called now, you may get or is equivalent in the long outdated Ubuntu release.

    Now, you can also gets ports of current R packages via the PPAs by Michael Rutter but dealing with thhat may take longer than I have time to explain now.