I can't connect to my PostGIS database using the following command (the same dsn works with ogrinfo):
pol <- st_read("PG:dbname='gis' host='localhost' port=5432 user='mylogin' password='mypassword'", "p1")
I get the following error: Error in eval(substitute(expr), envir, enclos) : Open failed
However the following query is OK with st_read_db():
dbcon <- dbConnect(dbDriver("PostgreSQL"), dbname = "gis", host = "localhost", user = "mylogin", password = "mypassword")
pol <- st_read_db(dbcon, query = "select * from p1")