Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- DESCRIPTION +7 -0
- app.R +51 -47
- data/CCS_Act01.csv +0 -0
- data/CCS_Act02.csv +0 -0
- data/CCS_Act03.csv +0 -0
- install.R +1 -0
DESCRIPTION
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Package: mycarbonapp
|
| 2 |
+
Package: CCSLawDB
|
| 3 |
+
Title: CCS Law Database Viewer
|
| 4 |
+
Version: 0.0.1
|
| 5 |
+
Description: Shiny app for viewing CCS-related legal data
|
| 6 |
+
Author: Your Name
|
| 7 |
+
License: MIT
|
app.R
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
library(shiny)
|
| 2 |
-
library(
|
| 3 |
library(dplyr)
|
| 4 |
-
library(
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
),
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
),
|
| 24 |
-
plotOutput("scatter")
|
| 25 |
)
|
| 26 |
|
|
|
|
| 27 |
server <- function(input, output, session) {
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
})
|
| 32 |
-
|
| 33 |
-
output$scatter <- renderPlot(
|
| 34 |
-
{
|
| 35 |
-
p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
|
| 36 |
-
theme_light() +
|
| 37 |
-
list(
|
| 38 |
-
theme(legend.position = "bottom"),
|
| 39 |
-
if (input$by_species) aes(color = Species),
|
| 40 |
-
geom_point(),
|
| 41 |
-
if (input$smooth) geom_smooth()
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
if (input$show_margins) {
|
| 45 |
-
margin_type <- if (input$by_species) "density" else "histogram"
|
| 46 |
-
p <- p |> ggExtra::ggMarginal(
|
| 47 |
-
type = margin_type, margins = "both",
|
| 48 |
-
size = 8, groupColour = input$by_species, groupFill = input$by_species
|
| 49 |
-
)
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
p
|
| 53 |
-
},
|
| 54 |
-
res = 100
|
| 55 |
-
)
|
| 56 |
}
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
| 1 |
+
if (!requireNamespace("DT", quietly = TRUE)) {
|
| 2 |
+
stop("DT package not available")
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
library(shiny)
|
| 6 |
+
library(DT)
|
| 7 |
library(dplyr)
|
| 8 |
+
library(readr)
|
| 9 |
|
| 10 |
+
# ファイル読み込み
|
| 11 |
+
act01 <- read_csv("data/CCS_Act01.csv") %>% mutate(法分類 = "法律")
|
| 12 |
+
act02 <- read_csv("data/CCS_Act02.csv") %>% mutate(法分類 = "政令")
|
| 13 |
+
act03 <- read_csv("data/CCS_Act03.csv") %>% mutate(法分類 = "省令")
|
| 14 |
|
| 15 |
+
# データ統合
|
| 16 |
+
law_data <- bind_rows(act01, act02, act03)
|
| 17 |
+
|
| 18 |
+
# UI定義
|
| 19 |
+
ui <- fluidPage(
|
| 20 |
+
titlePanel("法令データベース検索(CCS法体系プロトタイプ)"),
|
| 21 |
+
sidebarLayout(
|
| 22 |
+
sidebarPanel(
|
| 23 |
+
selectInput("law_type", "法分類を選択:",
|
| 24 |
+
choices = c("すべて", unique(law_data$法分類)),
|
| 25 |
+
selected = "すべて"),
|
| 26 |
+
textInput("keyword", "キーワード検索:", ""),
|
| 27 |
+
actionButton("search", "検索実行")
|
| 28 |
),
|
| 29 |
+
mainPanel(
|
| 30 |
+
DTOutput("table")
|
| 31 |
+
)
|
| 32 |
+
)
|
|
|
|
|
|
|
| 33 |
)
|
| 34 |
|
| 35 |
+
# サーバ定義
|
| 36 |
server <- function(input, output, session) {
|
| 37 |
+
|
| 38 |
+
filtered_data <- eventReactive(input$search, {
|
| 39 |
+
data <- law_data
|
| 40 |
+
|
| 41 |
+
if (input$law_type != "すべて") {
|
| 42 |
+
data <- filter(data, 法分類 == input$law_type)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (input$keyword != "") {
|
| 46 |
+
data <- filter(data, grepl(input$keyword, 条文テキスト, ignore.case = TRUE))
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
data
|
| 50 |
+
}, ignoreNULL = FALSE)
|
| 51 |
+
|
| 52 |
+
output$table <- renderDT({
|
| 53 |
+
datatable(
|
| 54 |
+
filtered_data(),
|
| 55 |
+
options = list(pageLength = 15, autoWidth = TRUE),
|
| 56 |
+
rownames = FALSE
|
| 57 |
+
)
|
| 58 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
+
# アプリ起動
|
| 62 |
+
shinyApp(ui = ui, server = server)
|
data/CCS_Act01.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/CCS_Act02.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/CCS_Act03.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
install.R
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
install.packages(c("shiny", "DT", "dplyr", "readr"), repos = "https://cloud.r-project.org")
|