Thanks for the answer, but I already fixed the problem. The problem was in selecting the row and column of the matrix. The program fixed is:
for(i in 1:length(dados)){ q3=quantile(dados*[,i]*, probs=.75) q2=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]=*NA* else if (dados[i2,i] > q2+1.5*d) dados[i2,i]=*NA* } } The parts in bold are the correct program, instead the anterior one that I posted here. [[alternative HTML version deleted]] ______________________________________________ R-help@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.