MySQL and R | R-bloggers
Using MySQL with R is pretty easy, with RMySQL. Here are a few notes to keep me straight on a few things I always get snagged on. Typically, most folks are going to want to analyze data that's already in a MySQL database. Being a little bass-ackwards, I often want to go the other way. One reason to do this is to do some analysis in R and make the results available dynamically in a web app, which necessitates writing data from R into a database. As of this writing, INSERT isn't even mentioned in the RMySQL docs, sadly for me, but it works just fine. The docs are a bit clearer for RS-DBI, which is the standard R interface to relational databases and of which RMySQL is one implementation. Opening and closing connections The best way to close DB connections, like you would do in a finally clause in Java, is to use on.exit, like this: con
R-bloggers