[R] identifying outliers

ucgamdo@ucl.ac.uk ucgamdo at ucl.ac.uk
Fri Aug 29 12:55:01 CEST 2003


You can identify your outliers with the boxplot function itself. Here is an
example:
(you can just copy it and paste it into R)

# This generates a rondom variable x with 10 elements

x = rnorm(100)
boxplot(x) # you shouldn't see any outliers here although sometimes yow will

# lets add some outliers intentionally
x = c(21, 20, 25, x) # now 10, 15 and 20 are outliers

myboxplot <- boxplot(x) # now you should see your three outliers

myboxplot$out # it will print the values of the outliers

# additionally, myboxplot stores a series of other useful statistics, try

names(myboxplot)

# you shold get something like
# [1] "stats" "n"     "conf"  "out"   "group" "names"
# try for example

myboxplot$stats

# Hope this is useful to you.




More information about the R-help mailing list