1
I need to remove outliers from a database in a "manual" way, I would use the following command:
a=X
Q1<-quantile(X,0.25)
Q3<-quantile(X,0.75)
IQR<-Q3-Q1
lim_inf=Q1-1.5*IQR
lim_sup=Q3+1.5*IQR
a>lim_sup
a<lim_inf
out=(a>lim_sup)|(a<lim_inf)
a[out]=NA
X=a
here the generic command I use, X is the variable to remove
But this command I always need to change the variable X all the time. I wonder if there is a way to do the removal faster, some loop or some package that removes from all the columns I have in a data.frame and swap for NA
I just found the source of the function I had posted as a response thanks to @Ruibarradas user. I deleted the answer, I don’t think it makes sense to have another answer like that, even quoting the source, in the OS just because it’s in another language. Follow the link for very similar question in OS En. I will post another answer with another way I did.
– Artur_Indio