I tried this all morning and still can't find a solution after reading the related entry in stackoverflow
I have the following code:
names <- colnames(df[17:length(df)])
counter = 17L
for (i in 1:length(names)) {
df.tax <- subset(df, df[,c(counter)] != 0)
counter = counter + 1L
meta <- subset(df.tax, select=c(1:16))
meltmeta <- melt(meta, id=c("Collector", "Year","Week","Cities","Provinces"))
ppv <- ggplot(meltmeta, aes(title = paste(names[i]), factor(Provinces), value))
ppv + geom_boxplot() + geom_boxplot(aes(fill=Collector), alpha=I(0.5)) + geom_point(aes(color=Collector), size=1) +facet_wrap(~variable, scale="free")
ggsave(file = paste(names[i], sep=".","provinces_vs_climate.pdf"), width=16, height=8)
}
My problem: I cannot add the correct header for ggplot. At each iteration of the for loop, I create a new dataframe called df.tax, by a subset of the df parts. I am melting df and then trying to generate a graph using ggplot.
I managed to save each plot with a different file name (based on an array of names) at each iteration on ggsave, but ggplot just continues to generate the header "paste (names [i])" for each graph.
I tried get (), paste (), labs () ... etc, but no one works
Does anyone know how I can solve this problem?