All,

thanks for your help.

Dieter,

thanks, it's a different way of tackling the problem.
But I still need a for loop to scroll throug the list?

For example:
c(1,2,3,5,)
and a threshold of 3, then c(1,5) should remain. If I make an integer with the 
difference between each element and the previous element,
then 5 should be eliminated, while it shouldn't.

Or am I wrong with this assumption?

Thanks anyway

Bart


> 
> Hi,
> 
> I have an integer which is extracted from a dataframe, which is sorted by
another column of the dataframe.
> Now I would like to remove some elements of the integer, which are near to
others by their value. For example:
> integer: c(1,20,2,21) should be c(1,20).

...
> Sorting the integer is not an option, the order is important.

Why not? It's extremely efficient for large series and the only method that
would work with large array. The idea: Keep the indexes of the sort order, mark
the "near others" for example making their index NA, and restore original order.
No for-loop needed.

Dieter
        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to