Slightly off topic, am I the only person who hates the %>% operator? I find it completely obfuscates code.
my_column %>%
gsub(" ","",.) %>% # Remove whitespace, then...
gsub("[a-zA-Z]+","",.) %>% # Remove letters, then...
strsplit("-") %>% # Split on dashes, then...
lapply(as.numeric) %>% # Make each vector in the list numeric, then...
lapply(mean) # calculate the mean for each list index
The alternatives here would be gigantic function calls that need to be read from the inside out, or multiple variable assignments.Now days I would do the same with the tidyverse equivalents:
my_column %>%
stringr::str_replace_all(" ","") %>%
stringr::str_replace_all("[a-zA-Z]+","") %>%
stringr::str_split("-") %>%
purrr::map(is.numeric) %>%
purrr::map(mean) df %>%
select(var_1, var_2, var_3) %>%
left_join(df2 %>%
select(another_var1, var2),
by = c('var_2', 'var2'))
This is really over using `%>%`. However, I sometimes take this pattern way too far... :D