99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2018-10-26 閱讀量: 1158
shiny應(yīng)用程序里的小工具

More Widgets Screenshot

More widgets這個(gè)應(yīng)用程序展示的是幫助文本和提交按鈕,以及用嵌入HTML元素的方式來自定義格式。要運(yùn)行例子,請(qǐng)鍵入:

> library(shiny) > runExample("07_widgets") 

UI增強(qiáng)

在這個(gè)例子里,我們更新了Shiny Text程序,增加了控件,調(diào)整了格式,特別地:

  • 增加了helpText控件,用以在輸入控件旁邊添加解釋文本。
  • 增加了 submitButton控件,用來表示我們不想讓輸入和輸出進(jìn)行實(shí)時(shí)連接,而是想讓用戶點(diǎn)擊按鈕后才更新輸出。這一特點(diǎn)在當(dāng)計(jì)算過程非常復(fù)雜時(shí)是很有用的。
  • 在輸出面板上增加了 h4 元素(四級(jí)標(biāo)題)。Shiny提供了大量的函數(shù)可直接往頁面上添加HTML元素,包括標(biāo)題、段落、鏈接等等。

下面更新后的用戶接口界面的代碼:

library(shiny) # Define UI for dataset viewer application shinyUI(pageWithSidebar( # Application title. headerPanel("More Widgets"), # Sidebar with controls to select a dataset and specify the number # of observations to view. The helpText function is also used to  # include clarifying text. Most notably, the inclusion of a  # submitButton defers the rendering of output until the user  # explicitly clicks the button (rather than doing it immediately # when inputs change). This is useful if the computations required # to render output are inordinately time-consuming. sidebarPanel( selectInput("dataset", "Choose a dataset:", choices = c("rock", "pressure", "cars")), numericInput("obs", "Number of observations to view:", 10), helpText("Note: while the data view will show only the specified", "number of observations, the summary will still be based", "on the full dataset."), submitButton("Update View") ), # Show a summary of the dataset and an HTML table with the requested # number of observations. Note the use of the h4 function to provide # an additional header above each output section. mainPanel( h4("Summary"), verbatimTextOutput("summary"), h4("Observations"), tableOutput("view") ) )) 

服務(wù)端腳本

和原來的Shiny Text的程序比,所有的變化都是在用戶接口界面部分,服務(wù)端腳本保持不變。

library(shiny) library(datasets) # Define server logic required to summarize and view the selected dataset shinyServer(function(input, output) { # Return the requested dataset datasetInput <- reactive({ switch(input$dataset, "rock" = rock, "pressure" = pressure, "cars" = cars) }) # Generate a summary of the dataset output$summary <- renderPrint({ dataset <- datasetInput() summary(dataset) }) # Show the first "n" observations output$view <- renderTable({ head(datasetInput(), n = input$obs) }) })
0.0000
3
關(guān)注作者
收藏
評(píng)論(0)

發(fā)表評(píng)論

暫無數(shù)據(jù)
推薦帖子