shinydashboard:: switch tab

https://rdrr.io/cran/shinydashboard/man/updateTabItems.html     ## Only run this example in interactive R sessions library(shiny) library(shinydashboard) ui <- dashboardPage( dashboardHeader(title = “Simple tabs”), dashboardSidebar( sidebarMenu( id = “tabs”, menuItem(“Dashboard”, tabName = “dashboard”,icon = icon(“dashboard”) ), menuItem(“Widgets”, tabName = “widgets”, icon = icon(“th”)) ), actionButton(‘btn_switchtab’, ‘Switch tab’) ), dashboardBody( tabItems( tabItem(tabName = “dashboard”, Read more…

Advanced topics2 – Create re-usable UI elements

http://zevross.com/blog/2016/04/19/r-powered-web-applications-with-shiny-a-tutorial-and-cheat-sheet-with-40-example-apps/  Posted on April 19, 2016 by zev@zevross.com  Create re-usable UI elements Create re-useable UI elements 여러 tab에 같은 UI element를 넣어야할때, (10개의 tab에 변수선택을 위한 같은 selectbox를 구현하고 싶을때) 같은 코드를 여러번 copy&paste한다면 각각 ID도 따로 생성해야  하고 수정에 대한 관리도 어려워 질것이다. =>  필요한 UI element를 output하는 function 을 만들고, 간단히 call하면 Read more…

ShinyDashboard vs. flexDashboard

– ShinyDashboard  https://rstudio.github.io/shinydashboard/ – flexDashboard      http://rmarkdown.rstudio.com/flexdashboard/ cf> tableau  https://www.tableau.com https://www.reddit.com/r/rstats/comments/6exqbp/shiny_vs_shinydashboard_vs_flexdashboard/ https://stackoverflow.com/questions/37992147/r-shiny-which-hammer-straight-shiny-flexdashboard-or-shinydashboard shinydashboard dashboard를 쉽게 만들기 위한 Shiny의 기본적인 template (Shiny만으로 dashboard를 만들기 쉽지 않기 때문) it sacrifices flexibility for simplicity and convenience flexdashboard Use R Markdown to publish a group of related data visualizations as a dashboard.  Optionally use Shiny to drive visualizations dynamically.   Read more…

r threejs

https://github.com/bwlewis/rthreejs/blob/master/README.md – Three.js widgets for R and shiny – This project is based on the htmlwidgets package.   See https://github.com/ramnathv/htmlwidgets for details and links to amazingly cool visualization widgets for R. Install Platform과 상관없이 GitHub에서 직접 threejs를 설치하기 위해서는 devtools 팩키지를 사용하여 설치 if(!require(“devtools”)) install.packages(“devtools”) devtools::install_github(“bwlewis/rthreejs”) 에러시: http://onesixx.com/error-github-peer-certificate-cannot-authenticated-given-ca-certificates/ Examples 간단예제1 추가적인 Read more…

Shiny reactive :: Action Button

https://shiny.rstudio.com/articles/action-buttons.html    observeEvent()  : 코드블럭을 trigger 함.    (with reactiveValues) : 상호작용하는 여러 action button에 대해 Object를 저장하는 역할   eventReactive() : 계산된 ouput을 update한다.  Pattern 0 – 기본 actionButton(“buttonID”, “Label 버튼명”) ui.R fluidPage( titlePanel(“Action Button”), sidebarPanel( actionButton(“button_id”,”click Me”) ), mainPanel(verbatimTextOutput(“text_val”) ) ) server.R server<-function(input, output,session){ output$text_val <- renderPrint({ input$button_id }) }   Pattern Read more…

Shiny reactivity :: examples

https://github.com/rstudio/shiny/tree/master/inst/examples/03_reactivity   ui.R server.R fluidPage( titlePanel(“Reactivity”), sidebarLayout( sidebarPanel( textInput(“caption”, “Caption:”, “Data Summary”), selectInput(“dataset”, “Choose a dataset:”, choices=c(“rock”,”pressure”,”cars”)), numericInput(“obs”, “No of obs to view:”, 10) ), mainPanel( h3(textOutput(“caption”, container = span)), verbatimTextOutput(“summary”), tableOutput(“view”) ) ) )   function(input, output, sessions){ datasetInput <- reactive({ switch(input$dataset, “rock” = rock, “pressure” = pressure, “cars” Read more…

Shiny :: withProgress showNotification

http://shiny.rstudio.com/articles/progress.html https://gallery.shinyapps.io/085-progress/ Progress indicators  single-file app  withProgress()  로딩중 가장 쉽고 기본적인 방법. 긴 계산과정을 포함하고 있는  reactive(), observer(), render함수() 내에 withProgress() 추가하기  library(shiny) ui <- fluidPage( plotOutput(“plot”) ) server <- function(input, output, session) { output$plot <- renderPlot({ # progress <- Progress$new(session, min=1, max=15) # on.exit(progress$close()) # progress$set(message = ‘Calculation in progress’, detail=’This Read more…

ShinyApp :: Layout

http://shiny.rstudio.com/articles/layout-guide.html   Layout함수 https://shiny.rstudio.com/reference/shiny/latest/ Page함수 navbarPage   <Top레벨 컴포넌트 메뉴를 가진 Application 생성, tabPanel > fluidPage  <fluid Grid System,  fluidRow(  column(),  column(4, offset = 1,  ), …) 컨테이너  사용>  fixedPage <fixed Grid System, fixedRow(  column(),  column(4, offset = 1,  ), …) 컨테이너  사용> bootstrap~(basic~ ), fill~ Layout 함수 sidebarLayout flow~,  split~, vertical~ Read more…

ShinyApp :: Layout Inputs/Outputs

https://shiny.rstudio.com/reference/shiny/latest/ http://deanattali.com/blog/building-shiny-apps-tutorial/ http://cfss.uchicago.edu/shiny001_abc.html   UI Inputs  간단히,  ui.R 에서 Input객체와 Output객체를 적절하게 배치하고,  server.R에서는 두 객체를 받아, 작성한 로직으로 프로세싱해서, 하나의 결과를 랜더링해준다.  (Id, Label, Value) ui.R   랜더링하여 HTML (컴마주의) server.R      R코딩  UI Inputs UI Inputs (Update) textInput ,      textAreaInput   updateTextInput ,      updateTextAreaInput numericInput   updateNumericInput dateInput ,  Read more…

Shiny :: nonstandard evaluation

 http://www.alshum.com/nse/ Ex1 > > library(ISLR) > library(“ISLR”) > aaa <- “ISLR” > library(aaa) Error in library(aaa) : there is no package called ‘aaa’   Ex2>  ggplot  p <- ggplot(mtcars, aes(c(input$sel, mpg, colors=as.factor(cyl))) + geom_point() print(p) 이유는 그냥 ggplot 을 사용했기 때문 Warning: Error in renderPlot: object ‘cyl’ not found ERROR: Read more…

Shiny :: Simple example (reactive)

  library(shiny) ui <- fluidPage( sliderInput(inputId = “num”, label = “Choose a number”, min = 1, max = 100, value = 25) ,actionButton(inputId = “go”, label = “Print Value”) ,plotOutput(“hist”) ) server <- function(input, output, session){ data <- eventReactive(input$go, { rnorm(input$num) }) observeEvent(input$go, { output$hist <- renderPlot({ hist(data()) }) }) Read more…

Shiny :: Simple example

  Code   실행 console에서  > setwd(“/Users/onesixx/RScience/shiny/firstEx/”) > list.files() [1] “server.R” “ui.R” > runApp() Rstudio를 활용해서, * runApp() 을  default browser대신 chrome에서 실행하고 싶은 경우, > options(browser=”C:/Program Files (x86)/Google/Chrome/Application/chrome.exe”) > runApp()   결과 ======================= ### First Example library(shiny) ui <- #shinyUI( pageWithSidebar( # Application title headerPanel(“First Example”), # Sidebar with Read more…

Shiny :: Hello world

https://www.youtube.com/watch?v=Ido56dwDTg8   Basic Template     # App Template ui <- fluidPage() server <- function(input, output) shinyApp(ui=ui, server=server) ex> # ##################### # App Template ########################## #UI Layout :: # absolutePanel (fixedPanel),bootstrapPage (basicPage),column,conditionalPanel,fillPage, # fillRow (fillCol),fixedPage (fixedRow),fluidPage (fluidRow),headerPanel,helpText,icon,mainPanel, # navbarPage (navbarMenu),navlistPanel,pageWithSidebar,sidebarLayout,sidebarPanel,tabPanel,tabsetPanel, # titlePanel,inputPanel,flowLayout,splitLayout,verticalLayout,wellPanel,withMathJax ui <- fluidPage( # Title # UI Inputs:: Read more…

BOOK :: R과 Knitr를 활용한 데이터 연동형 문서 만들기

http://www.acornpub.co.kr/book/r-knitr https://www.youtube.com/watch?v=lMpX9KXd9AY Dynamic Documents with R and knitr – Yihui Xie’s book check out Yihui Xie’s book, Dynamic Documents with R and knitr. https://royalsociety.org/topics-policy/projects/science-public-enterprise/Report/       http://www.kyobobook.co.kr/product/detailViewKor.laf?barcode=9788960775510#N http://www.kyobobook.co.kr/product/detailViewKor.laf?ejkGb=KOR&mallGb=KOR&barcode=9788960779501&orderClick=LEA&Kc=   1부: 다이내믹 문서 다이내믹 문서 Knitr, 알마크다운 R 패키지, 팬독 2부: 다양한 포맷의 문서 HTML, PDF, Word, presentation 3부: 인터랙티브 Read more…

BOOK :: R과 Shiny 패키를 활용한 web Application 개발

Web Application Development with R Using Shiny 출판사 : https://www.packtpub.com/web-development/web-application-development-r-using-shiny 출판사 (번역) :http://www.acornpub.co.kr/book/r-shiny   ————————————————————— http://www.electronicsandbooks.com/eab1/manual/index.php?dir=!+new+2%2FR%2F http://www.electronicsandbooks.com/eab1/manual/!%20new%202/R/1783284471%20%7BC1D4EB72%7D%20Web%20Application%20Development%20with%20R%20using%20Shiny%20[Beeley%202013-10-22].pdf

Shiny :: Intro

  기본 Template   library(shiny) ui <- fluidPage( ) server <- function(input, output){ } shinyApp(ui, server) html <!DOCTYPE html> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/> <script type=”application/shiny-singletons”></script> <script type=”application/html-dependencies”>json2[2014.02.04];jquery[1.12.4];shiny[1.0.3];bootstrap[3.3.7]</script><script src=”shared/json2-min.js”></script> <script src=”shared/jquery.min.js”></script> <link href=”shared/shiny.css” rel=”stylesheet” /> <script src=”shared/shiny.min.js”></script> <meta name=”viewport” content=”width=device-width, initial-scale=1″ /> <link href=”shared/bootstrap/css/bootstrap.min.css” rel=”stylesheet” /> <script src=”shared/bootstrap/js/bootstrap.min.js”></script> <script Read more…