I created 20 data frames in a loop already. And assigned them in the loop as below
for(x in 1:20){
my_file <- read.table(paste0("file_name",x), head=TRUE) %>%
select(Count, Total) %>%
data.frame()
assign(paste0("my_file_",x), my_file)
}
And I get each data frame just like this: (each data frame has the same Count names with the same sequence but the numbers are different)
Count Total
A 22
B 31
C 45
D 70
How can I make the mosaic plot for each data frame and put them on one page, with the same arrangement as below?
Block A Block B
Block C Block D
Thank you so much for your help!
The details depend on the particular package/function you are using. If you use the base
mosaicplot()
function, you can simply employpar(mfrow = c(..., ...))
with a suitable layout. If you are usingmosaic()
fromvcd
then you can either create your ownviewport()
with agrid.layout()
or use themplot()
function for that purpose. Seeexample("Ord_plot", package = "vcd")
for a worked example.