I'm working on this dataframe:
Col0 <- c("AA", "BB", "CC", "DD","EE","FF")
Col1 <- c(2,2,2,6,1,1)
Col2 <- c(2,2,2,1,3,4)
Col3 <- c(2,2,3,4,6,6)
Col4 <- c(2,2,3,1,2,1)
Col5 <- c(2,1,1,1,1,4)
Col6 <- c(2,4,2,5,4,4)
Col7 <- c(2,4,2,5,4,4)
Col8 <- c(2,2,3,4,5,4)
Col9 <- c(1,3,3,2,2,2)
df<-data.frame(Col0,Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9)
And I created a plot using ggplot2
Plot <- function(fun){
df<-melt(fun,id =c("Col0"))
colnames(df)[colnames(df) == 'value'] <- 'Val'
colnames(df)[colnames(df) == 'variable'] <- 'Col_i'
pl<- ggplot(df, aes(Col_i, Val, group=Col0)) + geom_line(aes(color=Col0))+theme(
axis.text.x = element_text(angle = 90, hjust = 1))+ ggtitle(paste("Plot"))+ labs(color = "Letters")+ theme( panel.border = element_rect(colour = "black", fill=NA, size=1))
print(pl)
}
Plotf <- Plot(df)
Starting from the assumption that the df can have n rows, I need to know how to print n graphs (one for each row) with only one function.