I'm trying to use summarize to get the first result for each group, but it returns the column header instead:
(get_table
is a custom function that gets a data table from a Postgres db)
require(dplyr)
require(RPostgres)
tbl <- get_table(my_server, my_table) %>%
select(column_a, column_b) %>%
group_by(column_a) %>%
summarize(first_b = first(column_b))
The result looks like
a first_b
1 "column_b"
2 "column_b"
3 "column_b"
If I use dplyr::collect()
before summarize()
I get the desired result but this really slows down performance.
Any ideas how I can summarize
without using collect
first?