I am working with a data set where I have a few variables that I'm constantly graphing that come out of CSV files with a specific naming convention. So for example I'll have something like:
p <- ggplot(plot_df, aes(x=ms, y=bandwidth)) + geom_line()
And by default, the graph's x and y titles will come out 'ms' and 'bandwidth', respectively. What I'd like to be able to do is to define a function that has a list of these mappings like:
"bandwidth"->"Bandwidth (GB/s)"
"ms"->"Time (ms)"
so I can feed p to a function that will essentially execute:
p + xlab("Time (ms)") + ylab("Bandwidth GB/s")
automatically without me having to keep specifying what the labels should be. In order to do this, I need to somehow get access to the x and y titles as a string. I'm having a hard time figuring out how I can get this information out of p.
EDIT: I guess typically the y axis comes out as 'value' because of melt, but for argument's sake, let's just say I'm doing the x axis for now.
