Displaying 1 result from an estimated 1 matches for "durf".
Did you mean:
dur
2011 Sep 13
1
writing a loop using several list()-objects
...This code works perfectly fine but stops doing so if I put it into a loop:
sums <- list()
for(i in 1:length(start)) { for(j in 1:length(unlist(start[[i]]))) {
sums[[i]][j] <-
list(sum(unlist(sequence[[i]])[unlist(start[[i]])[j]:unlist(end[[i]])[j]]))
}}
The output looks like this:
> durF[[2]]
[[1]]
[1] 387.064
[[2]]
[1] 302.541
[[3]]
[1] 734.028
instead of:
> durF[[2]]
[[1]]
[1] 387.064 302.541 734.028
Something seems to be wrong with the indexing but no idea how to fix it. I
am not ambitious about creating elegant loops, they simply should work - so
please do not hesitate...