[英]Grouping textInput box in shiny
我正在使用Shiny創建一個應用程序,該應用程序處理用戶輸入數據並計算某些患者統計信息,然后呈現結果值。 我在下面粘貼了我的ui.R代碼的虛擬片段。 我正在嘗試找到一種按患者就診對textInput框進行分組的方法。 有沒有一種方法可以對textInput框進行分組,以便每一行都可以將textInput框並排對齊,代表單獨的患者就診?
我希望將textInput框顯示為:
Visit1
[BMI1文本框] [膽固醇1文本框] [心率1文本框]
Visit2
[BMI2文本框] [膽固醇2文本框] [心率2文本框]
ui <- fluidPage(# App title ----
titlePanel("Dummy Patient Analysis"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
sidebarPanel(
#### Visit 1 #######
textInput(
inputId = "bmi1",
label = "BMI1",
value = 2
),
textInput(
inputId = "chol1",
label = "cholesterol 1",
value = 5
),
textInput(
inputId = "heart_rate1",
label = "Heart Rate",
value = 40
),
#### Visit 2 #######
textInput(
inputId = "bmi2",
label = "BMI2",
value = 2
),
textInput(
inputId = "chol2",
label = "cholesterol 2",
value = 7
),
textInput(
inputId = "heart_rate2",
label = "Heart Rate",
value = 42
),
actionButton("process", "Estimate")
),
mainPanel(
tableOutput("view"),
verbatimTextOutput("summary")
)
)
)
splitLayout
旨在以最小的努力來完成這種事情。 只需將您想要的每組輸入與splitLayout()
並排splitLayout()
即可實現所需的內容,例如:
library(shiny)
ui <- fluidPage(
titlePanel("Dummy Patient Analysis"),
sidebarLayout(
sidebarPanel(
splitLayout(
textInput(inputId = "bmi1", label = "BMI1", value = 2),
textInput(inputId = "chol1", label = "cholesterol 1", value = 5),
textInput(inputId = "heart_rate1", label = "Heart Rate", value = 40)
),
splitLayout(
textInput(inputId = "bmi2", label = "BMI2", value = 2),
textInput(inputId = "chol2", label = "cholesterol 2", value = 7),
textInput(inputId = "heart_rate2", label = "Heart Rate", value = 42)
),
actionButton("process", "Estimate")
),
mainPanel(
tableOutput("view"),
verbatimTextOutput("summary")
)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
如果您不希望這些框占用整個側邊欄,則還可splitLayout
提供一個定義單元格寬度的矢量(請參閱幫助頁面 )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.