#' @title Create a Plot of Iris Data
#' @description Create a specific histogram for the \code{iris} data
#' @param data the \code{iris} dataset
#' @name create_plot
#' @importFrom ggplot2 ggplot
#' @importFrom ggplot2 aes
#' @importFrom ggplot2 geom_histogram
#' @importFrom ggplot2 theme_gray
#' @importFrom ggplot2 facet_wrap
#' @return a \link{ggplot2} plot object
#' @rdname create_plot
#' @export
create_plot <- function(data) {
hist_plot <- ggplot2::ggplot(data, ggplot2::aes(x = Petal.Width, fill = Species)) +
ggplot2::geom_histogram(binwidth = 0.25) +
ggplot2::theme_gray(20) +
ggplot2::theme(line = ggplot2::element_line(size = ggplot2::rel(.5)),
text = ggplot2::element_text(size = 6))
return(hist_plot)
}
#' @rdname create_plot
#' @export
create_facet_plot <- function(data) {
hist_plot <- ggplot2::ggplot(data, ggplot2::aes(x = Petal.Width, fill = Species)) +
ggplot2::geom_histogram(binwidth = 0.25) +
ggplot2::facet_wrap(~ group, ncol = 1) +
ggplot2::theme_gray(20) +
ggplot2::theme(line = ggplot2::element_line(size = ggplot2::rel(.5)),
text = ggplot2::element_text(size = 6))
return(hist_plot)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.