Reputation:
I have GNU R
installed (the S-like
statistics package; version 2.8.1) and PostgreSQL (8.4.1)
, but I cannot connect GNU R
to my RDBMS
.
When I first did this (years ago - code lost) DBI
for R
didn't exist. Now it does. I am also confused as to which R
package to use. A quick search returns:
RPgSQL
Looks abandoned. I wish they would put a date on their webpage. ;-(My Linux distribution
doesn't package R
packages (irony) but I am comfortable running R CMD INSTALL package.tar.gz
.
I installed RPostgreSQL
: a lot of documentation says to call dbConnect
but I get the following error message: Error: object "dbConnect" not found
.
Upvotes: 8
Views: 4399
Reputation: 844
My guess is you need to install the DBI package (most database packages depend on it).
If you use install.packages('RPpostgreSQL',dep=TRUE)
from within R it should take care of any dependency issues.
Upvotes: 1
Reputation:
RODBC works great for me. You just have to set up a data source name (DSN) for the database you want to connect to. I find this nice because then the specific connection info does not have to be stored in R, and it may vary for your collaborators.
Also, yes, it sounds like you haven't loaded the RPostgresSQL package.
Upvotes: 0
Reputation: 368231
Just for completeness, you have two more options
But as a RPostgreSQL maintainer/co-author I am glad you found this one. As the other poster suggested, try library(RPostgreSQL)
before issueing commands. If you encounter other problems, feel free to email me off-SO with a bug report.
Edit: There is another option of embedding R inside PostgreSQL using Joe Conway's PL/R.
Upvotes: 9
Reputation: 44118
Maybe you need to run require(RPostgreSQL)
before you can use dbConnect
?
Upvotes: 3