Is there some equivalent function in R of Mathematica's "Apply"
Apply[ f, g[a,b]] ==> f[a,b]
In concret, I have a matrix of indexes:
[1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10
and I'd like to extract sequences 1:6, 2:7, 3:8, ..., 5:10 from a vector x.
What would be the most compact way of achieving this?
sapply(1:5, function(i) x[ind[i,1] : ind[i,2]])
sapply(1:5, function(i) x[seq(ind[i,])])
would be better (if it worked).
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Archive generated by hypermail 2.2.0, at Tue 24 Jun 2008 - 21:31:57 GMT.
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.
list of date sections of archive