Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Tal Galili
ch > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > > project.org] On Behalf Of Tal Galili > > Sent: Tuesday, 9 November 2010 10:10 a.m. > > To: r-help@r-project.org > > Subject: [R] Help with getting ?match to n

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Peter Alspach
f Of Tal Galili > Sent: Tuesday, 9 November 2010 10:10 a.m. > To: r-help@r-project.org > Subject: [R] Help with getting ?match to not sort > > Hello all, > > I think I am missing something about the sorting parameter in the > "match" > command/ > Here is an

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Phil Spector
Ted - If you want to retain the exact order of the rows of one of the merged matrices, I think you have to merge them "by hand": cbind(a1,num=a2[match(a1$name,a2$name),'num']) name num 1D 4 2B 2 3C 3 4A 1 5A 1 6C 3

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread jim holtman
Missing: a closer reading of the help page -- Value A data frame. The rows are by default lexicographically sorted on the common columns, but for sort = FALSE are in an unspecified order. So sort = FALSE says unspecified. If you want the original order, then add a column to the dataframe with th

[R] Help with getting ?match to not sort

2010-11-08 Thread Tal Galili
Hello all, I think I am missing something about the sorting parameter in the "match" command/ Here is an example: a1 <- data.frame(name = c("D", "B", "C", "A", "A", "C")) a2 <- data.frame(name = c("A", "B", "C", "D"), num = 1:4) a1 a2 merge(a1, a2, sort = F, by.x = T) The result is: name n