簡體   English   中英

運行應用程序時出現閃亮錯誤:match.arg(position) 中的錯誤:'arg' 必須為 NULL 或字符向量

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

嘗試運行我的閃亮應用程序時,我不斷收到錯誤“match.arg(position) 中的錯誤:'arg' 必須為 NULL 或字符向量”。 我反復閱讀我的代碼,但似乎找不到問題。 我也不知道這個問題是在我的 ui 代碼還是服務器代碼中。 誰能發現我錯過了什么?

這是我的用戶界面邏輯:

library(rtweet)
library(tidytext)
library(tidyverse)
library(stringr)
library(shiny)
library(DT)
library(markdown)
library(shinythemes)

source("R_rainclouds.R")


#create variables for ggplot
joined_names_tweets <- read_rds("joined_names_tweets.rds")
tweets <- read_rds("tweets.rds")


ui <- navbarPage("Project",
                 theme = shinytheme("united"),

     ###########
     ###DATA###
     ##########

           tabPanel("Graphics",
                    tabsetPanel(
                      tabPanel("Over Time",
                               sidebarPanel(
                                 selectInput("screen_name", "NCAA Twitter Accounts:",
                                             choices = joined_names_tweets$screen_name),
                                 mainPanel(plotOutput("raincloud")))),
                      tabPanel("Stuff"))),

    #############
    ##EXPLORE###
    ############

           tabPanel("Explore",

                    fluidPage(
                      titlePanel("Explore the data"),

                      sidebarLayout(
                        sidebarPanel(
                          helpText("Pick an NCAA Twitter Account to view recent tweets"),
                          h3("Tweet Search"),
                          selectInput("screen_name", NULL,
                                      choices = tweets$screen_name,
                                      selected = "@NCAA")),
                        mainPanel(
                          DTOutput("word_table")),
    ##########
    ##ABOUT##
    #########
                    tabPanel("About",
                    fluidRow(
                        column(8,
                               includeMarkdown("about.Rmd"))))))))

這是我的服務器邏輯:

server <- function(input, output, session) {

  ########
  ##DATA##
  ########

  output$raincloud <- renderPlot({

    data <- joined_names_tweets %>%
      filter(screen_name == input$screen_name) %>% 

      ggplot(aes(x=sex_id,y=created_at, fill = sex_id)) +
      geom_flat_violin(position = position_nudge(x = .2, y = 0),adjust = 4) +
      geom_point(position = position_jitter(width = .15), size = .25, alpha = .5) +
      ylab('Date')+
      xlab('Gender')+
      coord_flip()+
      theme_cowplot()+
      guides(fill = FALSE) +
      scale_fill_manual(values = c("snow1", "steelblue"))
  })


  ############
  ##EXPLORE##
  ###########

  output$word_table <- renderDT({

    datatable(tweets %>% filter(screen_name == input$screen_name) %>% select(-screen_name),
              class = 'display',
              rownames = FALSE,
              selection = 'single',
              colnames = c("Tweet Text", "Date", "Favorites", "Retweets"),
              options = list(dom = 'tip'))
  })

}


# Run the application 
shinyApp(ui = ui, server = server)

我相信您的問題出在您的UI如果您注意到sidebarLayout函數有四個參數而tabPanel不屬於其中。 您目前有sidebarPanelmainPanel但在關閉sidebarLayout之前還有另一個tabPanel

如果您刪除 tabPanel,您應該能夠讓它工作。

您可以閱讀有關其他問題的更多信息,以更好地了解我的意思。

match.arg(position) 中的閃亮錯誤:“arg”必須為 NULL 或字符向量

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM