commas <- function(...) stringr::str_c(..., collapse = ", ")
no braces needed for function on a single line
commas <- function(...) stringr::str_c(..., collapse = ", ")
no braces needed for function on a single line
it’s the same as the input!
because we want to modify columns in place
Compute the mean of every column in mtcars.
output <- vector("double", ncol(mtcars)) # 1. output
for (i in seq_along(mtcars)) { # 2. sequence
output[[i]] <- mean(mtcars[[i]]) # 3. body
}