[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] Find value in vector (or matrix)
From: Barry Rowlingson <B.Rowlingson () lancaster ! ac ! uk>
Date: 2003-11-20 12:50:10
[Download RAW message or body]
Pascal A. Niklaus wrote:
> y <- c("a","b","c")
> if("a" in y)
> {
> # "a" is not in y
> }
You are 98% of the way there. The missing two percent is this:
if("a" %in% y) {
...
}
you could also use the 'any' function:
if(any(y=="a")){
...
}
> Also, is there a way to generate character sequences similar to numeric
> sequences, e.g. something like "A":"J" ? I remember having seen a
> command doing this somewhere, but can't find it anymore
R defines two vectors, "letters" and "LETTERS" which have the 26 lower
and upper-case letters of the English alphabet. Subset from them to get
what you want.
Baz
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic