[R] Checking if an element is part of a vector

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Oct 6 18:33:24 CEST 2004


"Dominik Bach" <dominik.bach at directbox.com> writes:

> Hi!
> 
> I want to know if a given element <- ('c64') is part of a vector<- ('c64',  'amiga', 'atari'). 
> 
> Does a function exist for this which gives back a logical value?

> 'c64' %in% c('c64',  'amiga', 'atari')
[1] TRUE

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list