add_ggplot | R Documentation |
Add an ggplot plot inside the body of the email with this helper function.
add_ggplot(
plot_object,
width = 5,
height = 5,
alt = NULL,
align = c("center", "left", "right", "inline"),
float = c("none", "left", "right")
)
plot_object |
The |
width |
The width of the output plot in inches. |
height |
The height of the output plot in inches. |
alt |
Text description of image passed to the |
align |
The alignment to be used for the image. If not |
float |
The float value to be used for the image. If not |
An HTML fragment that can be placed inside the message body wherever the plot image should appear.
library(ggplot2)
# Create a ggplot plot
plot <-
ggplot(
data = mtcars,
aes(x = disp, y = hp,
color = wt, size = mpg)) +
geom_point()
# Create an HTML fragment that
# contains an the ggplot as an
# embedded plot
plot_html <-
add_ggplot(plot_object = plot)
# Include the plot in the email
# message body by simply referencing
# the `plot_html` object
email <-
compose_email(
body = md(
c(
"Hello!
Here is a plot that will change
the way you look at cars forever.\n",
plot_html,
"Let me know what you think
about it!"
)
)
)
if (interactive()) email
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.