Hi,all: I have a vector,and wanna get the opposite value via rev function.> a[1] FALSE FALSE TRUE TRUE TRUE> > rev(a)[1] TRUE TRUE TRUE FALSE FALSE>I don't know why the 3rd "TRUE" has not been reversed,while all other values are reversed? Thanks My best [[alternative HTML version deleted]]
Hi> [R] question about rev > > Hi,all: > I have a vector,and wanna get the opposite value via rev function. > > > > a > [1] FALSE FALSE TRUE TRUE TRUE > > > > rev(a) > [1] TRUE TRUE TRUE FALSE FALSE > > > > > I don't know why the 3rd "TRUE" has not been reversed,while all other > values are reversed?Misunderstanding what rev function does. see letters rev(letters) !a Regards Petr> > > > > Thanks > > > My best > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guideR-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Yes£¬I find out later. rev is only reverse the order. What I use is ! Thanks At 2012-01-06 16:07:11,"Petr PIKAL" <petr.pikal@precheza.cz> wrote:>Hi > >> [R] question about rev >> >> Hi,all: >> I have a vector,and wanna get the opposite value via rev function. >> >> >> > a >> [1] FALSE FALSE TRUE TRUE TRUE >> > >> > rev(a) >> [1] TRUE TRUE TRUE FALSE FALSE >> > >> >> >> I don't know why the 3rd "TRUE" has not been reversed,while all other >> values are reversed? > >Misunderstanding what rev function does. > >see > >letters >rev(letters) >!a > >Regards >Petr > > >> >> >> >> >> Thanks >> >> >> My best >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list >> stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
the function /rev / REVERSEs the order of the vector, as v= c(1,2,3) rev(v)= 3,2,1 if you want the opposite value , just add a exclamation in front of the vector: v=c(T,F,T,T); !v is F,T,F,F -- View this message in context: r.789695.n4.nabble.com/question-about-rev-tp4268518p4268716.html Sent from the R help mailing list archive at Nabble.com.