yLab of plots created with forloop in plot()

Viewed 112

I produce a batch of plot from a data frame (df) with below code :

par(mfrow=c(7,8))
for (i in 1:51) plot(df[,52], df[[i]],type="p", pch=19, cex=1.6)

How to set only corresponding colnames of the df as ylab of each plots and one main xlab equal to df[,52] ?

1 Answers

You could do something like this.

plot(df[, 52], df[, i], type = "p", pch = 19, cex = 1.6,
     ylab = names(df[, i, drop = FALSE]),
     xlab = names(df[, 52, drop = FALSE]))
Related