简体   繁体   English

R QQ图未显示

[英]R QQ-plot not showing

doing an online course and i was given the following task: 做一个在线课程,我得到了以下任务:

load("skew.RData")

Using QQ-plots, compare the distribution of each column of the matrix to a normal. 使用QQ绘图,将矩阵每一列的分布与正态分布进行比较。 That is, use qqnorm() on each column. 也就是说,在每列上使用qqnorm()。 To accomplish this quickly, you can use the following line of code to set up a grid for 3x3=9 plots. 要快速完成此任务,可以使用以下代码行为3x3 = 9的图设置网格。 ("mfrow" means we want a multifigure grid filled in row-by-row. Another choice is mfcol.) (“ mfrow”表示我们希望将多图网格逐行填充。另一个选择是mfcol。)

par(mfrow = c(3,3))

Then you can use a for loop, to loop through the columns, and display one qqnorm() plot at a time. 然后,您可以使用for循环遍历各列,并一次显示一个qqnorm()图。 You should replace the text between ** with your own code. 您应该用自己的代码替换**之间的文本。

for (i in 1:9) {
  **put your qqnorm call here**
}

i have as a file calld dat, something with 9 columns and around 1000 rows. 我有一个名为dat的文件,它有9列和大约1000行。

Can somone give me a hint how the QQ-plot command could look like? somone可以给我提示QQ-plot命令的样子吗?

compare the distribution of each column of the matrix to a normal 比较矩阵的每一列与正态分布

Suppose your matrix is dat after reading in your data file, you want 假设读取数据文件后矩阵是dat

load("skew.RData")  ## read in matrix `dat`
dat <- scale(dat)  ## standardization

par(mfrow = c(3, 3))
for (i in 1:9) {
  qqnorm(dat[, i], main = paste0(i, "-th column"))
  qqline(dat[, i])
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM