I want to know if it is possible to see the code of the graph that is stored in a variable. For example, given the following graph:
library(ggplot2)
myData <- data.frame(x=1:100, y = 100:1)
myPlot <- ggplot(myData, aes(x,y)) + geom_line()
I would like to have a "seeCode" function that returns the actual code used to plot the graph:
>seeCode(myPlot)
ggplot(myData, aes(x,y)) + geom_line()
dugar source
share