search for: sfoot

Displaying 1 result from an estimated 1 matches for "sfoot".

Did you mean: foot
2011 Sep 13
1
writing a loop using several list()-objects
...[[1]] [1] 4 7 9 I want to calculate sums of numbers in all start:end positions and list the output again, e.g. I can calculate the sum of the numbers occurring positions 2 till 4 of "sequence", i.e. between start[[2]][1] and end[[2]][1] using this code: sum(unlist(sequence[[2]])[unlist(Sfoot[[2]])[1]:unlist(end[[2]])[1]]) 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]])) }} Th...