[R] Matching a period in grep...

2008-08-05 Thread Alec.Zwart
Hi folks, Can anyone enlighten me as to why I get the following when I search for ".csv" at the end of a string? > grep("\.csv$","Blah.csv",value=TRUE) [1] "Blah.csv" Warning messages: 1: '\.' is an unrecognized escape in a character string 2: unrecognized escape removed from "[\.]csv$" R re

[R] One-to-one matching?

2008-06-22 Thread Alec.Zwart
Hi folks, Can anyone suggest an efficient way to do "matching without replacement", or "one-to-one matching"? pmatch() doesn't quite provide what I need... For example, lookupTable <- c("a","b","c","d","e","f") matchSample <- c("a","a","b","d") ##Normal match() behaviour: match(matchSample,lo

Re: [R] One-to-one matching?

2008-06-23 Thread Alec.Zwart
My thanks to Gabor Grothendieck, Charles C. Berry and Moshe Olshansky for their suggested solutions. The upshot of which is that a nice one-line solution to my one-to-one exact matching problem is the Grothendieck-Berry collaboration of match(make.unique(matchSample), make.unique(lookupTable))