1

Consider a shiny app with the following folder structure (github here):

├── data
│   └── import_finance.R
│   └── data.xlsx
├── dashboard.R
├── ui_elements
│   └── sidebar.R
│   └── body.R

The import_finance.R runs correctly when not run in the shiny app. However, when running the shiny app it fails to recognize the path.

# list of quarterly earnings worksheets
file_paths <- list.files('dashboard/data', pattern = 'xlsx', full.names = TRUE)
path <- file_paths[1]


# import all sheets from each workbook and merge to one df

 import <-
  path %>%
  excel_sheets() %>%
  set_names() %>%
  map_df(xlsx_cells, path = path) %>%
  mutate(workbook = word(path, -1, sep = '/')) # add column with file_name

Shiny says Error: path does not exist: ‘NA’. Please note that import_finance.R is called in dashboard.R via source("data/import_finance.R").

Even when specifying the full path the error persists. This thread claims the same error:

> system.file("/Users/pblack/Documents/Git Projects/opensource-freetoplay-economics/dashboard/data/dashboard/data/ATVI 12-Quarter Financial Model Q1 CY20a.xlsx")  
[1] ""

Any idea of the mistake I'm making? It's strange the script runs fine, but just not when running as a shiny app.

Phillip Black
  • 105
  • 1
  • 2
  • 10

1 Answers1

0

The error here was in

# list of quarterly earnings worksheets
file_paths <- list.files('dashboard/data', pattern = 'xlsx', full.names = TRUE)

When the shiny app was running it was operating from the data folder as the working directory when running source("data/import_finance.R").

To accommodate simply

# list of quarterly earnings worksheets
file_paths <- list.files('data', pattern = 'xlsx', full.names = TRUE)
Phillip Black
  • 105
  • 1
  • 2
  • 10