I have been using this template script to load and plot data:
library("ggplot2")
library("scales")
library("zoo")
library("lubridate")
library("grid")
library("gridExtra")
library("gtable")
library("labeling")
Template.sum.plot <- read.csv("F:/br/RF/Template_SK.csv", header=TRUE, sep=",", dec=".", quote="")
Template.sum.plot$Template_SK.SUM=rowSums(Template.sum.plot[,-1])
Template.sum.plot$date.hour <- ymd_hms(Template.sum.plot$filenames)
Template.sum.plot<-as.data.frame(Template.sum.plot)
Template_Total.SK.Data.Table.plotted <- ggplot(data=Template.sum.plot, aes(x=date.hour, y=Template_SK.SUM)) + geom_line(color="blue") + scale_y_continuous(labels=comma) + scale_x_datetime(position="top", labels=date_format("%F"), date_breaks="1 month") + theme(axis.title.x=element_blank(), plot.title = element_text(hjust = 0.5, size = 12, margin=margin(0,0,10,0)), panel.background=element_rect(fill='white'), panel.grid.major = element_line(colour = "black", linetype=3), panel.grid.minor = element_blank(), axis.ticks.x=element_blank()) + labs(x=(paste("4WRM, ",(format(Template.sum.plot$date.hour[1], '%Y-%m-%d %T %Z'))," to ",(Template.sum.plot$date.hour[(nrow(Template.sum.plot))]))) , y="PPM\n") + ggtitle("Template PON") + geom_vline(xintercept=as.numeric(Template.sum.plot$date.hour[(which(Template.sum.plot$date.hour == paste("2019-07-12 06:00:00")))]), linetype=2, color="red") + geom_vline(xintercept=as.numeric(Template.sum.plot$date.hour[(which(Template.sum.plot$date.hour == paste("2019-09-16 06:00:00")))]), linetype=2, color="red") + geom_line(aes(y = rollmean(Template_SK.SUM, 336, na.pad=TRUE)), color = "#111111")
png(filename="F:/br/Template.SK.Data.Table.plot.png", width=30, height=5, units="in", res=600)
grobz <- lapply(list(Template_Total.SK.Data.Table.plotted), ggplotGrob)
grobz.plot <- arrangeGrob( grobs = list(rbind(grobz[[1]], size = "last")), ncol = 1)
grid.draw(grobz.plot)
dev.off()
I have been manually search/replacing 'Template' to 'XXF' and 'XXGF' and then running my script up til now, but I am wondering if I can make a list (e.g. list_data <- list(c("XXF","XXGF","XXGT") ) and swap each occurrence of 'Template' for the list names?
'Template'in the string instances.glue::glue()is a nice way to do that. But why do you need to have the variables renamed? Aren't you just going to iterate over thelist_datavalues to get the plots you need?