[R] how to have 'match' ignore no-matches

Rolf Turner r.turner at auckland.ac.nz
Mon Oct 5 22:46:10 CEST 2009


On 6/10/2009, at 9:01 AM, Jill Hollenbach wrote:

>
> Hi all,
> I think this is a very basic question, but I'm new to this so  
> please bear
> with me.
>
> I'm using match to translate elements of a data frame using a  
> lookup table.
> If the content of a particular cell is not found in the lookup  
> table, the
> function returns NA. I'm wondering how I can just ignore those  
> cells, and
> return the original contents if no match is found in the lookup table.
>
> Many thanks in advance, this site has been extremely helpful for me  
> so far,
> Jill

It's not clear to me just what you want to accomplish, but it's possible
that setting nomatch=0 in your call to match() might get you somewhere.

Note that xxx[c(0,1,2,3] gives xxx[c(1,2,3)] whereas
xxx[c(NA,1,2,3)] gives c(NA,xxx[c(1,2,3)]).

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list