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


##########
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:
   How about formatting it as follows?
   
   ```suggestion
   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()
   ```



-- 
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