Im trying to connect postgres with dplyr functions
my_db <- src_postgres(dbname = \'mdb1252\', user = \"diego\", password = \"pass\")
my_db
src: postgres 9.2
You might want this,
db=src_postgres(dbname = 'mdb1252',
user = "diego", password = "pass", options="-c search_path=mortalidad")
If anybody ends up here with the same problem, here is what works for me: (taken from @Diego's comment from Feb 6'14)
postgre_table <- function (src, schema, table) {
paste('SELECT * FROM', paste(schema, table, sep = '.')) %>%
sql() %>% tbl(src = src)
}
Finally dplyr has the solution to this problem thanks to the latest version 0.7 recently announced by Hadley Wickham. The DBI and dbplyr libraries greatly simplified the connection between dplyr and PostgreSQL.
con <- DBI::dbConnect(RPostgreSQL::PostgreSQL(),
host = "database.rstudio.com",
user = "hadley",
password = rstudioapi::askForPassword("Database password"))
tbl <- dplyr::tbl(con, dbplyr::in_schema('mortalidad','def0307'))