在ggplot中使用QQ绘图功能

时间:2019-09-26 01:25:01

标签: r ggplot2

我是R的新手,并且有一个包含8列的数据框,该框每天都有利率变化。我可以使用以下代码绘制8列中每列的QQ图数据:

par(mfrow = c(2,4))
for(i in 1:length(column_names)){
  qqnorm(deltaIR.df[,i],main = column_names[i], pch = 16, cex = .5)
  qqline(deltaIR.df[,i],cex = .5)
}

我现在想在ggplot2包中使用stat_qq函数来更优雅地完成此操作,但是我无法理解语法-我一直弄错了。有人可以帮我翻译以上代码以使用ggplot,并允许我在具有适当标题的一页上查看我的8个QQ图吗?尝试显而易见的

ggplot(deltaIR.df) + stat_qq(sample = columns[i])

仅给我一条错误消息

Warning: Ignoring unknown parameters: sample
Error: stat_qq requires the following missing aesthetics: sample

并添加美学

ggplot(deltaIR.df, aes(column_names)) + stat_qq()

没有更好。错误消息只是更改为

Error: Aesthetics must be either length 1 or the same as the data (5271)

简而言之,到目前为止,我所做的一切(即使在Google的帮助下)也无法使我更接近解决方案。我可以要求指导吗?

0 个答案:

没有答案