I am struggling with creating multiple columns in a DRY way.
I have searched google and stack exchange and I am still struggling with the below.
df <- data.frame(red = 1:10, blue=seq(1,30,3))
myfunction <- function(x){
log(x) + 10
}
df$green <- myfunction(df$red)
df$yellow <- myfunction(df$blue)
My questions are:
how can I create the green and yellow columns using a for loop?
how can I create the green and yellow using an apply function?