Reputation: 1
I keep getting the same error and can't seem to fix it. It's supposed to produce about 6 graphs and they won't show up. Please help. I think it has something to do with the par() function.
variable <- c("Tot.Gross", "Gross.Log", "Age") # pick up the numeric columns according to the names
par(mfrow = c(3, 2)) # layout in 3 rows and 3 columns
for (i in 1:length(variable)){
sub <- unlist(salary[variable[i]])
submean <- mean(sub)
hist(sub, main = paste("Hist. of", variable[i], sep = " "), xlab = variable[i])
abline(v = submean, col = "blue", lwd = 1)
qqnorm(sub, main = paste("Q-Q Plot of", variable[i], sep = " "))
qqline(sub)
if(i == 1) {s.t <- shapiro.test(sub)
} else {s.t <- rbind(s.t, shapiro.test(sub))
}
}
Error in plot.new() : figure margins too large
Upvotes: 0
Views: 364
Reputation: 18683
Reduce the figure mar
gins. Eg.
par(mfrow=c(3, 2), mar=c(1, 1, 1, 1))
The default margins, especially for multi-panel plots, are often too large. The defaults are c(5,4,4,2) + 0.1 for the bottom, left, top, and right margins.
Upvotes: 1