I am trying to translate sql to R using the dplyr
library, which I am new to.
How would I do it for the following SQL?
select v1, v2, max(v2) as v3 from (select v1, v2 from data1 where v1<10) group by v1, v2;
Advertisement
Answer
data1 %>% filter(v1<10) %>% group_by(v1,v2) %>% summarize(v3 = max(v2)) %>% ungroup()