Combine multiple plots, generated using the “by” R function, in one figure
问题 I have a data frame containing multiple numeric columns and one column with different factors. I'd like to produce a unique image containing the plots of the numeric columns, by factor. I tried the following: varA <- runif(40) varB <- runif(40) varB <- runif(40) varC <- runif(40) mainVar <- c(rep('cat', 10), rep('dof', 10), rep('mouse', 10), rep('frog', 10)) plotData <- data.frame(varA, varB, varC, mainVar) pdf('asd.pdf') par(mfrow=c(2,2)) by(plotData, plotData$mainVar, function(x){ par(mfrow