View source: R/save_chartdata.R
save_chartdata | R Documentation |
Grattan reports are accompanied by Excel workbooks containing the data used to produce the chart ("chart data") and the chart itself. This function takes a ggplot2 object and creates a single-sheet Excel workbook with the chart data and chart. If your ggplot2 object has a subtitle and caption, those will be properly displayed in the spreadsheet.
save_chartdata(
filename,
object = ggplot2::last_plot(),
type = "normal",
height = NULL,
select_data = TRUE,
round = NULL
)
filename |
filename of the Excel workbook you wish to create. Can be a file path, but the directory must already exist. |
object |
ggplot2 chart to create chart data from. If left blank,
|
type |
type of plot. Default is "normal". See |
height |
Numeric, optional. Use this to override the default height
for plots of your chosen 'type'; see |
select_data |
Logical, default is TRUE. Removes any columns that are not used in ggplot mappings and facets from the exported chart data. |
round |
Numeric, optional. Round numbers in the chart data to this number of decimal places. Default is NULL, which does not round numbers. |
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
theme_grattan() +
labs(title = "Title",
subtitle = "Subtitle",
caption = "Caption")
## Not run: save_chartdata("my_chartdata.xlsx", p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.