diff --git a/DESCRIPTION b/DESCRIPTION index 5be91b3..e423014 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,7 @@ RoxygenNote: 7.3.2 Imports: colorspace, dplyr, - ggplot2, + ggplot2 (>= 3.0.0), gt, rlang, showtext, diff --git a/NAMESPACE b/NAMESPACE index 37cfd1e..a2ead15 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(geom_path) export(geom_point) export(geom_step) export(geom_text) +export(gt_ojo) export(gt_okpi) export(ojo_analyst_name_text) export(ojo_gt_captions) diff --git a/R/ojo_gt.R b/R/ojo_gt.R index 1b844dc..43c5621 100644 --- a/R/ojo_gt.R +++ b/R/ojo_gt.R @@ -42,14 +42,23 @@ gt_okpi <- function(data, font = gt::google_font(font) ) |> gt::tab_style( - style = gt::cell_text(weight = "bold", - color = ojothemes::okpi_red, - size = gt::px(font_size * 2)), + style = list( + gt::cell_text(weight = "bold", + color = ojothemes::okpi_red, + size = gt::px(font_size * 2)), + gt::css(padding.left = "10px", + border.left = paste0("10px solid ", okpi_red, ";")) + ), locations = gt::cells_title(groups = "title") ) |> gt::tab_style( - style = gt::cell_text(style = "italic", - size = gt::px(font_size * 1.25)), + style = list( + gt::cell_text(style = "italic", + color = ojothemes::okpi_blue, + size = gt::px(font_size * 1.25)), + gt::css(padding.left = "10px", + border.left = paste0("10px solid ", okpi_red, ";")) + ), locations = gt::cells_title(groups = "subtitle") ) |> gt::tab_style( @@ -133,14 +142,23 @@ gt_ojo <- function(data, font = gt::google_font(font) ) |> gt::tab_style( - style = gt::cell_text(weight = "bold", - color = "#333333", - size = gt::px(font_size * 2)), + style = list( + gt::cell_text(weight = "bold", + color = "#333333", + size = gt::px(font_size * 2)), + # I think this little splash of color is nice + gt::css(padding.left = "10px", + border.left = paste0("10px solid ", okpi_yellow, ";")) + ), locations = gt::cells_title(groups = "title") ) |> gt::tab_style( - style = gt::cell_text(style = "italic", + style = list( + gt::cell_text(style = "italic", size = gt::px(font_size * 1.25)), + gt::css(padding.left = "10px", + border.left = paste0("10px solid ", okpi_yellow, ";")) + ), locations = gt::cells_title(groups = "subtitle") ) |> gt::tab_style( diff --git a/R/zzz.R b/R/zzz.R index b710a63..6ede1a8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -19,18 +19,4 @@ sysfonts::font_add_google("Roboto Condensed") showtext::showtext_auto() - # check ggplot2 version - if (unlist(utils::packageVersion("ggplot2"))[1] < 3) { - packageStartupMessage( - "Warning: ojothemes requires ggplot2 version 3.0.0 or higher." - ) - } - - # check that ggplot2 is already loaded - if (!"ggplot2" %in% (.packages())) { - packageStartupMessage( - "Warning: ggplot2 needs to be loaded before ojothemes is loaded. Consider restarting your R session." - ) - } - } diff --git a/man/gt_ojo.Rd b/man/gt_ojo.Rd new file mode 100644 index 0000000..2fc60cb --- /dev/null +++ b/man/gt_ojo.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ojo_gt.R +\name{gt_ojo} +\alias{gt_ojo} +\title{gt_ojo Function} +\usage{ +gt_ojo( + data, + title = NA, + subtitle = NA, + font_size = 14, + font = "Roboto Mono", + format_cols = TRUE, + analyst_name = NA, + source = NA +) +} +\arguments{ +\item{data}{A data frame to be converted into a gt table.} + +\item{title}{Optional. A title for the table. Default is NA.} + +\item{subtitle}{Optional. A subtitle for the table. Default is NA.} + +\item{font_size}{The font size for the table. Default is 14.} + +\item{font}{The font family to use. Default is Roboto Condensed.} + +\item{format_cols}{Should gt::fmt_auto() be applied to all cols?} + +\item{analyst_name}{The name of the analyst to credit in the footnote} + +\item{source}{The source / domain of the data} +} +\value{ +A gt table based on the input data frame with specified modifications. +} +\description{ +gt_ojo Function +} +\examples{ +\dontrun{ +okpi_gt(data = mtcars, title = "Motor Trend Car Road Tests", subtitle = "From mtcars") +} +}