티스토리 뷰
url = 'http://kosis.kr/openapi/statisticsBigData.do?method=getList&apiKey=YjJhODMwYjhiMzc0MTBjOGUzYmRmMTE4ZTg5NDgwMDY=&format=xls&userStatsId=knholic/101/DT_1L9H002/3/1/20181127222300&prdSe=Q&newEstPrdCnt=100'
https://cran.r-project.org/web/packages/shinyjqui/vignettes/orderInput.html
https://yang-tang.github.io/shinyjqui/
https://shiny.rstudio.com/articles/css.html
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shinyjqui)
library(tidyverse)
library(DT)
library(magrittr)
library(lazyeval)
library(shiny)
base_pivot <- function(para_dt, para_grp, para_grp2, para_summ, para_func){
# para_dt <- iris
# para_grp <- "Sepal.Length"
# para_grp2 <- "Species"
# para_summ <- c("Sepal.Length","Sepal.Width")
# para_func <- c("sum", "mean")
summ <- c()
for (idx in 1:length(para_summ)) {
assign(paste0("func", idx), match.fun(para_func[idx]), envir = .GlobalEnv)
temp <- paste0( "interp(~func",idx,"(v), v=as.name(\"", para_summ[idx], "\"))") %>% as.formula()
summ %<>% c(., temp)
}
names_summ <- paste0(para_func, "_", para_summ)
names <- c(para_grp, para_grp2, names_summ)
b <- para_dt %>%
group_by(.dots = c(para_grp, para_grp2)) %>%
summarise_(.dots = summ) %>%
set_names(names)
if (length(para_summ) == 1) {
b %<>% unite("nVal", para_grp2)%>% spread( nVal, names_summ)
}
b
}
# iris <- read_csv("testtest.csv") %>% head(1000)
# Define UI for application that draws a histogram
ui <- fluidPage(
includeCSS("test.css"),
tags$div( class = "header1",
titlePanel("Pivot Shiny"),tags$hr()),
# Application title
# Sidebar with a slider input for number of bins
fluidPage(
fluidRow(
column(width = 10,
dateInput('thedate', '기준일 선택'),
orderInput('source', 'Source', items = names(iris),
as_source = TRUE, connect = c('행', '열'), item_class = 'warning'), tags$br(),
orderInput('행', '행', items=NULL, placeholder = 'Drag items here...', connect = 'delete', item_class = 'primary'), tags$br(),
orderInput('열', '열', items=NULL, placeholder = 'Drag items here...', connect = 'delete'), tags$hr(),
orderInput('source', 'Source', items = names(iris)[sapply(iris, class)=="numeric" ],
as_source = TRUE, connect = c('연산대상'), item_class = 'success'),tags$br(),
orderInput('연산대상', '연산대상', items=NULL, placeholder = 'Drag items here...', connect = 'delete'),tags$br(),
orderInput('source', 'Source', items = c("sum","mean","n"),
as_source = TRUE, connect = c('연산'), item_class = 'info'),tags$br(),
orderInput('연산', '연산', items=NULL, placeholder = 'Drag items here...', connect = 'delete'),tags$hr(),
verbatimTextOutput('order'),tags$hr(),
actionButton('run', "RUN"),
tags$br(),
tags$br(),
tags$hr(),
tags$br()
),
column(width = 2,
orderInput('delete', '삭제란', items=NULL, placeholder = 'Drag items here...')
)
),
tabsetPanel(
tabPanel('tab1',
fluidRow(
column(width = 12,tags$br(),
DT::dataTableOutput('dtoutp')
)
),
fluidRow(
column(width = 3,tags$br(),
selectizeInput('slt_x','x', choices = NULL),
selectizeInput('slt_y','y', choices = NULL)
),
column(width = 9,tags$br(),
plotOutput('ploutp')
)
)
),
tabPanel('tab2',
fluidRow(
column(width=12,tags$br(),
tableOutput('dtoutp2')
)
))
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
output$order <- renderPrint({
print(paste0(input$연산_order,"_",input$연산대상_order) )
})
aa <- reactive({
c(input$aaaa_order[1], input$aaaa_order[2])
})
output$distPlot <- renderPlot({
ggplot(iris, aes_string(aa()[1], aa()[2])) +
geom_point()
})
dtf <- eventReactive(input$run, {
a <- base_pivot(iris, input$행_order, input$열_order, input$연산대상_order, input$연산_order)
updateSelectizeInput(session, 'slt_x', choices =names(a), server = TRUE)
updateSelectizeInput(session, 'slt_y', choices =names(a), server = TRUE)
a
})
output$dtoutp <- DT::renderDataTable(dtf())
output$dtoutp2 <- renderTable(dtf())
output$ploutp <- renderPlot({
cnames <- names(dtf())
ggplot(dtf(), aes_string(input$slt_x, input$slt_y)) +
geom_point()
}
)
observe({
print(input$연산대상_order)
print(input$연산_order)
print(paste0(input$연산대상_order,"_",input$연산_order))
})
}
# library(rpivotTable)
#
# rpivotTable(mtcars)
#
# Run the application
shinyApp(ui = ui, server = server)
'#Archive' 카테고리의 다른 글
[노트북] IT전문가의 컴알못을 위한 LG Gram 구매 팁 (0) | 2021.03.23 |
---|---|
[ADSP] 빅데이터 자격증 - 00. Intro (0) | 2019.01.14 |
09. 질산 공장 데이터 (stackloss) (0) | 2018.07.05 |
08. 올드페이스풀 간헐천 (faithful geysor) 데이터 (0) | 2018.07.05 |
[시외 버스] 광명 - 광주 버스 시간표 및 예매 방법 (0) | 2018.05.06 |
- Total
- Today
- Yesterday
- 가족여행
- 커플여행
- 캠핑초보
- Koreancuisine
- 파이썬
- 자연힐링
- 캠핑장추천
- bukhansannationalpark
- 영월캠핑
- 알고리즘
- 백준
- Oracle
- 가평여행
- 카카오
- 반려견캠핑
- 글램핑
- 여름캠핑
- 강원도캠핑
- 계곡캠핑
- 여름휴가
- 여름휴가추천
- 머신러닝
- 영월여행
- sql
- SeoulTravel
- 강원도여행
- 가평캠핑
- 서울근교캠핑
- 가족캠핑
- python
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |