我正在使用从下面提供的工作示例中调用x
的数据框调用的变量构建分位数-分位数图。df
我想用name
我的数据集的变量标记这些点df
。
是否可以在 ggplot2 中做到这一点而不诉诸痛苦的解决方案(手动编码理论分布,然后将其与经验分布相比较)?
编辑:碰巧是的,这要感谢一个发布然后删除他的答案的用户。请参阅下面 Arun 回答后的评论。感谢 Didzis 的巧妙解决方案ggbuild
。
# MWE
df <- structure(list(name = structure(c(1L, 2L, 3L, 4L, 5L, 7L, 9L,
10L, 6L, 12L, 13L, 14L, 15L, 16L, 17L, 19L, 18L, 20L, 21L, 22L,
8L, 23L, 11L, 24L), .Label = c("AUS", "AUT", "BEL", "CAN", "CYP",
"DEU", "DNK", "ESP", "FIN", "FRA", "GBR", "GRC", "IRL", "ITA",
"JPN", "MLT", "NLD", "NOR", "NZL", "PRT", "SVK", "SVN", "SWE",
"USA"), class = "factor"), x = c(-0.739390016757746, 0.358177826874146,
1.10474523846099, -0.250589535389937, -0.423112615445571, -0.862144579740376,
0.823039669834058, 0.079521521937704, 1.08173649722493, -2.03962942823921,
1.05571087029737, 0.187147291278723, -0.144770773941437, 0.957990771847331,
-0.0546549555439176, -2.70142550075757, -0.391588386498849, -0.23855544527369,
-0.242781575907386, -0.176765072121165, 0.105155860923456, 2.69031085872414,
-0.158320176671995, -0.564560815972446)), .Names = c("name",
"x"), row.names = c(NA, -24L), class = "data.frame")
library(ggplot2)
qplot(sample = x, data = df) + geom_abline(linetype = "dotted") + theme_bw()
# ... using names instead of points would allow to spot the outliers
我正在修改这个要点,如果我对回归诊断有任何疑问,我会考虑向 CrossValidated 发送其他问题,这可能是 CV 用户感兴趣的。