Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

RbeginneraiAI generated

Survey Crosstab Explorer

Build a small Shiny web app in R for exploring survey results. You upload a CSV of survey answers, pick two questions from dropdown menus, and the app shows a crosstab: a table counting how many people gave each combination of answers, with row percentages and a bar chart. It also runs a chi-square test with the infer package (part of tidymodels) to show whether the two answers seem related, and lets you download everything as an HTML report. It's a gentle introduction to R: reading data, counting and reshaping it with dplyr and tidyr, plotting with ggplot2, and building an interactive app with Shiny.

Estimate
~9h
Steps
6
Completed by
0
Proposed by
codeseed.app

Shiny · tidymodels

Project roadmap

  1. 01

    Set up the project and sample data

    ~1h

    Install R and RStudio, then install the packages shiny, dplyr, tidyr, ggplot2, readr, infer and rmarkdown. Create app.R with a minimal Shiny app (ui, server and shinyApp) that shows a title. Add a sample survey CSV in data/ with at least 100 rows and 4 categorical columns, such as age_group, region, satisfaction and would_recommend. Done when: running the app opens a page with the title, and the sample file is in the repo.

  2. 02

    Upload a CSV and pick two questions

    ~1.5h

    Add a fileInput for the CSV, read it with readr::read_csv, and fill two selectInput dropdowns with its column names: one for rows and one for columns. Show a clear message if the file can't be read or has fewer than two columns. Until a file is uploaded, use the sample data. Done when: uploading a file updates both dropdowns with its column names.

  3. 03

    Build the crosstab

    ~2h

    When two different columns are selected, count each combination of answers with dplyr::count and reshape the result with tidyr::pivot_wider into a table: one row per answer to the first question, one column per answer to the second, containing counts. Add a second table with row percentages rounded to one decimal. Treat missing answers as a category called (missing). Done when: the app shows both tables for the selected pair.

  4. 04

    Add a chart

    ~1.5h

    Draw a stacked bar chart with ggplot2: one bar per answer to the first question, split by the answers to the second, using row percentages so every bar reaches 100%. Add axis labels and a title naming both questions. Done when: the chart updates whenever either dropdown changes.

  5. 05

    Test whether the answers are related

    ~1.5h

    Use infer to run a chi-square test of independence between the two questions, for example with chisq_test. Show the statistic, the p-value, and a plain-language sentence: likely related if p < 0.05, no clear relationship otherwise. If any expected count is below 5, add a warning that the result may be unreliable. Done when: the test result and sentence appear below the tables.

  6. 06

    Export a report

    ~1.5h

    Add a Download report button using downloadHandler that renders an R Markdown file (report.Rmd) to HTML, containing the two chosen questions, both tables, the chart and the test result. Done when: clicking the button downloads an HTML report that matches what's on screen.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9h · 6 steps

Tech stack

Shinytidymodels