qqplot 不会作图。将数据帧转换为向量时出错

qqplot would not graph. Error in converting dataframe into a vector

data = read.csv("HeatofCombustion.csv", header=T) 
attach(data)
library(lattice)
x = data[ , "Qc"]
qqplot(x=qexp(x), y=data, main="Exponential Q-Q Plot",
       xlab="Theoretical Quantiles", ylab= "Your Data Quantiles")

错误:

Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : 
  undefined columns selected
In addition: Warning messages:
1: In qexp(x) : NaNs produced
2: In xtfrm.data.frame(x) : cannot xtfrm data frames

为什么会这样?我以为我已经使用 x = data[ , "Qc"] 将数据帧转换为向量 我正在尝试在 R 中绘制指数 Q-Q 图。非常感谢。

数据查看:

变量Qc(热容量)的实际数据:

Qc = c(17.39, 6.68, 23.31, 47.74, 
19.53, 45.8, 26.75, 26.86, 29.62, 28.39, 34.21, 43.65, 24.13, 
31.37, 25.42, 27.91, 30.9, 31.07, 38.35, 29.18, 26.45, 25.27, 
26.92, 24.97, 39.84, 29.38, 31.53, 31.06, 18.71, 29.92, 32.5, 
31.07, 31.48, 31.23, 31.15, 31.65, 26.03, 28.61, 30.65, 34.39, 
30.28, 30.63, 34.89, 26.5, 29.59, 29.06, 26.54, 25.92, 33.64)

这个功能可能有点太花哨了,但应该做你想做的。 (qfun.args/do.call 废话是允许你为目标分布包含额外的形状参数,这在这里似乎没有必要——因为 Q-Q 图的方式经评估,比例和位置参数的变化对它们的外观影响不大。)

它基本上只是封装和概括 ?qqplot 中显示的 chi-squared 示例...生成 x-variable,您使用 ppoints() 生成一组适当的等距分位数点,然后使用目标分布的分位数 (q*) 函数将其转换为理论分位数。

qfun <- function(y, qfun = qnorm, qfun.args = NULL, ...) {
    n <- length(y)
    qqplot(do.call(qfun,
                   c(list(ppoints(n)), qfun.args)),
           xlab = "",
           y, ...)
    qqline(y,
           distribution = function(p) do.call(qfun, c(list(p), qfun.args)),
           probs = c(0.1, 0.6), col = 2)
}

试试看:

qfun(Qc, main = "Gaussian")
qfun(Qc, qexp, main = "Exponential")

library(VGAM)
qfun(Qc, qgumbel, main = "Gumbel")