I'm doing some analysis stuff and using R. I encountered a problem:
I have a list of logicals, which looks as follows :
list = (TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE)
for every logical value a have a list of numeric values :
num = (1, 4, 3, 7, 3, 2 , 23, 98, 5)
I would like to sum the values for the blocks of TRUEs and put them in the matrix or sth.
Just like that :
list[1] == TRUE and list[2] == TRUE and list[3] == TRUE
so i'm calculating the sum : 1+4+3 = 8
so matrix[1,1] <- 8
and then omit list[4] and list[5] because it's FALSE and go to list[6], matrix[2,1] <- 2
... and so on...
I have no idea how to extract those blocks of TRUEs. I hope you can help me somehow!