Issues publishing shiny to shinyapps.io

...
I am trying to publish my shiny app to shinyapps.io and everything deploys correctly, but I am unsure how to pull the data so that it is able to be used on the web.

I currently have it said up as read.csv for pulling the data in my project directory, but I have an error that says "Paths should be to files directly within the project directory" Which is where I have the file located.

The app is deployed here: https://shawngillapps.shinyapps.io/FantasyFootballStats/ but it is returning an error because of this. Any insight would be much appreciated!!

-Shawn

EDIT:

Here is my code

library(shiny)
library(shiny)
library(tidyverse)
library(shinyWidgets)
library(plotly)
library(ggplot2)
library(nflplotR)
library(readr)
library(dplyr)
library(DT)
library(shinythemes)
library(ggdark)

allowing for the code to be read online

AllStats <- read_csv("C:/Users/shawn/Downloads/R/FantasyFootballStats/Fantasy_Stats_2021.csv")

columns = colnames(AllStats)

Define UI for application

ui <- fluidPage(theme = shinytheme("cosmo"),
titlePanel("Fantasy Football Stats 2016-2021"),

            # Sidebar for multiple inputs
            sidebarLayout(
              sidebarPanel(
                selectInput("Season", "Select Season(s)", AllStats$Season, multiple = TRUE),
                selectInput("Player", "Select Players(s)", AllStats$Player, multiple = TRUE),
                selectInput("stat", "Select Statistic(s)", choices = columns)),
              
              mainPanel(
                tabsetPanel(
                  tabPanel("Table",
                           DT::dataTableOutput("player_stats")),## table of stats for viewing
                  tabPanel("Graph #1",
                           plotOutput("nflPlot")),
                  tabPanel("Graph #2",
                           plotOutput("distPlot")))),  ## graph for viewing
                 
            )

)

Define server logic required to display graph and table

server <- function(input, output) {
output$player_stats = DT::renderDataTable({
filter_table = filter(AllStats, Season %in% input$Season & Player %in% input$Player)#creating the data table
})

output$nflPlot <- renderPlot({
All_Stats <- filter(AllStats, Player %in% input$Player, Season %in% input$Season) ## creating output for graph

ggplot(data = All_Stats, aes(x = Season, y= get(input$stat), z= Player)) +
  geom_line(colour = "red", fill = "white") +
  xlab("Season")+
  ylab("Chosen Stat")+
  dark_theme_classic()+
  ggtitle("Chosen Stat Comparison by Season")+
  theme(plot.title = element_text(hjust = 0.5, size = 18))

})

output$distPlot <- renderPlot({
All_Stats <- filter(AllStats, Player %in% input$Player, Season %in% input$Season) ## creating output for graph

ggplot(data = All_Stats, aes(x = Player, y= get(input$stat))) +
  geom_col(fill = "red", colour = "white") +
  xlab("Player")+
  ylab("Chosen Stat")+
  dark_theme_classic()+
  ggtitle("Chosen Stat Comparison")+
  theme(plot.title = element_text(hjust = 0.5, size = 18))

})

}

Also define logic to draw season over season bar chart

Run the application

shinyApp(ui = ui, server = server)

Once deployed, read.csv will look at the local directory. Does it work if you remove the full filepath and update to this?

AllStats <- read_csv("Fantasy_Stats_2021.csv")
1 Like

Can't believe it was that easy. Thank you so much!!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.