GSS Data Explorer
  • Overview
  • Demographics
  • Trust & Social Capital
  • Political Attitudes
  • About

Overview

General Social Survey 2020

Exploring happiness, trust, and social attitudes across America.

View Full Dashboard Code
library(dashboardr)
library(gssr)
library(dplyr)

# Load and prepare GSS data
data(gss_all)
gss_clean <- gss_all %>%
  filter(year >= 2010) %>%
  mutate(
    sex = haven::as_factor(sex),
    degree = haven::as_factor(degree),
    happy = haven::as_factor(happy),
    region = haven::as_factor(region),
    polviews = haven::as_factor(polviews),
    partyid = haven::as_factor(partyid)
  ) %>%
  filter(!is.na(age), !is.na(sex), !is.na(degree))

# Create visualizations with nested tabsets
analysis_vizzes <- create_content() %>%
  add_viz(type = "stackedbar",
          x_var = "degree", stack_var = "happy",
          title = "Happiness by Education",
          tabgroup = "happiness") %>%
  add_viz(type = "boxplot",
          x_var = "happy", y_var = "age",
          title = "Age by Happiness",
          tabgroup = "happiness") %>%
  add_viz(type = "histogram",
          x_var = "age",
          title = "Age Distribution",
          tabgroup = "age")

# Create dashboard with value boxes
dashboard <- create_dashboard(
  output_dir = "showcase_dashboard",
  title = "GSS Data Explorer",
  theme = "flatly"
) %>%
  add_page(
    name = "Overview",
    content = create_content() %>%
      add_value_box_row() %>%
        add_value_box(title = "Respondents", value = "2,849") %>%
        add_value_box(title = "Very Happy", value = "32%") %>%
      end_value_box_row(),
    is_landing_page = TRUE
  ) %>%
  add_page(
    name = "Demographics",
    data = gss_clean,
    content = analysis_vizzes
  )

# Generate
generate_dashboard(dashboard)

View full showcase_dashboard source code

N
Total Respondents
2,849
Very Happy
32%
Trust Others
34%
College Educated
28%
Regions
9
Survey Year
2020

Quick Navigation

Demographics - Explore happiness and wellbeing by demographic groups

Trust & Social Capital - Filter and explore trust patterns across regions

Political Attitudes - Party identification and ideology breakdowns

About - Data sources and methodology

Back to top
Source Code
---
title: "{{< iconify ph house >}} Overview"
format: html
---

```{r, include=FALSE}
# Initialize dashboardr page configuration (CSS/JS for charts)
dashboardr:::.page_config()
```

# General Social Survey 2020

Exploring happiness, trust, and social attitudes across America.

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

# Load dashboardr (includes dplyr, highcharter as dependencies)
library(dashboardr)

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

```


<details>
<summary>{{< iconify ph code >}} View Full Dashboard Code</summary>

```r
library(dashboardr)
library(gssr)
library(dplyr)

# Load and prepare GSS data
data(gss_all)
gss_clean <- gss_all %>%
  filter(year >= 2010) %>%
  mutate(
    sex = haven::as_factor(sex),
    degree = haven::as_factor(degree),
    happy = haven::as_factor(happy),
    region = haven::as_factor(region),
    polviews = haven::as_factor(polviews),
    partyid = haven::as_factor(partyid)
  ) %>%
  filter(!is.na(age), !is.na(sex), !is.na(degree))

# Create visualizations with nested tabsets
analysis_vizzes <- create_content() %>%
  add_viz(type = "stackedbar",
          x_var = "degree", stack_var = "happy",
          title = "Happiness by Education",
          tabgroup = "happiness") %>%
  add_viz(type = "boxplot",
          x_var = "happy", y_var = "age",
          title = "Age by Happiness",
          tabgroup = "happiness") %>%
  add_viz(type = "histogram",
          x_var = "age",
          title = "Age Distribution",
          tabgroup = "age")

# Create dashboard with value boxes
dashboard <- create_dashboard(
  output_dir = "showcase_dashboard",
  title = "GSS Data Explorer",
  theme = "flatly"
) %>%
  add_page(
    name = "Overview",
    content = create_content() %>%
      add_value_box_row() %>%
        add_value_box(title = "Respondents", value = "2,849") %>%
        add_value_box(title = "Very Happy", value = "32%") %>%
      end_value_box_row(),
    is_landing_page = TRUE
  ) %>%
  add_page(
    name = "Demographics",
    data = gss_clean,
    content = analysis_vizzes
  )

# Generate
generate_dashboard(dashboard)
```

[View full showcase_dashboard source code](https://github.com/favstats/dashboardr/blob/main/R/tutorial_dashboard.R)

</details>


```{r}
#| echo: false
#| results: 'asis'
dashboardr::render_value_box_row(list(
  list(
    title = "Total Respondents",
    value = "2,849",
    bg_color = "#3498db",
    logo_url = NULL,
    logo_text = "N"
  ),
  list(
    title = "Very Happy",
    value = "32%",
    bg_color = "#27ae60",
    logo_url = NULL,
    logo_text = "{{< iconify ph smiley >}}"
  ),
  list(
    title = "Trust Others",
    value = "34%",
    bg_color = "#9b59b6",
    logo_url = NULL,
    logo_text = "{{< iconify ph handshake >}}"
  )
))
```


```{r}
#| echo: false
#| results: 'asis'
dashboardr::render_value_box_row(list(
  list(
    title = "College Educated",
    value = "28%",
    bg_color = "#f39c12",
    logo_url = NULL,
    logo_text = "{{< iconify ph graduation-cap >}}"
  ),
  list(
    title = "Regions",
    value = "9",
    bg_color = "#e74c3c",
    logo_url = NULL,
    logo_text = "{{< iconify ph map-pin >}}"
  ),
  list(
    title = "Survey Year",
    value = "2020",
    bg_color = "#1abc9c",
    logo_url = NULL,
    logo_text = "{{< iconify ph calendar >}}"
  )
))
```


---


## Quick Navigation


[{{< iconify ph users-three >}} Demographics](demographics.html) - Explore happiness and wellbeing by demographic groups





[{{< iconify ph handshake >}} Trust & Social Capital](trust___social_capital.html) - Filter and explore trust patterns across regions





[{{< iconify ph chart-bar >}} Political Attitudes](political_attitudes.html) - Party identification and ideology breakdowns





[{{< iconify ph info >}} About](about.html) - Data sources and methodology

© 2025 dashboardr Package - All Rights Reserved

 

dashboardr logoPowered by dashboardr