相关疑难解决方法(0)

使用闪亮的文本输入和 dplyr 过滤数据框中的行

我试图在闪亮的应用程序上使用文本输入小部件来过滤数据框中的行,但我无法让它工作。

数据集

df1<-data.frame (Name=c("Carlos","Pete","Carlos","Carlos","Carlos","Pete","Pete","Pete","Pete","Homer"),Sales=(as.integer(c("3","4","7","6","4","9","1","2","1","9"))))
Run Code Online (Sandbox Code Playgroud)

用户界面

shinyUI(fluidPage(
titlePanel("Sales trends"),titlePanel("People score"),

sidebarLayout(sidebarPanel(

  textInput("text", label = h3("Text input"), value = "Enter text..."),

  numericInput("obs", "Number of observations to view:", 3),

  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")
),

mainPanel(
  h4("Volume: Total sales"),
  verbatimTextOutput("volume"),

  h4("Top people"),
  tableOutput("view")
))))
Run Code Online (Sandbox Code Playgroud)

服务器

library(shiny)
library (dplyr)
df1<-data.frame (Name=c("Carlos","Pete","Carlos","Carlos","Carlos","Pete","Pete","Pete","Pete","Homer"),Sales=(as.integer(c("3","4","7","6","4","9","1","2","1","9"))))
shinyServer(function(input, output) {
output$value <- renderPrint({ input$text })
datasetInput <- reactive({
switch(input$dataset,df1%>% filter(Name …
Run Code Online (Sandbox Code Playgroud)

r shiny dplyr shinydashboard

3
推荐指数
1
解决办法
5671
查看次数

标签 统计

dplyr ×1

r ×1

shiny ×1

shinydashboard ×1