Skip to content

Commit efd1db9

Browse files
authored
chore(r): Move example app to inst/examples-shiny/sqlite, use palmerpenguins instead (#94)
* chore(r): Move example app to `inst/examples-shiny/sqlite`, use palmerpenguins instead * chore(r): Small tweaks to example app
1 parent e5130ed commit efd1db9

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

pkg-r/DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Imports:
3232
Suggests:
3333
bsicons,
3434
DT,
35+
palmerpenguins,
3536
R6,
3637
RSQLite,
3738
shinytest2,
File renamed without changes.

pkg-r/examples/app-database.R renamed to pkg-r/inst/examples-shiny/sqlite/app.R

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ library(bslib)
33
library(querychat)
44
library(DBI)
55
library(RSQLite)
6+
library(palmerpenguins)
67

78
# Create a sample SQLite database for demonstration
89
# In a real app, you would connect to your existing database
@@ -18,52 +19,52 @@ conn <- dbConnect(RSQLite::SQLite(), temp_db)
1819
# querychat_init
1920

2021
# Create sample data in the database
21-
iris_data <- iris
22-
dbWriteTable(conn, "iris", iris_data, overwrite = TRUE)
22+
dbWriteTable(conn, "penguins", palmerpenguins::penguins, overwrite = TRUE)
2323

2424
# Define a custom greeting for the database app
2525
greeting <- "
26-
# Welcome to the Database Query Assistant! 📊
26+
# Welcome to the Database Query Assistant! 🐧
2727
28-
I can help you explore and analyze the iris dataset from the connected database.
29-
Ask me questions about the iris flowers, and I'll generate SQL queries to get the answers.
28+
I can help you explore and analyze the Palmer Penguins dataset from the connected database.
29+
Ask me questions about the penguins, and I'll generate SQL queries to get the answers.
3030
3131
Try asking:
32-
- Show me the first 10 rows of the iris dataset
33-
- What's the average sepal length by species?
34-
- Which species has the largest petals?
35-
- Create a summary of measurements grouped by species
32+
- <span class=\"suggestion\">Show me the first 10 rows of the penguins dataset</span>
33+
- <span class=\"suggestion\">What's the average bill length by species?</span>
34+
- <span class=\"suggestion\">Which species has the largest body mass?</span>
35+
- <span class=\"suggestion\">Create a summary of measurements grouped by species and island</span>
3636
"
3737

3838
# Create data source using querychat_data_source
39-
iris_source <- querychat_data_source(conn, table_name = "iris")
39+
penguins_source <- querychat_data_source(conn, table_name = "penguins")
4040

4141
# Configure querychat for database
4242
querychat_config <- querychat_init(
43-
data_source = iris_source,
43+
data_source = penguins_source,
4444
greeting = greeting,
45-
data_description = "This database contains the famous iris flower dataset with measurements of sepal and petal dimensions across three species (setosa, versicolor, and virginica).",
45+
data_description = "This database contains the Palmer Penguins dataset with measurements of bill dimensions, flipper length, body mass, sex, and species (Adelie, Chinstrap, and Gentoo) collected from three islands in the Palmer Archipelago, Antarctica.",
4646
extra_instructions = "When showing results, always explain what the data represents and highlight any interesting patterns you observe."
4747
)
4848

4949
ui <- page_sidebar(
5050
title = "Database Query Chat",
5151
sidebar = querychat_sidebar("chat"),
52+
5253
h2("Current Data View"),
5354
p(
5455
"The table below shows the current filtered data based on your chat queries:"
5556
),
5657
DT::DTOutput("data_table", fill = FALSE),
57-
br(),
58-
h3("Current SQL Query"),
58+
59+
h2("Current SQL Query"),
5960
verbatimTextOutput("sql_query"),
60-
br(),
61-
h3("Dataset Information"),
61+
62+
h2("Dataset Information"),
6263
p("This demo database contains:"),
6364
tags$ul(
64-
tags$li("iris - Famous iris flower dataset (150 rows, 5 columns)"),
65+
tags$li("penguins - Palmer Penguins dataset (344 rows, 8 columns)"),
6566
tags$li(
66-
"Columns: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species"
67+
"Columns: species, island, bill_length_mm, bill_depth_mm, flipper_length_mm, body_mass_g, sex, year"
6768
)
6869
)
6970
)
@@ -73,8 +74,7 @@ server <- function(input, output, session) {
7374

7475
output$data_table <- DT::renderDT(
7576
{
76-
df <- chat$df()
77-
df
77+
chat$df()
7878
},
7979
options = list(pageLength = 10, scrollX = TRUE)
8080
)

0 commit comments

Comments
 (0)