I'm new with dplyr package, hopefully the question is not too silly.
Take the data.frame
test= data.frame(aoi_id = c(15651,19975,15998,15842, 15651,19975,15998,15842), ge_id = c(1, 1, 1, 1, 2, 2, 2, 2), ADJSTK = c(50, 54, 56, 50))
I want to summarise it as the function aggregate would do like:
aggregate(eu["ADJSTK"],eu["aoi_id"], mean, na.rm=T)
I wrote the following:
test %>% group_by(aoi_id) %>% summarise(ADJSTK = mean(ADJSTK, na.rm = T))
Instead of returning average ADJSTK by aoi_id, I get a simple mean of ADJSTK accross the whole dataset. Can you help me figuring out what is wrong? Thank you