I would like to apply a global normalization of one column of a tibble. I used mutate_at with a normalization function as following
normalize2 <- function(x, na.rm = T) (x / max(x, na.rm = T)) mutate_at('avg', normalize2) %>%
It did normalization but within a subset according to other columns. So the "normalized" column avg has multiple "1"
I googled a bit and found the following code which worked,
mutate_at('avg', ~(scale(.) %>% as.vector))
but I don't get the general logic of muate_at then. Could someone please explain how come this code worked and how to make my version work in the same way without considering the conditions of other columns?
More importantly, what is the general way to tell the mutate function to apply a function globally on a column instead of considering other conditions? I realize this is very dangerous at least for me because my first impression is it should be applied just globally.