[R] Remove top-K elements in Vector

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Wed Feb 18 09:24:38 CET 2009


try this:

x[-(1:3)]
# or
tail(x, -3)


Best,
Dimitris


Gundala Viswanath wrote:
> Hi all,
> 
> Suppose I hve this vector:
> 
>> x
>  [1]  3  4  7 17 22 12 15 12  3  3  1  1
> 
> How can I remove the top-3 element.
> Yielding only:
> [1]  17 22 12 15 12  3  3  1  1
> 
> - Gundala Viswanath
> Jakarta - Indonesia
> 
> ______________________________________________
> 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.
> 

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014




More information about the R-help mailing list