[R] finding paired values from common subjects -- vector operation?
ggrothendieck at gmail.com
Sun Oct 21 15:24:36 CEST 2007
A <- data.frame(subject = suba, a)
B <- data.frame(subject = subb, b)
merge(A, B, all = TRUE)[-1]
Omit all = TRUE if you only want matches, i.e. no rows with NAs, and
omit [-1] if you want an extra column giving the subject.
On 10/21/07, gallon li <gallon.li at gmail.com> wrote:
> I have two vectors for values collected from a group of subjects, say
> I also have two vectors which indicate the corresponding subjects for a and
> b, say
> for a, the subjects are
> for b, the subjects are
> Then, I want to find out the paired values from a and b, such as (100, 200)
> (from subject 1), (150,300) (from subject 3), (140, 420) (from subject 5)
> How can I do this in R? Can somebody drop a hint here?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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