Function composition
square <- function(x) x^2
deviation <- function(x) x - mean(x)
x <- runif(100)
sqrt(mean(square(deviation(x))))
#> [1] 0.2928569
out <- deviation(x)
out <- square(out)
out <- mean(out)
out <- sqrt(out)
out
#> [1] 0.2928569
x %>%
deviation() %>%
square() %>%
mean() %>%
sqrt()
#> [1] 0.2928569