Functions Create a function my_function <- function(x, y) { result <- x + y return(result) } Apply a function to a column df$NewColumn <- sapply(df$OldColumn, my_function)