Re: [R] Smart Indexing

2010-08-09 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
Mathematics > Cc: r-help@r-project.org > Subject: Re: [R] Smart Indexing > > I think you just need merge(), e.g. > > a <- data.frame(id = rep(1:3, each=3), val = rnorm(9)) > b <- data.frame(id = 1:3, set1 = LETTERS[1:3], set2 = 5:7) > > merge(a, b, by = "i

Re: [R] Smart Indexing

2010-08-09 Thread Dimitris Rizopoulos
I think you just need merge(), e.g. a <- data.frame(id = rep(1:3, each=3), val = rnorm(9)) b <- data.frame(id = 1:3, set1 = LETTERS[1:3], set2 = 5:7) merge(a, b, by = "id") I hope it helps. Best, Dimitris On 8/9/2010 11:01 AM, Thaler, Thorn, LAUSANNE, Applied Mathematics wrote: Hi all, Su

[R] Smart Indexing

2010-08-09 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
Hi all, Suppose that I've two data frames, a and b say, both containing a column 'id'. While data frame 'a' contains multiple rows sharing the same id, data frame 'b' contains just one entry per id (i.e. a 1 to n relationship). For the ease of modeling I now want to generate a new data frame c, wh