---
output: html_document
---

```{r}
library(tidyverse)
```

```{r}
mtcars %>% 
  gather(variable, value) %>% 
  group_by(variable) %>% 
  summarise(mean(value), sd(value))

mtcars_std <- mtcars %>% 
  #mutate_all(function(x) (x - mean(x))/sd(x)) %>%
  #mutate_if(is.numeric, function(x) (x - mean(x))/sd(x)) %>%
  mutate_if(is.numeric, funs((. - mean(.))/sd(.)))

head(mtcars)
head(mtcars_std)

mtcars_std %>% 
  gather(variable, value) %>% 
  group_by(variable) %>% 
  summarise(mean(value), sd(value))
```

