How do I achieve row-wise iteration using purrr::map?
Here's how I'd do it with a standard row-wise apply.
df <- data.frame(a = 1:10, b = 11:20, c = 21:30)
lst_result <- apply(df, 1, function(x){
var1 <- (x[['a']] + x[['b']])
var2 <- x[['c']]/2
return(data.frame(var1 = var1, var2 = var2))
})
However, this is not too elegant, and I would rather do it with purrr. May (or may not) be faster, too.