[R] Calling a list element

David Winsemius dwinsemius at comcast.net
Wed May 12 23:29:33 CEST 2010


On May 12, 2010, at 5:18 PM, Luis Felipe Parra wrote:

> Hello, i have the following list
> strsplit(as.character(Elecciones$Municipios),"\\.")
> [[1]]
> [1] "ANTIOQUIA" "ABEJORRAL"
> [[2]]
> [1] "META"    "ACACIAS"
> [[3]]
> [1] "CASANARE" "AGUAZUL"
> [[4]]
> and I would like to make a vector of the first element of each of  
> the list
> items, in this case ANTIOQUIA, META, CASANARE, etc . Do you know how  
> can I
> do this?
>

 > unlist( lapply(ll, "[", 1))
[1] "ANTIOQUIA" "META"      "CASANARE"


> Thank you
>
> Felipe Parra

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list