This vignette will take you from zero to publishing your dashboard online in under 10 minutes. No prior Git or GitHub knowledge required!
⚠️ IMPORTANT: Data Privacy Warning
When you publish a dashboard, all data embedded in your visualizations becomes publicly accessible. Before publishing, verify that your dashboard does not contain:
- Personal identifiable information (PII) - names, emails, addresses, ID numbers
- Sensitive survey responses - individual-level data that could identify respondents
- Confidential research data - unpublished findings, proprietary information
- Location data - precise coordinates that could identify individuals
How dashboardr protects you:
- Data is aggregated for visualizations (counts, percentages, means)
- Individual-level microdata is not exported to the final HTML
- Only the summary statistics needed to render charts are included
- Automatic .gitignore protection - Data files are automatically excluded from Git commits
About .gitignore protection:
The
.gitignorefile in your dashboard folder automatically excludes data files from being published:
- Common data file extensions (
.csv,.rds,.xlsx,.sav,.dta) are ignored by default- Large files (>10MB) are automatically detected and added to
.gitignore- Check your
.gitignorefile to verify your data files match the patternsBest practices:
- Review before publishing - Open your generated HTML files and inspect what data is visible
- Remove identifying variables - Drop columns like names, IDs, or exact dates before creating visualizations
- Test with
render = TRUE, open = "browser"- Review the full dashboard locally before pushing to GitHub- Consider access controls - For sensitive data, use private repositories or institutional hosting instead of public GitHub Pages
By the end of this guide, you’ll be able to:
You need:
dashboardr package installedgetting-started vignette if you need to create one)# Install packages if you don't have them
install.packages(c("usethis", "gert"))
library(dashboardr)⚡ Already have Git and GitHub set up?
If you already have Git installed, a GitHub account, and a Personal Access Token configured, you can skip directly to Part 2: Publishing Your Dashboard.
Git is the tool that tracks changes to your files. It needs to be installed before R can use it.
Git usually comes pre-installed. To check or update:
xcode-select --installGit needs to know your name and email. Run this in R with your information:
library(usethis)
use_git_config(
user.name = "Your Username",
user.email = "[email protected]"
)Important: Use the same email you’ll use for GitHub.
Run this command to verify your setup:
You should see:
GitHub will host your dashboard for free.
GitHub needs a way to verify it’s really you. We’ll create a Personal Access Token (PAT).
Run this command in R:
This will:
On the GitHub page:
ghp_xxxxxxxxxxxx)Now comes the fun part - publishing your dashboard!
First, create and render your dashboard as usual:
# Example dashboard
my_data <- data.frame(
category = c("A", "B", "C", "D"),
value = c(23, 45, 67, 34)
)
viz <- create_viz(type = "bar", x_var = "category") %>%
add_viz()
dashboard <- create_dashboard(
output_dir = "my_dashboard",
title = "My First Dashboard"
) %>%
add_page(
name = "Analysis",
data = my_data,
visualizations = viz
)
# Generate the dashboard files
generate_dashboard(dashboard, render = TRUE)Now for the magic command with the key arguments shown explicitly:
publish_dashboard(
message = "Initial commit", # Your commit message
path = "/docs" # Folder with your dashboard (default)
)Or simply:
Important: publish_dashboard() works
from your current working directory. It will:
/docs folder to GitHub
PagesMain arguments you might want to customize:
message - Your initial commit message
(default: "Initial commit")
publish_dashboard(message = "Launch my analysis dashboard")private - Create a private repository
(default: FALSE)
publish_dashboard(private = TRUE)path - Which folder contains your site
files (default: "/docs")
/docs (with leading slash) tells GitHub Pages to
serve from the docs/ folder in your repository rootgenerate_dashboard() creates your HTML
files.gitignore file is created
(automatically excludes data files, large files >10MB, and temporary
files)Important notes:
Your dashboard URL will be shown in the output and will look like:
https://YOUR-USERNAME.github.io/your-dashboard-name/
Copy this URL and wait 2-5 minutes, then visit it to see your live dashboard!
For more advanced scenarios:
Made changes to your dashboard? Here’s how to update the published version.
Make your changes and regenerate:
# Make changes to your dashboard
dashboard <- create_dashboard(
output_dir = "my_dashboard",
title = "My Updated Dashboard"
) %>%
add_page(
name = "Analysis",
data = my_data,
visualizations = viz,
text = "Now with more insights!" # Added new content
)
# Regenerate
generate_dashboard(dashboard, render = TRUE)What happens:
Safety feature: By default,
update_dashboard() will show you what files will be pushed
and ask for confirmation. Type yes or y to
proceed.
That’s it! Your changes will be live in 1-2 minutes. The function will display your dashboard URL - just refresh the page to see your updates.
# Custom commit message
update_dashboard(message = "Added new visualizations")
# Update specific files only
update_dashboard(
files = c("docs/index.html", "docs/analysis.html"),
message = "Updated main pages"
)
# Update all HTML files
update_dashboard(
files = "docs/*.html",
message = "Regenerated all pages"
)
# Skip confirmation prompt (not recommended!)
update_dashboard(ask = FALSE)Here’s a full example from start to finish:
library(dashboardr)
# 1. Create your dashboard
my_data <- mtcars
viz <- create_viz(type = "bar", x_var = "cyl") %>%
add_viz(text = "Cars by Cylinder Count")
dashboard <- create_dashboard(
output_dir = "mtcars_dashboard",
title = "Motor Trends Car Analysis"
) %>%
add_page(
name = "Overview",
data = my_data,
visualizations = viz
)
# 2. Generate the dashboard
generate_dashboard(dashboard, render = TRUE)
# 3. Publish (only needed once!)
publish_dashboard(message = "Initial publication")
# ... time passes, you make changes ...
# 4. Regenerate with changes
generate_dashboard(dashboard, render = TRUE)
# 5. Push updates
update_dashboard(message = "Updated car analysis")Problem: R can’t find your GitHub token.
Solution: Run gitcreds::gitcreds_set()
and paste your token again.
Problem: Git isn’t installed or R can’t find it.
Solution: 1. Install Git (see Step 1) 2. Restart
RStudio 3. Run git_sitrep() to verify
Problem: You’re trying to publish a second time.
Solution: Use update_dashboard()
instead of publish_dashboard().
Problem: Git wasn’t initialized properly, or you’re trying to update before publishing.
Solution: 1. Make sure you’ve run
publish_dashboard() at least once 2. Run
publish_dashboard() first to initialize Git and create the
repository
Problem: Your site isn’t deployed yet, or Pages isn’t configured.
Solution: 1. Wait 2-5 minutes after first publish 2.
Check your repository settings on GitHub 3. Make sure “Pages” is enabled
and set to deploy from /docs folder
Problem: Your data files are being uploaded to GitHub.
Solution: The .gitignore file should
automatically exclude data files. Check: 1. Look for a
.gitignore file in your dashboard folder 2. Make sure your
data files match the patterns (.csv, .rds, etc.) 3. Large files
(>10MB) are automatically detected and ignored
The publishing functions automatically exclude: - All common data file formats (CSV, RDS, Excel, etc.) - Large files (>10MB) - Data directories
This keeps your repository small and protects sensitive data.
Instead of:
Do this:
Always run
generate_dashboard(dashboard, render = TRUE, open = "browser")
to preview your changes before publishing.
It’s easier to push small, frequent updates than large, infrequent ones. Update after each significant change.
After updating, wait 1-2 minutes then visit your dashboard URL to verify the changes appear correctly.
Now that your dashboard is published, you can:
Happy publishing! 🎉
For more advanced features, see: -
vignette("advanced-features", package = "dashboardr") -
GitHub Pages documentation: https://docs.github.com/pages