ui <- fluidPage(
textInput(
inputId = "team_numSearch", label = "Choose a team"),
verbatimTextOutput("teamData")
)
server <- function(input, output){
df <-read.csv(file = "sample.txt", head = TRUE)
output$teamData <- renderPrint({
df[grep(input$team_numSearch, df$Team.Number),]
})
}
shinyApp(ui = ui, server = server)
df
Team.Number,Match.Number
1,8888
2,2333
3,365
我想要的是这段代码来缩小输出范围,以仅显示匹配号。因此,如果我搜索Team.Number 1
,我只希望输出8888
而不是1,8888
答案 0 :(得分:0)
只需添加要显示的列即可,在您的示例中,只是[2] int切片
ui <- fluidPage(
textInput(
inputId = "team_numSearch", label = "Choose a team"),
verbatimTextOutput("teamData")
)
server <- function(input, output){
df <-read.csv(file = "sample.txt", head = TRUE)
output$teamData <- renderPrint({
df[grep(input$team_numSearch, df$Team.Number),2]
})
}
shinyApp(ui = ui,服务器=服务器)