"Pascal A. Niklaus" <[EMAIL PROTECTED]> writes: > Hi all, > > Is there a function to check if a particular value is contained in a > vector? I've looked at grep in the hope that I could use a Perl-like > syntax, but obviously it's different... > > I'd like to do something like: > > y <- c("a","b","c") > if("a" in y) > { > # "a" is not in y > }
"a" %in% y > 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 LETTERS[1:10] is probably the closest. You do need to look up that "J" is the 10th letter or resort to things like LETTERS[which(LETTERS>="A"&LETTERS<="J")] or LETTERS[which(LETTERS=="A"):which(LETTERS=="J")] -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help