# NOT RUN {
data(efc)
std(efc$c160age) %>% head()
std(efc, e17age, c160age) %>% head()
center(efc$c160age) %>% head()
center(efc, e17age, c160age) %>% head()
# NOTE!
std(efc$e17age) # returns a vector
std(efc, e17age) # returns a tibble
# works with mutate()
library(dplyr)
efc %>%
select(e17age, neg_c_7) %>%
mutate(age_std = std(e17age), burden = center(neg_c_7)) %>%
head()
# works also with grouped data frames
mtcars %>% std(disp)
mtcars %>%
group_by(cyl) %>%
std(disp)
data(iris)
# also standardize factors
std(iris, include.fac = TRUE)
# don't standardize factors
std(iris, include.fac = FALSE)
# }
Run the code above in your browser using DataLab