hmmmbob hmmmbob - 1 year ago 135
R Question

R QQ-plot not showing

doing an online course and i was given the following task:


Using QQ-plots, compare the distribution of each column of the matrix to a normal. That is, use qqnorm() on each column. To accomplish this quickly, you can use the following line of code to set up a grid for 3x3=9 plots. ("mfrow" means we want a multifigure grid filled in row-by-row. Another choice is 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. 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.

Can somone give me a hint how the QQ-plot command could look like?

Answer Source

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

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])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download