Created
December 17, 2018 16:06
-
-
Save verajosemanuel/56629d57c88b047153c3ebc054d70a63 to your computer and use it in GitHub Desktop.
#print #index in #lapply #function in #R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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