[英]Write a R function GroupSummary(x) that will display the five-number summary for two separate groups from a vector x
[英]Remove outlier from five-number summary statistics
boxplot
返回一個命名列表,其中包含可用於刪除調用fivenum
時的異常值的內容:
$out
包括文字異常值。 使用setdiff(data$`Weight(g)`)
可能很誘人,但由於R FAQ 7.31 (和浮點相等性),這可能容易出現問題,所以我建議不要這樣做; 反而,
$stats
包括用於箱線圖本身的數字,沒有異常值。 我建議我們一起工作。
(順便說一句, title(.)
通過副作用完成它的工作,並且它沒有被text(.)
使用,我建議你移動那個電話。)
可重現的數據/代碼:
vec <- c(1, 10:20, 30)
bp <- boxplot(vec)
str(bp)
# List of 6
# $ stats: num [1:5, 1] 10 12 15 18 20
# $ n : num 13
# $ conf : num [1:2, 1] 12.4 17.6
# $ out : num [1:2] 1 30
# $ group: num [1:2] 1 1
# $ names: chr "1"
five <- fivenum(vec[ vec >= min(bp$stats) & vec <= max(bp$stats)])
text(x=1.25, y=five, labels=five)
title("Weight(g)")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.