[R] Last element of a vector by group

2012-05-15 Thread Axel Urbiz
Dear List,

How can I get a logical vector as shown by a.ord.last below (i.e., it is
FALSE whenever there are subsequent equal values of an ordered vector and
FALSE otherwise)?


a - c(1,1,2,1,3,4,3,5,6)
a.ord - a[order(a)]
a.ord

a.ord.last - c(F, F, T, T, F, T, T, T, T)


Thanks for any help

Axel.

[[alternative HTML version deleted]]

__
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.


Re: [R] Last element of a vector by group

2012-05-15 Thread R. Michael Weylandt
? duplicated

!duplicated(a.ord, fromLast = TRUE)


HTH,
Michael

On Tue, May 15, 2012 at 9:37 PM, Axel Urbiz axel.ur...@gmail.com wrote:
 Dear List,

 How can I get a logical vector as shown by a.ord.last below (i.e., it is
 FALSE whenever there are subsequent equal values of an ordered vector and
 FALSE otherwise)?


 a - c(1,1,2,1,3,4,3,5,6)
 a.ord - a[order(a)]
 a.ord

 a.ord.last - c(F, F, T, T, F, T, T, T, T)


 Thanks for any help

 Axel.

        [[alternative HTML version deleted]]

 __
 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.