尝试运行闪亮的应用程序时,我不断收到错误消息“ match.arg(position)中的错误:'arg'必须为NULL或字符向量”。我阅读并重新阅读了我的代码,但似乎找不到问题。我也不知道这个问题是在我的ui代码还是服务器代码中。谁能发现我所缺少的东西?
这是我的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)
答案 0 :(得分:0)
我相信您的问题出在您的UI
上,如果您注意到sidebarLayout
函数有四个参数,而tabPanel
却不是。您目前有sidebarPanel
和mainPanel
,但是在关闭tabPanel
之前还有另一个sidebarLayout
。
如果删除tabPanel,则应该可以使其正常工作。
您可以阅读更多有关其他问题的信息,以更好地理解我的意思。
shiny Error in match.arg(position) : 'arg' must be NULL or a character vector