I have 3 lists called T1, T2, and T3 (shown below). From these lists, I want to extract a subset Q.
L1<-list("A"=matrix(c(1:4),2),"B"=matrix(c("a","b","c","d"),2))
L2<-list("P"=matrix(c(5:8),2),"Q"=list(list("u","v","w","x"),2))
T1 <- list(L1, L2)
T2 <- list(NULL, L1, L2)
T3 <- list(L1, NULL, L2)
The output I need is only the list Q which is embedded in the parent lists (T1, T2, and T3).
Here are the solutions I tried, but they all return the NULL value for siblings of Q -
lapply(T3, `[[`, "Q")
purrr::map(T3, `[`, "Q")
purrr::map_depth(T3, 2, "Q")
Please suggest a solution to subset Q out of parents T1, T2, and T3. As you can see the position of Q is different in each parent, I am looking for a solution to subset parent list by child name Q instead of hardcoding the position of Q.