I am trying to create plots with ggplot for 20 data frames ("df1" - "df20") that are contained in a list called "list1". The list looks like this:
list1 <- list(df1, df2, ..., df20)
Each data frame has two columns z and y that I want to plot against each other:
df1
z y
1 6
2 9
3 7
I have created the following code which also works but it does not provide the plots with the respective titles from df1 to df20:
lapply(list1, function(x)
ggplot(data = list1$x) +
geom_line(mapping = aes(x = x$z,
y = x$y)))
I have tried putting all names in a vector and including this vector in the code like this:
titlenames <- c(df1, df2, ..., df20)
+ ggtitle(titlenames)
but this only provides the first name for all plot.
Would appreciate any help with this as I am still quite new to R.