[R] PHP MySQL and R

BEER Michael michael.beer at unifr.ch
Fri Dec 17 09:33:00 CET 2004


> -----------
> Problem #1:
> ...
> -----------

Consider using the library "RMySQL" (available at
http://stat.bell-labs.com/RS-DBI/download/) for directly accessing your
MySQL database from R.

--- bla.R ---
library("RMySQL")
con <- dbConnect(dbDriver("MySQL"), 
	  group = "<your group name as defined in $HOME/.my.cnf>")
res <- dbSendQuery(con, 
	  "SELECT x,y,lagged FROM DATA WHERE ds_id=(whatever dataset)")
userdata <- fetch(res, n = -1)
...
--- ***** ---

The only parameter you need to pass to your script from PHP would thus
be the current dataset ID. Maybe someone else can advise you on how to
do this in an elegant way.

 
> -----------
> Problem #2:
> ...
> -------------

Paste the appropriate values of summary.lm into an SQL statement
("INSERT INTO ...") and send this command to your database using
dbSendQuery(...) again.

Yours, Michael.




More information about the R-help mailing list