Skip to content

Instantly share code, notes, and snippets.

@verajosemanuel
Created December 17, 2018 16:06
Show Gist options
  • Save verajosemanuel/56629d57c88b047153c3ebc054d70a63 to your computer and use it in GitHub Desktop.
Save verajosemanuel/56629d57c88b047153c3ebc054d70a63 to your computer and use it in GitHub Desktop.
#print #index in #lapply #function in #R
myfunction<- function(values, index){
cat("Adding values (", index, "): ", values[1], "...", values[2], " = ", sum(values), "\n" )
invisible(values[1] + values[2])
}
mylist <- list(c(5, 4), c(3, 2), c(1, 3))
mapply(myfunction, mylist, seq_along(mylist))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment