eitsupi commented on code in PR #35702:
URL: https://github.com/apache/arrow/pull/35702#discussion_r1200696052


##########
r/vignettes/data_wrangling.Rmd:
##########
@@ -165,6 +165,34 @@ sw2 %>%
   transmute(name, height, mass, res = residuals(lm(mass ~ height)))
 ```
 
+Because window functions are not supported, computing an aggregation like 
`mean()` on a grouped table or within a rowwise opertation like `filter()`  is 
not supported:
+
+```{r}
+sw %>%
+  select(1:4) %>%
+  filter(!is.na(hair_color)) %>%
+  group_by(hair_color) %>%
+  filter(height < mean(height, na.rm = TRUE))
+```
+
+This operation can be accomplished in arrow by computing the aggregation 
separately, for example within a join operation: 
+
+```{r}
+
+sw %>%  
+  select(1:4) %>%
+  filter(!is.na(hair_color)) %>%
+  left_join(sw %>% 
+    group_by(hair_color) %>%
+    summarize(mean_height = mean(height, na.rm = TRUE)) 
+    ) %>%
+  filter(height < mean_height) %>% 
+  select(-mean_height) %>%
+  collect()
+

Review Comment:
   Yes, sorry for the lack of explanation.
   I believe dplyr has been used `!` these days, instead of `-` in select, etc.
   The reference page confirms that there are no examples using `-`.
   https://dplyr.tidyverse.org/reference/select.html
   
   So I think using `!` is more better here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to