Using relational database tables in R

R: database tables can be read directly into dataframes, lists, etc. for use with linear models, plot and other R functions.

require("RODBC");
channel = odbcConnect("localhost", uid="tj", pwd="password", case="postgresql", believeNRows = FALSE);

sql = "Select logp from training_set";
propval = sqlQuery(channel, sql, max=0);
sql = "Select smarts, count_matches(smiles,smarts)
from training_set, atom_types where train_freq > 10";
counts = sqlQuery(channel, sql, max=0);
....
propfit = lm(data.frame(propval,counts));
plot(x=fitted(propfit), y=propval$logp,
ylab='experimental value', xlab='predicted value');
sql = "Select logp,glogp(smiles) from xlogp.test_set order by logp desc";
logp = sqlQuery(channel, sql, max=0);
plot(logp);