I have a vector a = c(1,0,0,0,1,0,4,0,0,0) Now I want to get a vector of positions in a vector a where the value is non zero.. How to do it?? -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-vector-of-poitions-in-a-vector-tp2299997p2299997.html Sent from the R help mailing list archive at Nabble.com.
Hi> a = c(1,0,0,0,1,0,4,0,0,0) > which(a!=0)[1] 1 5 7 Beware of floating point near zero values. Petr r-help-bounces at r-project.org napsal dne 23.07.2010 13:12:44:> > I have a vector a = c(1,0,0,0,1,0,4,0,0,0) > Now I want to get a vector of positions in a vector a where the value isnon> zero.. > How to do it?? > > > -- > View this message in context:http://r.789695.n4.nabble.com/How-to-get-vector-> of-poitions-in-a-vector-tp2299997p2299997.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
(1:length(a))[a != 0]
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of vikrant
Sent: 23 July 2010 12:13
To: r-help at r-project.org
Subject: [R] How to get vector of poitions in a vector ?
I have a vector a = c(1,0,0,0,1,0,4,0,0,0)
Now I want to get a vector of positions in a vector a where the value is
non
zero..
How to do it??
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-get-vector-of-poitions-in-a-vector-
tp2299997p2299997.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at 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.
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}