as the title suggest, I want to plot all columns from my data.frame, but I want to do it in a generic way. All my columns are factor. Here is my code so far:
nums <- sapply(train_dataset, is.factor) #Select factor columns
factor_columns <- train_dataset[ , nums]
plotList <- list()
for (i in c(1:NCOL(factor_columns))){
name = names(factor_columns)[i]
p <- ggplot(data = factor_columns) + geom_bar(mapping = aes(x = name))
plotList[[i]] <- p
}
multiplot(plotList, cols = 3)
where multiplot function came from here: http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
And my dataset came from Kaggle (house pricing prediction): https://www.kaggle.com/c/house-prices-advanced-regression-techniques
What I get from my code is the image below, which appears to be the last column badly represented.
This would be the last column well represented:
EDIT: Using gridExtra as @LAP suggest also doesn't give me a good result. I use this instead of multiplot.
nCol <- floor(sqrt(length(plotList)))
do.call("grid.arrange", c(plotList, ncol=nCol))
but what I get is this: Again, SaleCondition is the only thing printed and not very well. PD: I also tried cowplot, same result.
SaleCondition
column to original dataset and plot everything in one graph. – pogibasgridExtra
might also help. – LAPSaleCondition
is already in the dataset, what I mean is that when I try to do subplot my data, all I have is the last column which is 'SaleCondition`. I cannot plot it all in one graph beacuse I'm want to plot bars. @LAP I'll take a look at that. – Isaac