Hi,
Is it possible to make something like the following code actually
work? My goal in this example would be that I'd see results like
1 10000 10100
2 10100 10200
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
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.