atomtemplates is a comprehensive R package that provides templates, themes, and utilities for standardizing data visualizations and analyses. This package ensures consistent branding, accessibility, and quality across all data products.
You can install most recent stable version of atomtemplates from GitHub:
# install.packages("devtools")
devtools::install_github("michaellopez/atomtemplates")Professional ggplot2 themes aligned with Atom brand guidelines:
library(atomtemplates)
library(ggplot2)
# Apply Atom theme to any ggplot
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
theme_atom() # Default Atom theme
# Available theme variants
theme_atom_classic() # Traditional academic style
theme_atom_minimal() # Clean, minimal design
theme_atom_dark() # Dark mode for presentations
theme_atom_map() # Optimized for maps
theme_atom_print() # Print-ready formatting
# Shiny dark/light mode switching
theme_atom_switch(input$dark_mode_toggle) # Returns appropriate theme
make_theme_reactive(input) # Creates reusable reactive themeComprehensive color palettes with accessibility built-in:
# Access Atom colors
atom_colors() # Core brand colors
atom_colors_primary() # Primary palette
atom_colors_extended() # Extended palette
# Apply color scales to plots
ggplot(diamonds, aes(cut, fill = color)) +
geom_bar() +
scale_fill_atom() + # Discrete colors
theme_atom()
# Continuous color scales
ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
geom_tile() +
scale_fill_atom_c() + # Continuous colors
theme_atom()
# View available palettes
view_atom_palettes()
list_atom_palettes()Create interactive charts with Atom theming using Highcharter:
library(highcharter)
# Basic themed chart
hchart(mtcars, "scatter", hcaes(wt, mpg, group = factor(cyl))) |>
hc_atom_theme() |>
hc_title(text = "Weight vs MPG")
# Bar chart with tooltips
hchart(data, "column", hcaes(x = category, y = value)) |>
hc_atom_theme() |>
hc_tooltip_atom(decimals = 0, suffix = " units") |>
hc_add_atom_logo()
# Dark mode support in Shiny
output$chart <- renderHighchart({
hchart(data, "line", hcaes(x = date, y = value)) |>
hc_atom_theme(input$dark_mode) |>
hc_yaxis_atom(title = "Value", prefix = "$")
})
# Specialized chart types
hc_histogram_atom(mtcars$mpg, title = "MPG Distribution")
hc_lollipop_atom(categories, values, title = "Rankings")
hc_dumbbell_atom(categories, start_vals, end_vals, title = "Change")Create interactive maps with Atom styling using mapgl:
library(mapgl)
library(dplyr)
# Initialize an Atom-styled map (themes: light, dark, satellite, minimal)
atom_mapgl(theme = "light") |>
add_fill_layer(
id = "counties",
source = my_sf_data,
fill_color = "#8B4D3B",
fill_opacity = 0.7,
popup = "popup_column"
) |>
add_atom_popup_style() |>
add_legend(
"My Legend",
values = legend_values,
colors = legend_colors,
style = atom_legend_style()
)
# Create rich popup content with metrics
my_data <- my_data |>
rowwise() |>
mutate(
popup = atom_popup_html_metrics(
title = name,
subtitle = "Category",
metrics = c(
"Population" = scales::comma(population),
"Rate" = paste0(rate, "%")
),
footer = "Source: Data source"
)
) |>
ungroup()Create publication-ready tables with Atom styling:
# GT tables with Atom theme
atom_table_gt(mtcars,
title = "Motor Trend Car Data",
subtitle = "1974 Motor Trend US magazine",
highlight_columns = c("mpg", "hp")
)
# Interactive Reactable tables
atom_table_reactable(mtcars,
searchable = TRUE,
sortable = TRUE,
pagination = TRUE,
highlight_row_on_hover = TRUE
)
# Simplified wrapper
atom_table(mtcars,
type = "gt", # or "reactable"
title = "My Table"
)Quickly scaffold new projects with Atom standards:
# Create a new analysis project
start_project(
name = "quarterly-analysis",
type = "analysis",
include_git = TRUE,
include_renv = TRUE
)
# Create a Shiny dashboard
start_project(
name = "data-dashboard",
type = "shiny_dashboard"
)
# Available project types:
# - "basic": Simple R project
# - "analysis": Data analysis with targets
# - "report": Quarto report template
# - "shiny_app": Basic Shiny application
# - "shiny_dashboard": Full dashboard
# - "package": R package structureGenerate professional reports and presentations:
# Create an Atom report
use_quarto_report(
title = "Quarterly Report",
author = "Your Name",
path = "reports/"
)
# Create presentation slides
use_quarto_slides(
title = "Data Insights",
path = "presentations/"
)
# Create a web document
use_quarto_web(
title = "Interactive Analysis",
path = "web/"
)STILL UNDER CONSTRUCTION Set up reproducible analysis pipelines:
# Add targets to existing project
use_targets(
type = "analysis", # or "etl", "modeling"
path = "."
)# Setup Google Fonts for consistency
setup_atom_google_fonts()
# Get appropriate font family
atom_font_family()# Save plots with consistent settings
save_atom_plot(
plot = my_plot,
filename = "analysis.png",
width = 10,
height = 6,
dpi = 300
)# Add Atom logo to plots
my_plot + add_atom_logo(position = "bottom-right")# Check if colors meet WCAG standards
check_plot_accessibility(my_plot)# Update package assets
update_atom_assets()
# Get specific assets
get_atom_asset("logo", category = "logos")library(atomtemplates)
library(ggplot2)
library(dplyr)
# Set up fonts (run once per session)
setup_atom_google_fonts()
# Create a simple bar chart
mtcars %>%
group_by(cyl) %>%
summarise(avg_mpg = mean(mpg)) %>%
ggplot(aes(factor(cyl), avg_mpg, fill = factor(cyl))) +
geom_col() +
scale_fill_atom() +
theme_atom() +
labs(
title = "Average MPG by Cylinder Count",
subtitle = "Motor Trend Car Road Tests",
x = "Cylinders",
y = "Miles per Gallon",
fill = "Cylinders"
)# Create a new dashboard project
start_project("my-dashboard", type = "shiny_dashboard")
# This creates a complete dashboard structure with:
# - app.R with Atom theming
# - modular structure
# - Atom color scheme
# - Responsive layout# Create a report project
use_quarto_report(
title = "Annual Data Report",
author = "Data Team"
)
# This generates:
# - Quarto document with Atom styling
# - Bibliography support
# - Professional formatting
# - Export to PDF/HTML/Word| Category | Key Functions | Description |
|---|---|---|
| Themes | theme_atom(), theme_atom_*(), theme_atom_switch() |
ggplot2 themes for consistent styling |
| Colors | scale_*_atom(), atom_colors() |
Color palettes and scales |
| Highcharter | hc_atom_theme(), hc_theme_atom_*(), hc_colors_atom() |
Interactive Highcharter charts |
| Tables | atom_table_gt(), atom_table_reactable() |
Formatted tables |
| Dashboards | atom_dashboard_theme(), make_theme_reactive() |
Shiny dashboard components |
| Projects | start_project(), use_*() |
Project scaffolding |
| Maps | atom_mapgl(), atom_legend_style(), atom_popup_html_metrics(), add_atom_popup_style() |
Interactive mapping with mapgl |
| Utilities | save_atom_plot(), add_atom_logo() |
Helper functions |
- Always use Atom themes for consistency
- Check accessibility with
check_plot_accessibility() - Use semantic color mappings from Atom palettes
- Include descriptive titles and subtitles
- Export at 300 DPI for print materials
- Use project templates to maintain structure
- Implement targets for reproducible workflows
- Version control with git (included in templates)
- Document dependencies with renv
- Cache interactive plots when working with large datasets
- Use appropriate table type (GT for static, Reactable for interactive)
- Optimize map layers by simplifying geometries when needed
- R ≥ 4.3.0
- Core dependencies: ggplot2, gt, reactable, bslib, sass, highcharter
- Optional: quarto (for reports), shiny (for apps), targets (for pipelines), mapgl (for maps)
We welcome contributions! Please see our Contributing Guidelines for details.
# Clone the repository
git clone https://github.com/michaellopez/atomtemplates.git
# Install development dependencies
devtools::install_deps(dependencies = TRUE)
# Run checks
devtools::check()- Documentation: Full function documentation available via
?function_name - Issues: GitHub Issues
GPL-3 © Michael Lopez
This package was developed to standardize and improve data visualization practices across personal projects.
For more examples and detailed documentation, visit the package website.
