Displaying 1 result from an estimated 1 matches for "returnlast".
Did you mean:
returninst
2009 Jul 18
1
apply/return and reuse
...200
3 10200 10300
4 10300 10400
In real usage the function would obviously do a lot more work, but the
question I cannot answer myself yet is whether the apply can return a
value from the work on one row and then use that value as the input to
the function for the next row?
Thanks,
Mark
ReturnLast = function (.row, NextInitial=100) {
.row$Initial = as.numeric(NextInitial)
.row$Final = as.numeric(.row$Initial+100)
}
MyStart = 10000
X = data.frame(cbind(Event = 1:10, Initial = 0, Final = 0))
X
MyStart = apply(X, 1, ReturnLast( X, MyStart))
X