Reputation: 96
I am in the strange position of being responsible for data visualization, but there is a good chance that our client will want to change some or all of the graphs I create after they are delivered. Is there an R package (or technique) which can export raw data used to make ggplot2 graphs as .csv files along with the images as they are created?
For example, in a bar chart, I take a survey response, which is a string, and turn it into a factor variable, using
ggplot(subset(data.df, !is.na(xvar)), aes(factor(xvar))
in order to plot it. I can go through the extra step of selecting the subset of my data again and writing a little .csv file with just the IDs and that variable, but it will be a string again. Help me! I don't want to have to do all this in Excel.
Upvotes: 1
Views: 580
Reputation: 96
I found it out; it's very simple.
For example, if your graph is p
, then simply type p$data
to output the data frame that was used to in its creation. I'll report back if I find a way to just output the data that's represented in the graph (as opposed to the entire data frame).
Upvotes: 1
Reputation: 94277
Just do everything in a knitr script, that takes an agreed input file, does all your manipulation, creates the graphs. Then give that to your client. If they want to change things then they can either supply new data or edit your script.
Upvotes: 0