Dollar operator as function argument for sapply not working as expected
问题 I have the following list test_list=list(list(a=1,b=2),list(a=3,b=4)) and I want to extract all elements with list element name a . I can do this via sapply(test_list,`[[`,"a") which gives me the correct result #[1] 1 3 When I try the same with Rs dollar operator $ , I get NULL sapply(test_list,`$`,"a") #[[1]] #NULL # #[[2]] #NULL However, if I use it on a single element of test_list it works as expected `$`(test_list[[1]],"a") #[1] 1 Am I missing something obvious here? 回答1: From what I've