I would like to have an sapply()
statement of the following form:
a <- c(4, 9, 20, 3, 10, 30)
sapply(c(a), function(x) b[x,2] - b[x,1])
Normally instead of c(a)
I would have 1:x
, however now I would like to go through only the values specified in a
. Is this possible?
Update: The point is not what goes after function(x)
- that is only intended as an example.