title: Casting PostgresqlResult to R dataframe
body: <p>I am trying to fetch data from a local Postgresql instance into R. I need to work with parameterized queries because the queries will later depend on the users input.   </p>
  
  <pre><code>res &lt;- postgresqlExecStatement(con, "SELECT * FROM patient_set WHERE 
  instance_id  = $1", c(100))
  postgresqlFetch(res,n=-1)
  postgresqlCloseResult(res)
  
  dataframe = data.frame(res)
  dbDisconnect(con)
  </code></pre>
  
  <p>Unfortunately this still gives me the following error:</p>
  
  <pre><code>Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class "structure("PostgreSQLResult", package ="RPostgreSQL")" to a data.frame
  </code></pre>
  
  <p>I also tried switching to dbGetQuery and dbBind but didn't get it running properly. What is the best way to fetch the result of parameterized queries from Postgresql directly into an R dataframe or table?</p>