Trying to create a function that will compute the average of some variable, whose name is provided in the function. For instance:
mean_of_var <- function(var){
open_dataset('myfile') %>% summarise(meanB=mean(get(var) ,na.rm = T),
medianB=median(get(var),na.rm = T)) %>% collect %>% return
}
mean_of_var('myvar')
The main problem is that arrow:open_dataset does not support the get() function. So I get the error message:
Error: Error : Expression mean(get(var), na.rm = T) not supported in
Arrow Call collect() first to pull data into R.
Is there a way to write a function like that, while keeping the use of the "open_dataset('myfile')" function.