Tutorial Dashboard
  • Home
  • Example Dashboard
  • Standalone Charts
  • Text-Only Page
  • Showcase Dashboard

Example Dashboard

Here, you can see how to add text within a dashboard.

Add a new heading like this

A line break is displayed when you add a new section.

Example 1: Stacked Bars

  • Change the title here…
  • Tabset #2

If you want to add text within the tab, you can do so here.

Change the position of the text using the text_position argument.

Example 2: Heatmap

  • Trust by Education and Age
  • Trust by Region and Education

Here’s another example of the kind of plots you can generate in your dashboard.

Educational and regional patterns in trust distribution.

Back to top
Source Code
---
title: "{{< iconify ph chart-line >}} Example Dashboard"
format: html
---

Here, you can see how to add text within a dashboard.

## Add a new heading like this

A line break is displayed when you add a new section.

```{r setup}
#| echo: false
#| warning: false
#| message: false
#| error: false
#| results: 'hide'

# Load required libraries
library(dashboardr)
library(dplyr)
library(highcharter)

# Global chunk options
knitr::opts_chunk$set(
  echo = FALSE,
  warning = FALSE,
  message = FALSE,
  error = FALSE,
  fig.width = 12,
  fig.height = 8,
  dpi = 300
)

# Load data from dataset_2867obs.rds
data <- readRDS('dataset_2867obs.rds')

# Data summary
cat('Dataset loaded:', nrow(data), 'rows,', ncol(data), 'columns\n')

```

## Example 1: Stacked Bars


::: {.panel-tabset}

### {{< iconify ph chart-bar >}} Change the title here...


If you want to add text within the tab, you can do so here.

```{r demographics}
# Change the title here...
result <- create_stackedbar(
  data = data,
  title = "Change the title here...",
  x_var = "degree_1a",
  stack_var = "happy_1a",
  subtitle = "You can add a subtitle using the subtitle argument",
  x_label = "Education Level",
  y_label = "Percentage of Respondents",
  stack_label = "Happiness Level",
  stacked_type = "percent",
  x_order = c("Lt High School", "High School", "Junior College", "Bachelor", "Graduate"),
  stack_order = c("Very Happy", "Pretty Happy", "Not Too Happy"),
  tooltip_suffix = "%",
  color_palette = c("#2E86AB", "#A23B72", "#F18F01")
)

# Apply height to highcharter object
if (inherits(result, 'highchart')) {
  result <- highcharter::hc_chart(result, height = 500)
}

result
```


### {{< iconify ph gender-intersex >}} Tabset #2

```{r demographics-2}
# Tabset #2
result <- create_stackedbar(
  data = data,
  title = "Tabset #2",
  x_var = "sex_1a",
  stack_var = "happy_1a",
  subtitle = "Another example subtitle here!",
  x_label = "Gender",
  y_label = "Percentage of Respondents",
  stack_label = "Happiness Level",
  stacked_type = "percent",
  stack_order = c("Very Happy", "Pretty Happy", "Not Too Happy"),
  tooltip_suffix = "%",
  color_palette = c("#2E86AB", "#A23B72", "#F18F01")
)

# Apply height to highcharter object
if (inherits(result, 'highchart')) {
  result <- highcharter::hc_chart(result, height = 450)
}

result
```

Change the position of the text using the `text_position` argument.



:::

## Example 2: Heatmap


::: {.panel-tabset}

### {{< iconify ph heatmap >}} Trust by Education and Age


Here's another example of the kind of plots you can generate in your dashboard.

```{r social}
# Trust by Education and Age
result <- create_heatmap(
  data = data,
  title = "Trust by Education and Age",
  x_var = "degree_1a",
  y_var = "age_1a",
  value_var = "trust_1a",
  subtitle = "Average trust levels across education and age groups",
  x_label = "Example x axis",
  y_label = "Customizable y label",
  value_label = "You can change the label here too...",
  x_order = c("Lt High School", "High School", "Junior College", "Bachelor", "Graduate"),
  color_palette = c("#d7191c", "#fdae61", "#ffffbf", "#abdda4", "#2b83ba"),
  tooltip_prefix = "Trust: ",
  tooltip_suffix = "/3",
  tooltip_labels_format = "{point.value:.2f}"
)

# Apply height to highcharter object
if (inherits(result, 'highchart')) {
  result <- highcharter::hc_chart(result, height = 600)
}

result
```


### {{< iconify ph chart-pie >}} Trust by Region and Education


Educational and regional patterns in trust distribution.

```{r social-2}
# Trust by Region and Education
result <- create_heatmap(
  data = data,
  title = "Trust by Region and Education",
  x_var = "region_1a",
  y_var = "degree_1a",
  value_var = "trust_1a",
  subtitle = "Educational and regional patterns in trust levels",
  x_label = "Region",
  y_label = "Education Level",
  value_label = "Trust Level",
  y_order = c("Lt High School", "High School", "Junior College", "Bachelor", "Graduate"),
  color_palette = c("#d7191c", "#fdae61", "#ffffbf", "#abdda4", "#2b83ba"),
  tooltip_prefix = "Trust: ",
  tooltip_suffix = "/3",
  tooltip_labels_format = "{point.value:.2f}"
)

# Apply height to highcharter object
if (inherits(result, 'highchart')) {
  result <- highcharter::hc_chart(result, height = 550)
}

result
```


:::
 

© 2025 dashboardr Package - All Rights Reserved

  • Edit this page
  • View source
  • Report an issue