My dataframe contains numeric and character columns as shown below.
> df
A B C D E G
a1 b1 c1 1 2 3
a2 b2 c2 4 5 6
...
I want to compute row-wise zscores for numeric columns (D, E and G) using dplyr. I tried:
> df %>% rowwise() %>% mutate_if(is.numeric, ~scale(., center=T, scale=T))
> A B C D E G
a1 b1 c1 NA NA NA
a2 b2 c2 NA NA NA
I'm unable to understand why NA is being returned. Any inputs on how to achieve what I want to do is greatly appreciated.
Thanks!