I want to get index number of 0s, like x <- c(1, 2, 0, 3, 0, 4) I want an output of 3, 5 Thank you. [[alternative HTML version deleted]]
On Thu, 2006-06-01 at 11:06 -0400, Mu Tian wrote:> I want to get index number of 0s, like > > x <- c(1, 2, 0, 3, 0, 4) > > I want an output of > > 3, 5 > > Thank you.See ?which> which(x == 0)[1] 3 5 HTH, Marc Schwartz
try: which(x == 0) Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: med.kuleuven.be/biostat student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Mu Tian" <muster at gmail.com> To: "R-Help" <r-help at stat.math.ethz.ch> Sent: Thursday, June 01, 2006 5:06 PM Subject: [R] simple index question>I want to get index number of 0s, like > > x <- c(1, 2, 0, 3, 0, 4) > > I want an output of > > 3, 5 > > Thank you. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html >Disclaimer: kuleuven.be/cwis/email_disclaimer.htm