Getting data frame name

I am writing a wrapper function to build multiple data frames:

gf <- function(dataframe){
  ggplot(dataframe, aes(x=Date, y=Close)) + 
  geom_point() + 
  ggtitle(nameofdataframe))

and I cannot understand the last part how to get the name of the data frame as a variable used in ggtitle (). Please, help.

+5
source share
1 answer

This will be done:

ggtitle(deparse(substitute(dataframe)))

deparse()converts the variable name to a character string, substitute()allows you to use it in the plot.

+7
source

All Articles