简体   繁体   中英

Subset from a list

I have a list that looks like this:

 cse[[1]]   
 [1] "name1"  "surname1"    
 cse[[2]] 
 [1] "name2"  "surname2"
 cse[[3]] 
 [1] "name3"  "surname3"    
 ......................     
 cse[[92514]]

How can I subset only the elements corresponding to:

cse[[1]][1]    
cse[[2]][1]   
cse[[3]][1]    
...........    
cse[[92514]]   

corresponding to: name1, name2, name3, ..., and put them together in a data.frame?

这应该可以解决问题

sapply(cse, "[", 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM