简体   繁体   English

Shiny 应用程序中的“match.arg(position) 错误:‘arg’必须为 NULL 或字符向量”

[英]"Error in match.arg(position) : 'arg' must be NULL or a character vector" in Shiny app

I've been developing a Shiny app in a single app.R file (see below).我一直在一个 app.R 文件中开发一个 Shiny 应用程序(见下文)。 I'm getting the "Error in match.arg(position) : 'arg' must be NULL or a character vector" error, but can't see why?我收到“match.arg(position) 中的错误:'arg' 必须为 NULL 或字符向量”错误,但不知道为什么? I've looked at previous threads about this and they all seem to relate to issues with placement of the elements of the app (eg duplicate sidebarPanel etc), but I can't tell form them what I'm doing wrong.我已经查看了以前关于此的主题,它们似乎都与应用程序元素的放置问题(例如重复的侧边栏面板等)有关,但我无法告诉他们我做错了什么。 I've been developing this app, and it previous iterations the app has at least appeared, with the two selectInput's working.我一直在开发这个应用程序,它之前的迭代应用程序至少已经出现,两个 selectInput 的工作。 Any advice hugely appreciated.非常感谢任何建议。 Apologies for my inelegant coding and layout as I've been trying to follow the formatting instructions, but it just makes it look even worse.为我不雅的编码和布局道歉,因为我一直在尝试遵循格式说明,但这只会让它看起来更糟。 Thinking of giving up completely, as I'm spending hours and getting absolutely nowhere.考虑完全放弃,因为我花了几个小时却一无所获。

Ian伊恩

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#

library(shiny)
library(shinydashboard) 
library(fingertipsR)
library(ggplot2)
library(viridis)
library(plotly)

#Import QOF indicators
setwd("/Users/ianbowns/Documents/R/ShinyFT")
dat <- readRDS("data")
my.df <- as.data.frame(dat)
#Defines year and age category choices
yearchoices <- unique(as.character(my.df$Timeperiod))
indicator <- unique(as.character(my.df$IndicatorName))
# Define UI for application that draws boxplot
ui <- fluidPage(

 # Application title
 titlePanel("FingerTips QOF Prevalences"),

 # Input for year and ages 
 sidebarLayout(
  sidebarPanel(
    selectInput(inputId = "year",
            label = "Choose a year:",
            choices = yearchoices,
            selected = "2015/16"),
    selectInput(inputId = "indicator",
            label = "Choose ages:",
            choices = indicators,
            selected = "All ages")),
  actionButton("goButton", "Refresh graph"),
  # Show a plot of the generated distribution
  mainPanel(
     plotlyOutput("bPlot")
  )
))


# Define server logic required to draw a histogram
server <- function(input, output) {

    inds <- my.df[which(IndicatorID == "input$indicator" & Sex == "Persons" 
          & Timeperiod == "input$year" & ParentCode != "E92000001"),]
# draw the boxplot
#                   input$goButton
        output$bPlot <- renderPlotly({
               plot_ly(data = inds, y = ~Value, color = inds$ParentName, 
type = "box", colors = viridis_pal(alpha = 1, begin = 0, end = 1, direction 
= -1, option = "D")(3), boxpoints = "all", jitter = 0.3, 
pointpos = -1.8) %>% 
               layout(title = "Dementia", titlefont = list(family = 
"Helvetica", size = 16), yaxis = list(title = "Prevalence (%)", titlefont = 
list(family = "Helvetica", size = 12)))})
}
# Run the application
shinyApp(ui = ui, server = server)

Since you havent provided any data to go with it, I will speculate that it doesnt work because you didnt wrap your data into a reactive expression.由于您没有提供任何数据与之配套,我推测它不起作用,因为您没有将数据包装到reactive表达式中。 Try the server below:试试下面的server

# Define server logic required to draw a histogram
server <- function(input, output, session) {

  inds <- reactive({
    my.df[which(IndicatorID %in% input$indicator & Sex == "Persons" 
                & Timeperiod %in% input$year & ParentCode != "E92000001"),]
  })

  # draw the boxplot
  #                   input$goButton
  output$bPlot <- renderPlotly({
    plot_ly(data = inds(), y = ~Value, color = inds()$ParentName, 
            type = "box", colors = viridis_pal(alpha = 1, begin = 0, end = 1, direction 
                                               = -1, option = "D")(3), boxpoints = "all", jitter = 0.3, 
            pointpos = -1.8) %>% 
      layout(title = "Dementia", titlefont = list(family = 
                                                    "Helvetica", size = 16), yaxis = list(title = "Prevalence (%)", titlefont = 
                                                                                            list(family = "Helvetica", size = 12)))})
}
# Run the application
shinyApp(ui = ui, server = server)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行应用程序时出现闪亮错误:match.arg(position) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量 - Shiny Error when running App: Error in match.arg(position) : 'arg' must be NULL or a character vector match.arg(position) 中的闪亮错误:“arg”必须为 NULL 或字符向量 - shiny Error in match.arg(position) : 'arg' must be NULL or a character vector 警告:match.arg中的错误:&#39;arg&#39;必须为NULL或字符向量 - Warning: Error in match.arg: 'arg' must be NULL or a character vector match.arg(regions) 中的错误:“arg”必须为 NULL 或字符向量 - Error in match.arg(regions) : 'arg' must be NULL or a character vector match.arg(opt_crit)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(opt_crit) : 'arg' must be NULL or a character vector match.arg(p.adjust.method)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(p.adjust.method) : 'arg' must be NULL or a character vector 尝试运行以下代码中的插补函数时,“match.arg(what) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量” - "Error in match.arg(what) : 'arg' must be NULL or a character vector" when trying to run the impute function in the below code match.arg(mvnTest)中的错误:“ arg”的长度必须为1 - Error in match.arg(mvnTest) : 'arg' must be of length 1 &#39;arg&#39;必须为NULL或字符向量 - 'arg' must be NULL or a character vector 对多个 arguments 使用 match.arg 时出错 - Error in using match.arg for multiple arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM