Apply a callback to an array: Difference between revisions

m
No edit summary
Line 1,203:
cubes[i] <- cube(elements[i])
}</lang>
Loop syntax can often simplified using the [http://stat.ethz.ch/R-manual/R-patched/library/base/html/apply.html *arrayapply] family of functions.
<lang R>elements2 <- list(1,2,3,4,5)
cubes <- sapply(elements2, cube)</lang>
Anonymous user