2

I keep getting the error "Error in match.arg(position) : 'arg' must be NULL or a character vector" when trying to run my shiny app. I read and reread my code and I can't seem to find an issue. I also have no idea whether this issue is in my ui code or server code. Can anyone spot what I'm missing?

Here's my ui logic:

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

and here's my server logic:

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)

1 Answers1

2

I believe your issue is in your UI If you notice the sidebarLayout function has four arguments and tabPanel is not of them. You currently have sidebarPanel and mainPanel but then have another tabPanel before closing the sidebarLayout.

If you delete the tabPanel you should be able to get it to work.

You can read a little more on this other question to get a better idea of what I mean.

shiny Error in match.arg(position) : 'arg' must be NULL or a character vector

Hansel Palencia
  • 1,006
  • 9
  • 17
  • Thank you this helped! My shiny is running now, but for some reason my output in my DT table has disappeared. All I did was close my sidebarLayout and move tabPanel outside as did above. Why would this effect my DT output? – Sydney Sorkin Dec 02 '19 at 16:11
  • Probably an issue with where things are placed again. Try moving it around to make sure it isn't something in the server and then play with placement. If my answer was correct please accept it as the correct answer :) – Hansel Palencia Dec 02 '19 at 17:28