[R] Managing list elements

Phil Spector spector at stat.berkeley.edu
Fri Jun 11 19:36:32 CEST 2010


Luis -
    I *think* that

mapply(list,LHS,RHS,SIMPLIFY=FALSE)

will give you what you want, but without a reproducible
example it's hard to tell.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu


On Fri, 11 Jun 2010, Luis Felipe Parra wrote:

> Hello, I have two lists with the same number of elements
>
>> tail(LHS)
> [[1]]
> [1] "antecedentes.factor_riesgo=17"     "antecedentes.estado=1"
> "antecedentes.medio=4"              "tarjetas_flagrancia.adquiriente2="
> [[2]]
> [1] "antecedentes.riesgo=1"             "antecedentes.estado=1"
> "antecedentes.medio=4"              "tarjetas_flagrancia.adquiriente2="
> [[3]]
> [1] "resultado_investig.pto_comp=N" "antecedentes.riesgo=1"
> "antecedentes.factor_riesgo=17" "antecedentes.medio=4"
> [[4]]
> [1] "resultado_investig.pto_comp=N"     "antecedentes.riesgo=1"
> "antecedentes.factor_riesgo=17"     "tarjetas_flagrancia.adquiriente2="
> [[5]]
> [1] "resultado_investig.pto_comp=N"     "antecedentes.factor_riesgo=17"
> "antecedentes.medio=4"              "tarjetas_flagrancia.adquiriente2="
> [[6]]
> [1] "resultado_investig.pto_comp=N"     "antecedentes.riesgo=1"
> "antecedentes.medio=4"              "tarjetas_flagrancia.adquiriente2="
>> tail(RHS)
> [[1]]
> [1] "antecedentes.riesgo=1"
> [[2]]
> [1] "antecedentes.factor_riesgo=17"
> [[3]]
> [1] "tarjetas_flagrancia.adquiriente2="
> [[4]]
> [1] "antecedentes.medio=4"
> [[5]]
> [1] "antecedentes.riesgo=1"
> [[6]]
> [1] "antecedentes.factor_riesgo=17"
>>
>
>
> I would like to create a new list from this two which would have in every
> list entry one entry with the corresponding elements from LHS and another
> entry with the corresponding element from RHS (LHS doesn't always have three
> 4 elements per entry). Do you know how can I do this? Thank you
>
> Felipe Parra
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list