[R] Find value in vector (or matrix)

Philipp Pagel p.pagel at gsf.de
Thu Nov 20 13:46:59 CET 2003


On Thu, Nov 20, 2003 at 01:26:23PM +0100, Pascal A. Niklaus wrote:
> Is there a function to check if a particular value is contained in a 
> vector?

> myvec <- c('foo','bar','duh','bonk')
> 'bonk' %in% myvec
[1] TRUE
> 'asdf' %in% myvec
[1] FALSE

> Also, is there a way to generate character sequences similar to numeric 
> sequences, e.g. something like "A":"J" ?

> LETTERS[1:5]
[1] "A" "B" "C" "D" "E"

> letters[c(8,9,12,23)]
[1] "h" "i" "l" "w"

cu
	Philipp

-- 
Dr. Philipp Pagel                                Tel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS              Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany




More information about the R-help mailing list