Thanks for the rapid response.
The inequality with the quantile trim works great, however I am in looking for
a two tailed trim. This could work if I could unite two series in a command
similar to the following:
trim <- function(x,prop=.05) {
trimlow <- x[x < quantile(x,prob=(1-prop))]
trimhigh <- x[x > quantile(x,prob=(prop))]
trimx <- intersect(trimlow, trimhigh)
return(trimx)
}
However the intersect function will not return repeated values, which is a
problem. Any thoughts??
Thanks.
Petr Klasterecky <[EMAIL PROTECTED]> wrote: If it is precise enough for you,
you can use
trim <- function(x,prop=.05) {
trimx <- x[x < quantile(x,prob=(1-prop))]
return(trimx)
}
Petr
Jonathan Morse napsal(a):
> Hi,
>
> I am trying to restrict a data set so as not to included outliers.
> Specifically, I would like to specify a percentage where a fraction of
> observations are eliminated from the data set, much in the same way that the
> trimmed mean function works - but leaving the restricted data set intact.
>
> I have been using a function which will restrict the data set using:
>> trim=function(x,p){
>> o=order(x)
>> xo=x[o]
>> n=length(xo)
>> tl=round(n*p)
>> print(xo[(tl+1):(n-tl)])}
>
> However I was wondering if anyone knew a more elegant and simple method to
> get the same result.
>
> Thanks in advance.
>
>
>
> ---------------------------------
> Don't pick lemons.
>
> [[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.
>
--
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic
---------------------------------
Be a PS3 game guru.
[[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.