I have three lists: test1
, test2
, test3
:
test1 <- list(`0` = "text", `1` = T)
test2 <- list(`0` = "text", `1` = "text")
test3 <- list(`0` = T, `1` = T)
In these lists i only want to keep information that is NOT TRUE
. For this i am using lapply:
test1 <- lapply(test1, function(x) x[!isTRUE(x)])
test2 <- lapply(test2, function(x) x[!isTRUE(x)])
test3 <- lapply(test3, function(x) x[!isTRUE(x)])
Now, i would like to append test1, test2 and test3 to an empty list with equally named list elements. However, i only want to append enteries that are text. The text may vary and there is no way to do this by character matching. I am currently getting:
$test1
$test1$`0`
[1] "text"
$test1$`1`
logical(0)
$test2
$test2$`0`
[1] "text"
$test2$`1`
[1] "text"
$test3
$test3$`0`
logical(0)
$test3$`1`
logical(0)
desired result is:
$test1
$test1$`0`
[1] "text"
$test2
$test2$`0`
[1] "text"
$test2$`1`
[1] "text"
$test3
NULL
How can i avoid getting logical(0)
and obtain my desired result?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…