[R] Removing outliers
jim holtman
jholtman at gmail.com
Thu Nov 10 14:21:01 CET 2011
It is hard to tell with reproducible example; e.g., you data is
missing. At least provide 'str(dados)' so we have an idea of what it
looks like. My "guess" is that you want 'dados[[i]]' instead of
'dados[i]'. Also a stack trace would be useful. There was a
discussion yesterday about trapping errors and getting the stack
trace.
On Thu, Nov 10, 2011 at 5:21 AM, Filipe Ferminiano Rodrigues
<filipe.ferminiano at gmail.com> wrote:
> Hi,
> I want to remove the outliers of my database with the following program (an
> observation is considered an outlier if it is bigger than second quartile +
> 1,5* distance interquartiles or less than second quartile - 1,5*distance
> interquartiles):
>
> for(i in 1:length(dados)){
> q3=quantile(dados[i], probs=.75)
> q3=quantile(dados[i], probs=.50)
> q1=quantile(dados[i], probs=.25)
> d=q3-q1
> for(i2 in 1:length(dados$quest_1)) {
> if (dados[i2,i] < q2-1.5*d) dados[i2,i]=NULL
> else if (dados[i2,i] > q2+1.5*d) dados[i2,i]=NULL
> }
> }
>
> But R is returning the following error message:
>
> Erro em `[.data.frame`(x, order(x, na.last = na.last, decreasing =
> decreasing)) :
> undefined columns selected
>
> Anyone can help me fix this?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list