I am analyzing and using R. I ran into a problem:
I have a list of logics that looks like this:
list = (TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE)
for each logical value a there is a list of numerical values:
num = (1, 4, 3, 7, 3, 2 , 23, 98, 5)
I would like to summarize the values โโfor TRUE blocks and put them in a matrix or sth.
Just:
list[1] == TRUE and list[2] == TRUE and list[3] == TRUE, so I calculate the sum: 1 + 4 + 3 = 8 therefore matrix[1,1] <- 8, and then omit the list [4] and list [5], because it is FALSE and go to list [6], matrix[2,1] <- 2... and so on ...
I do not know how to extract these TRUE blocks. I hope you can help me somehow!
source
share