Re: [R] list matching

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 14 Jun 2010 09:30:55 -0400

One thing you might do is to transform the data into a format that is easier to combine; I like using 'merge':

> mynames=cbind(c('a','b'),c(11,22))
> lst=list(a=c(1,2), b=5)
> mynames

     [,1] [,2]
[1,] "a" "11"
[2,] "b" "22"
> lst

$a
[1] 1 2

$b
[1] 5

> mynames.df <- as.data.frame(mynames)
> mynames.df

  V1 V2
1 a 11
2 b 22
> lst.s <- stack(lst)
> lst.s

  values ind

1      1   a
2      2   a
3      5   b

> merge(mynames.df, lst.s, by.x="V1", by.y="ind")
  V1 V2 values
1  a 11      1
2  a 11      2
3  b 22      5

>

On Mon, Jun 14, 2010 at 8:06 AM, Yuan Jian <jayuan2008_at_yahoo.com> wrote:
> Hello,
>
> I could not find a clear solution for the follow question. please allow me to ask. thanks
>
> mynames=cbind(c('a','b'),c(11,22))
> lst=list(a=c(1,2), b=5)
>
> now I try to combine mynames and lst:
> a  1  11
> a  2  11
> b  5  22
>
> thanks
> jian
>
>
>
>
>        [[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.
>
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
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.
Received on Mon 14 Jun 2010 - 13:33:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 13:40:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive