Shiny :: Intro

Published by onesixx on


기본 Template


ui <- fluidPage(

server <- function(input, output){

shinyApp(ui, server)


<!DOCTYPE html>

  <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 src="shared/bootstrap/shim/html5shiv.min.js"></script>
<script src="shared/bootstrap/shim/respond.min.js"></script>


  <div class="container-fluid"></div>


Reference Site

Google shiny forum






– R 팩키지중 하나 (Interactive & Reactive)
– (Dynamic) Web Application 제작 프레임웍  ( R 코드가 HTML,CSS, Javascript를 대신해서 사용됨)
– Rmd(FlexBoard)에 embed가능 : 독립적인 웹페이지 대신에, Rmd문서의 컨텐츠로  embed가능

  • YAML 헤더에 runtime:shiny 추가  => RStudio의 KnitHTML버튼이 Run Document 버튼을 변경됨 
  • 함수 직접 사용

Input widget

  • 입력된 값이 Server에 넘겨질때의 Data-Type에 대해 주의 
  • 가능하면, Default값이 명시한다.

output element




> library("shiny")
> runExample()
Valid examples are "01_hello", "02_text", "03_reactivity", "04_mpg", "05_sliders", "06_tabsets",
                   "07_widgets", "08_html", "09_upload", "10_download", "11_timer"
> runExample("01_hello")

Application Name :  Shiny 앱을 위치시킬 폴더와 일치 

  • Single File: app.R 생성
  • Multiple File: ui.R, server.R 생성

Ui, server 함수 객체 만들기

ui <- 함수()
server <- function(input, output, session){}

ui, server 객체합치기

shinyApp(ui, server)




print(source(‘xxx.R’))                  파일명이 app.R이  아닌 경우

Sharing Shiny apps

방법1. 자신의 Shiny 서버 구축

방법2. 활용하기
  Posted on  by [email protected] 

Deploy your app

Although Shiny apps end up as HTML files you can’t simply copy them to your server.
They require a Shiny server, a server that can run your R commands.

* Running your own Shiny server

There is a free, open source version of the Shiny server that you can run on, for example, Amazon Web Services or your own server. This is designed for apps with a relatively low number of visitors.

Running locally

  • If you’re developing in RStudio, and have a multi-page app you can open either ui.R or server.R and click on Run App in the top right.
  • For a single or multi-page app you can use the function runApp where you specify the directory your app.R or ui.R/server.R files are housed in.
  • For a single page app you can use the function shinyApp where you specify the ui and the server as I’ve done in the examples above.

Running on

This site is managed by RStudio and is free for small apps with limited visits and scales up in paid versions.


Running Shiny Server Pro

RStudio also sells a yearly subscription to Shiny Server Pro that provides security, admin and other enhancements when compared to the open source version. You can view a comparison of the open source and pro version here.      



Notes on the creation of this post

The output of sessionInfo() is below in case you run into trouble related to versions of Shiny or other packages discussed. RStudio is generously hosting the 40 mini-apps in the post and they are shown here using iFrames. Browsers limit the number of connections (iFrames) on one page so I could not load all 40 apps at once. I’ve done my best to speed things up by pre-loading apps when users click on certain links but in some case you need to wait for an app load or reload an app and I apologize if this is slow.

## R version 3.2.3 (2015-12-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## other attached packages:
## [1] htmlwidgets_0.6    leaflet_1.0.1.9002 DT_0.1.55         
## [4] shiny_0.13.1.9002 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.4     digest_0.6.9    mime_0.4        R6_2.1.2       
##  [5] xtable_1.8-0    formatR_1.2.1   magrittr_1.5    evaluate_0.8   
##  [9] stringi_1.0-1   rmarkdown_0.9.5 tools_3.2.3     stringr_1.0.0  
## [13] httpuv_1.3.3    yaml_2.1.13     htmltools_0.3.5 knitr_1.12.3






Categories: Shiny


Blog Owner

Leave a Reply

Your email address will not be published.