I have a large data-set and I will preform some analysis in R software. While I could not import the data properly to R.
I get this error:
Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (could not connect User@local on dbname "Intel"
I have used PostgreSQL to open data and somehow manage it. How can I import the existing data in the PostgreSQL to the R software?
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, host='localhost', port='5432', dbname='Swiss',
user='postgres', password='123456')
Moreover, "RPostgreSQL" package in R should be installed.
Try the R package RPostgreSQL http://cran.r-project.org/web/packages/RPostgreSQL/ . You can see how to use it in http://code.google.com/p/rpostgresql/ . Example:
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL") ## loads the PostgreSQL driver
con <- dbConnect(drv, dbname="R_Project") ## Open a connection
rs <- dbSendQuery(con, "select * from R_Users") ## Submits a statement
fetch(rs,n=-1) ## fetch all elements from the result set
dbGetQuery(con, "select * from R_packages") ## Submit and execute the query
dbDisconnect(con) ## Closes the connection
dbUnloadDriver(drv) # Frees all the resources on the driver
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With