我正在开发一个让用户输入 2x2 表的应用程序。目前我正在使用 UI。R
library(shiny)
shinyUI(fluidPage(
titlePanel("2x2 Table"),
sidebarLayout(
sidebarPanel(
sliderInput("n11","Count of cell 1-1",
min=0, max=100, value=50,step=1),
sliderInput("n12","Count of cell 1-2",
min=0, max=100, value=50,step=1),
sliderInput("n21","Count of cell 2-1",
min=0, max=100, value=50,step=1),
sliderInput("n22","Count of cell 2-2",
min=0, max=100, value=50,step=1),
),
mainPanel(
uiOutput("table")
)
)
))
但是如果我可以在侧边栏中有一个 2x2 的表格,用户可以在其中输入他们的数字,那就更好了
我发现矩阵输入,但这似乎不起作用,无法交互式更改矩阵
谢谢
沃尔夫冈
你应该考虑使用嵌套fluidRow
和列来获取所需的网格,而不是sidebarLayout和sidebarPanel。示例如下...可能需要复制并粘贴到 R 中
library(shiny);
shinyUI(fluidPage(
titlePanel("Word Prediction - Iteration 1.12"),
fluidRow(
column(3,
wellPanel(
h4('Work outstanding'),
)
),
column(9,
fluidRow(column(9,h4('Predicted words ...'))),
fluidRow(
column(3,
verbatimTextOutput('oid1'),
tags$head(tags$style(type="text/css", "#oid1 {text-align: center}"))
),
column(3,
verbatimTextOutput('oid2'),
tags$head(tags$style(type="text/css", "#oid2 {text-align: center}"))
),
column(3,
verbatimTextOutput('oid3'),
tags$head(tags$style(type="text/css", "#oid3 {text-align: center}"))
)
),
fluidRow(
column(9,
h4('The same sentence now including the predicted word ...'),
verbatimTextOutput('oid4')
)
),
br(),br(),br(),br(),hr(),
fluidRow(
column(9,
textInput('id1','Type in your sentence'),
tags$head(tags$style(type="text/css", "#id1 {width: 720px}"))
)
)
)
)
))