Using dplyr to work with data from a database, the median function does not seem to be translating correctly. Mean works as expected but median does not. I'm using a mysql database but can recreate the problem in sqlite.
mf <- memdb_frame(group = c("a", "a", "b", "b", "c"),
year = c(2010, 2010, 2012, 2013, 2010),
var1 = 5:1,
var2 = 100:104)
mf %>%
group_by(group, year) %>%
summarise_at(vars(one_of("var1", "var2")), median)
mf %>%
group_by(group, year) %>%
summarise_at(vars(one_of("var1", "var2")), mean)
This error is rather unhelpful, on my actual data I was getting something like
'AS temp, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY var1) AS var1, at line 1 [1064]
Using dplyr to work with data from a database, the median function does not seem to be translating correctly. Mean works as expected but median does not. I'm using a mysql database but can recreate the problem in sqlite.
This error is rather unhelpful, on my actual data I was getting something like