A.A*_*idi 15 postgresql r
我有一个大型数据集,我将在R软件中进行一些分析.虽然我无法将数据正确导入R.
我收到此错误:
Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (could not connect User@local on dbname "Intel"
我使用PostgreSQL打开数据并以某种方式管理它.如何将PostgreSQL中的现有数据导入R软件?
A.A*_*idi 24
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, host='localhost', port='5432', dbname='Swiss',
user='postgres', password='123456')
Run Code Online (Sandbox Code Playgroud)
此外,应安装R中的"RPostgreSQL"包.
小智 7
试试R包RPostgreSQL http://cran.r-project.org/web/packages/RPostgreSQL/.您可以在http://code.google.com/p/rpostgresql/中查看如何使用它.例:
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
Run Code Online (Sandbox Code Playgroud)