florianWickler · GitHub

Please have a look at
http://stackoverflow.com/questions/25184965/r-dplyr-how-to-use-last-first-nth-correct-in-a-sql-database

 library("dplyr")
 mytab <- tbl(src_postgres(dbname, host, port, user, password), "catalog")
 mytab <- group_by(mytab, catalog_id)
 mytab<- mutate(mytab, curr2 = last(currency))
 mytab

RS-DBI driver: (could not Retrieve the result : ERROR: function first_value() does not exist

mytab$query

SELECT "catalog_id", "currency", "skonto", FIRST_VALUE() OVER (PARTITION BY "catalog_id") AS "curr2" FROM "catalog"

In my opinion the query should be:

SELECT "catalog_id", "currency", "skonto", FIRST_VALUE(currency) OVER (PARTITION BY "catalog_id") AS "curr2" FROM "catalog"

Read the original on github.com ↗