Hi Joe, Not sure about your expected result blah<- paste0("x",1:5) which(blah=="xyz") #integer(0) blah=="xyz" #[1] FALSE FALSE FALSE FALSE FALSE any(blah=="xyz") #[1] FALSE
sum(blah=="xyz") #[1] 0 sum(blah=="x1") #[1] 1 A.K. ----- Original Message ----- From: Joseph Trubisz <jtrub...@me.com> To: r-help@r-project.org Cc: Sent: Wednesday, May 22, 2013 2:08 PM Subject: [R] How to test if something doesn't exist Couldn't exactly explain the subject, so here's the example: idx<-which(blah[,1]=="xyz") idx integer(0) How do I test that idx has a valid value (namely, > 0)? TiA, Joe ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.