Files changed (1) hide show
  1. app.R +25 -19
app.R CHANGED
@@ -8,12 +8,14 @@ library(shiny)
8
  # Data & QueryChat setup
9
  # ---------------------------------------------------------------------------
10
 
11
- oews <- as.data.frame(readRDS("data/oews.rds"))
 
 
 
 
 
 
12
 
13
- # Pre-compute static stats for the Home tab
14
- n_occupations <- length(unique(oews$occ_title[oews$o_group == "detailed"]))
15
- n_areas <- length(unique(oews$area_title))
16
- data_period <- "May 2024"
17
 
18
  client <- ellmer::chat_openai(
19
  model = "gpt-5-mini-2025-08-07",
@@ -21,20 +23,22 @@ client <- ellmer::chat_openai(
21
  )
22
 
23
  qc <- querychat::querychat(
24
- oews,
25
  client = client,
26
- greeting = "Welcome to Our ISA 401 Assistant for Understanding the OEWS Dataset",
27
  extra_instructions = "data/extra_instructions.md",
28
  data_description = "data/data_desc.md"
29
  )
30
 
 
 
31
  # ---------------------------------------------------------------------------
32
  # UI
33
  # ---------------------------------------------------------------------------
34
 
35
  ui <- bslib::page_navbar(
36
  id = "navbar",
37
- title = "OEWS Jobs Explorer",
38
  theme = bslib::bs_theme(primary = "#C3142D"),
39
  navbar_options = bslib::navbar_options(bg = "#C3142D"),
40
  fillable = "Explorer",
@@ -57,9 +61,10 @@ ui <- bslib::page_navbar(
57
  tags$hr(),
58
  tags$p("Try asking things like:"),
59
  tags$ul(
60
- tags$li("Show me the top 10 highest paying occupations"),
61
- tags$li("Filter to software developers in California"),
62
- tags$li("What are the jobs with more than 1 million employees?")
 
63
  )
64
  )
65
  ),
@@ -78,10 +83,10 @@ ui <- bslib::page_navbar(
78
  style = "background: linear-gradient(135deg, #C3142D 0%, #8B0E20 100%);",
79
  bslib::card_body(
80
  class = "text-center py-5",
81
- tags$h1("OEWS Jobs Explorer", class = "display-4 fw-bold"),
82
  tags$p(
83
  class = "lead mt-3 mb-4",
84
- "Explore U.S. Occupational Employment and Wage Statistics using natural language queries powered by AI"
85
  ),
86
  tags$p(class = "text-white-50 mb-4", "A Business Intelligence and Data Visualization Assignment for ISA 401 at Miami University"),
87
  shiny::actionButton(
@@ -118,8 +123,9 @@ ui <- bslib::page_navbar(
118
  bslib::value_box(
119
  title = "Data Period",
120
  value = data_period,
121
- p(format(n_occupations, big.mark = ","), " occupations \u00B7 ",
122
- format(n_areas, big.mark = ","), " areas"),
 
123
  showcase = bsicons::bs_icon("bar-chart-line"),
124
  theme = "light"
125
  )
@@ -138,7 +144,7 @@ ui <- bslib::page_navbar(
138
  tags$a("querychat", href = "https://posit-dev.github.io/querychat/",
139
  target = "_blank"),
140
  " R package to let you query the ",
141
- tags$strong("OEWS May 2024"),
142
  " dataset from the ",
143
  tags$a("Bureau of Labor Statistics",
144
  href = "https://www.bls.gov/oes/tables.htm", target = "_blank"),
@@ -234,7 +240,7 @@ ui <- bslib::page_navbar(
234
  # ---------------------------------------------------------------------------
235
 
236
  server <- function(input, output, session) {
237
- qc_vals <- qc$server()
238
 
239
  # Navigate to Explorer tab on button click
240
  shiny::observeEvent(input$go_explorer, {
@@ -242,7 +248,7 @@ server <- function(input, output, session) {
242
  })
243
 
244
  output$explorer_table_title <- shiny::renderText({
245
- qc_vals$title() %||% "OEWS Data"
246
  })
247
 
248
  output$table <- DT::renderDT({
@@ -254,7 +260,7 @@ server <- function(input, output, session) {
254
  })
255
 
256
  output$sql <- shiny::renderText({
257
- qc_vals$sql() %||% "SELECT * FROM oews"
258
  })
259
  }
260
 
 
8
  # Data & QueryChat setup
9
  # ---------------------------------------------------------------------------
10
 
11
+ oews <- as.data.frame(readRDS("data/listings.rds"))
12
+
13
+ # Pre-compute static stats for the Home tab (Airbnb)
14
+ n_listings <- nrow(listings)
15
+ n_neighbourhoods <- length(unique(listings$neighbourhood))
16
+ n_hosts <- length(unique(listings$host_id))
17
+ data_period <- "Snapshot: Feb 2026" # or use the dataset’s real snapshot date if you know it
18
 
 
 
 
 
19
 
20
  client <- ellmer::chat_openai(
21
  model = "gpt-5-mini-2025-08-07",
 
23
  )
24
 
25
  qc <- querychat::querychat(
26
+ listings,
27
  client = client,
28
+ greeting = "Welcome! Ask questions about Columbus Airbnb listings (price, room type, neighbourhood, reviews, and availability).",
29
  extra_instructions = "data/extra_instructions.md",
30
  data_description = "data/data_desc.md"
31
  )
32
 
33
+
34
+
35
  # ---------------------------------------------------------------------------
36
  # UI
37
  # ---------------------------------------------------------------------------
38
 
39
  ui <- bslib::page_navbar(
40
  id = "navbar",
41
+ title = "Airbnb Listings Explorer",
42
  theme = bslib::bs_theme(primary = "#C3142D"),
43
  navbar_options = bslib::navbar_options(bg = "#C3142D"),
44
  fillable = "Explorer",
 
61
  tags$hr(),
62
  tags$p("Try asking things like:"),
63
  tags$ul(
64
+ tags$li("Show entire homes under $150 in Short North"),
65
+ tags$li("What neighbourhoods have the lowest average price?"),
66
+ tags$li("Show listings with zero reviews and availability_365 = 0")
67
+
68
  )
69
  )
70
  ),
 
83
  style = "background: linear-gradient(135deg, #C3142D 0%, #8B0E20 100%);",
84
  bslib::card_body(
85
  class = "text-center py-5",
86
+ tags$h1("Airbnb Listings Explorer", class = "display-4 fw-bold"),
87
  tags$p(
88
  class = "lead mt-3 mb-4",
89
+ "Explore Columbus Airbnb listings using natural language queries powered by AI"
90
  ),
91
  tags$p(class = "text-white-50 mb-4", "A Business Intelligence and Data Visualization Assignment for ISA 401 at Miami University"),
92
  shiny::actionButton(
 
123
  bslib::value_box(
124
  title = "Data Period",
125
  value = data_period,
126
+ p(format(n_listings, big.mark = ","), " listings \u00B7 ",
127
+ format(n_hosts, big.mark = ","), " hosts \u00B7 ",
128
+ format(n_neighbourhoods, big.mark = ","), " neighbourhoods"),
129
  showcase = bsicons::bs_icon("bar-chart-line"),
130
  theme = "light"
131
  )
 
144
  tags$a("querychat", href = "https://posit-dev.github.io/querychat/",
145
  target = "_blank"),
146
  " R package to let you query the ",
147
+ tags$strong("Columbus Airbnb listings"),
148
  " dataset from the ",
149
  tags$a("Bureau of Labor Statistics",
150
  href = "https://www.bls.gov/oes/tables.htm", target = "_blank"),
 
240
  # ---------------------------------------------------------------------------
241
 
242
  server <- function(input, output, session) {
243
+ qc_vals$title() %||% "Airbnb Listings"
244
 
245
  # Navigate to Explorer tab on button click
246
  shiny::observeEvent(input$go_explorer, {
 
248
  })
249
 
250
  output$explorer_table_title <- shiny::renderText({
251
+ qc_vals$title() %||% "Airbnb Listings"
252
  })
253
 
254
  output$table <- DT::renderDT({
 
260
  })
261
 
262
  output$sql <- shiny::renderText({
263
+ qc_vals$sql() %||% "SELECT * FROM listings"
264
  })
265
  }
266