Dynamic UI

Published by onesixx on

http://onesixx.com/shiny-cheat-sheet-link-ui-with-the-server-renderand-output/
http://zevross.com/blog/2016/04/19/r-powered-web-applications-with-shiny-a-tutorial-and-cheat-sheet-with-40-example-apps/  

dynamic UI 생성방법 5가지

사용자 Input에 따라 반응하는 UI 만들기

https://shiny.rstudio.com/articles/dynamic-ui.html
uiserver
uiOuputrenderUI
uiOuput InsertUI/ RemoveUI
ConditionalPanel
Use JavaScript 웹페이지에서 직접 수정
useShinyjs ex) hide/show , toggle
  •  conditionalPanel ()
    ui.R 에서  정의하는 conditionalPanel()은 dynamic하게  shown/hidden할 UI요소들 묶어서 조건에 따라 반응한다.
  •  renderUI () function
     server.R 에서 정의하는 renderUI()는   ui.R의 uiOutput()와 같이 사용하며,
    reactive을 이용하여 UI함수가 호출되도록 만들어 놓고, Input에 따라 reactive가 반응할때,   UI에서 미리 정의해 놓은 결과를  보여준다.
  •  insertUI() 와 removeUI()
      server.R 에서 정의하는 insertUI()는
    allow you to add and remove arbitrary chunks of UI code (all independent from one another), as many times as you want, whenever you want, wherever you want.
  • Use JavaScript
    to modify the webpage directly.
  • shinyjs
    hide/show , toggle

renderUI (uiOutput)

example01 : http://shiny.rstudio.com/gallery/dynamic-ui.html
R
R

ex> SideBar내 select Input 간 Dynamic

UI에서 하나의 object의 결과가 다른 object에 영향을 줄 때,  (즉 UI에서 Object의 property가 Dynamic하게 변경될 때) ui.R에서해당 updateComponent로UI컨트롤을 변경하는 것이 아니라, uiOutput()으로 위치만 정의하고,
server.R에서 정의와 처리를 동시에 한다.

R

Tab 간 Dynamic

Dynamic UI (with renderUI & outputUI)

If you want to return a block of UI elements – say a paragraph,
then a text box and a selector – you would use renderUI and uiOutput(outputUI) and instead of returning one object,
you return a list or tagList of objects (these functions can be used interchangeably).

Example app: Dynamic user interface

하나의 Object를 return받는 것 대신, Object의 list를 return한다.
아래 예에서,  my_output_UI output 은  h4 header and a selector의 list 이다.

The selector gets updated when the user clicks on the button (note observeEvent).
Each time the user clicks the button the selections gets updated.

R

Without uiOutput, renderUI

R

ex> BC Liquor Store data (bcl-data)

https://www.r-bloggers.com/building-shiny-apps-an-interactive-tutorial/
https://stackoverflow.com/questions/37092002/creating-reactive-renderui
R

renderUI sweetalertR

R
Categories: Shiny

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x