So I want to plot multiple plots at the same time for each place with Num of Visits on y-axis and Day on x-axis but I'm not sure if there is a function to do this?
So I was able to make a plot for place A by subsetting place A :
placeA <- subset(df$place=="A")
ggplot(data=placeA, aes(x=Day, y=Num_OfVisits, group=1)) +
geom_line(color="#00AFBB", size=0.5) +
theme(axis.text.x=element_text(angle=90,hjust=1, size=5))
But now I want to generate a plot for the other places and I am hoping that I could do it all in one shot because there are around 1000 places on my dataset and subsetting is taking some time. Any help will be appreciated. Thank you!
You can write a function that takes the data frame and
Place
as inputs then loop through all the values inPlace
column to create the corresponding plots.Loop through
Place
var, create plots & store them in a list usingpurrr::map()
Display all plots with
purrr::walk()
Save all plots to PNG files using
purrr::iwalk()
Combine all plot together if needed using
cowplot::plot_grid()
Created on 2018-10-19 by the reprex package (v0.2.1.9000)