I am writing a wrapper function for plotting several data frames:
gf <- function(dataframe){
ggplot(dataframe, aes(x=Date, y=Close)) +
geom_point() +
ggtitle(nameofdataframe))
and I cannot figure out the last part, how to get the name of the data frame as a variable to use in ggtitle(). Please help.
This will do it:
deparse()converts the variable name to a character string,substitute()lets you use it in the plot.