Re: [R] matching each row

2009-07-08 Thread Marc Schwartz
On Jul 8, 2009, at 12:17 PM, tathta wrote: From an email suggestion, here are two sample datasets, and my ideal output: dataA <- data.frame(unique.id=c("A","B","C","B"),x=11:14,y=5:2) dataB <- data .frame(unique.id=c("A","B","A","B","A","C","D","A"),x=27:20,y=22:29) ## mystery operation(

Re: [R] matching each row

2009-07-08 Thread tathta
>From an email suggestion, here are two sample datasets, and my ideal output: dataA <- data.frame(unique.id=c("A","B","C","B"),x=11:14,y=5:2) dataB <- data.frame(unique.id=c("A","B","A","B","A","C","D","A"),x=27:20,y=22:29) ## mystery operation(s) happen here ## ideal output would be: dat

Re: [R] matching each row

2009-07-08 Thread Marc Schwartz
On Jul 8, 2009, at 10:09 AM, tathta wrote: I have two dataframes, the first column of each dataframe is a unique id number (the rest of the columns are data variables). I would like to figure out how many times each id number appears in each dataframe. So far I can use: length( match (da

Re: [R] matching each row

2009-07-08 Thread tathta
Close... The output I'm looking for is more like this: output <- data.frame(unique.id=c(1,3,5,7,9),N.in.x=c(2,3,1,2,1),N.in.y=c(0,1,3,1,1)) The first column can be gotten using a small change to the first table line: table ( x [ which ( x %in% x ) ] ) ##the 3rd "x" used to be a "y" but

Re: [R] matching each row

2009-07-08 Thread David Huffer
SA/Washington, DC david.huf...@csosa.gov - -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of tathta Sent: Wednesday, July 08, 2009 11:10 AM To: r-help@r-project.org Subject: [R] matching each row

[R] matching each row

2009-07-08 Thread tathta
I have two dataframes, the first column of each dataframe is a unique id number (the rest of the columns are data variables). I would like to figure out how many times each id number appears in each dataframe. So far I can use: length( match (dataframeA$unique.id[1], dataframeB$unique.id) )