shiny入門課【1.概要】

1717 ワード

shinyは、インタラクティブなWebアプリケーションを作成するためのRパッケージです.まず、このパッケージをインストールする必要があります.
install.packages("shiny")

shinyパッケージには、runExampleコマンドを使用して実行できる11の作成済みアプリケーションが内蔵されています.
library(shiny)
runExample("01_hello")

Shinyアプリケーションの構造
shinyアプリケーションは一般的にapp.Rコードファイルに単独で格納され、app.Rがnewdir/ディレクトリの下に配置されている場合、アプリケーションはrunExample("newdir")で実行することができる.
app.Rは以下の3つの部分を含む.
  • uiオブジェクト
  • server関数
  • shinyApp関数の呼び出しuiオブジェクトは、ページレイアウトおよびアプリケーションの外観を制御し、serverはインタラクションを制御し、shinyApp関数はshinyアプリケーションを作成するために使用される.

  • uiオブジェクトの例:
    library(shiny)
    
    # Define UI for app that draws a histogram ----
    ui 

    server関数の例:
    # Define server logic required to draw a histogram ----
    server 

    いったいこうぞう
    library(shiny)
    
    # See above for the definitions of ui and server
    ui 

    アプリケーションの実行
    ディレクトリ名をrunAppに渡せばいいです.
    library(shiny)
    runApp("my_app")
    

    Shiny内蔵アプリケーション
    runExample("01_hello")      # a histogram
    runExample("02_text")       # tables and data frames
    runExample("03_reactivity") # a reactive expression
    runExample("04_mpg")        # global variables
    runExample("05_sliders")    # slider bars
    runExample("06_tabsets")    # tabbed panels
    runExample("07_widgets")    # help text and submit buttons
    runExample("08_html")       # Shiny app built from HTML
    runExample("09_upload")     # file upload wizard
    runExample("10_download")   # file download wizard
    runExample("11_timer")      # an automated timer