Hello,
I want to create a function in order to make some count after grouping.
The function works as the code shows:
library(tidyverse)
base<-mtcars
resumen<-function(x,y){
base %>%
group_by({{x}},{{y}}) %>%
count()
}
resumen(carb,gear)
Howeverm, I can't use map2.
I try to perform a "loop" with map2 and I failed time after time.
var_x<-list("carb","cyl")
var_y<-list("gear","vs")
map2(var_x,var_y, resumen )
What am I doing wrong?
I used the forum to obtain the notation {{variable}} inside the function.
But I couldn't find an example using purrr.
Thanks for your replies and time.
Have a nice week, community.