R Shiny 不读取文件路径
R Shiny not reading file path
考虑具有以下文件夹结构的闪亮应用程序 (github here):
├── data
│ └── import_finance.R
│ └── data.xlsx
├── dashboard.R
├── ui_elements
│ └── sidebar.R
│ └── body.R
import_finance.R
运行 在闪亮的应用程序中不 运行 时是正确的。但是,当 运行 启动闪亮的应用程序时,它无法识别路径。
# 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
闪亮说 Error: path does not exist: ‘NA’
。请注意 import_finance.R
通过 source("data/import_finance.R")
在 dashboard.R
中调用。
即使指定了完整路径,错误仍然存在。这个 thread 声称同样的错误:
> system.file("/Users/pblack/Documents/Git Projects/opensource-freetoplay-economics/dashboard/data/dashboard/data/ATVI 12-Quarter Financial Model Q1 CY20a.xlsx")
[1] ""
知道我犯的错误吗?奇怪的是脚本 运行 很好,但当 运行 宁作为一个闪亮的应用程序时就不行了。
这里的错误在
# list of quarterly earnings worksheets
file_paths <- list.files('dashboard/data', pattern = 'xlsx', full.names = TRUE)
当 shiny 应用 运行 时,它从 data
文件夹作为工作目录运行 当 运行 source("data/import_finance.R")
.
简单容纳
# list of quarterly earnings worksheets
file_paths <- list.files('data', pattern = 'xlsx', full.names = TRUE)
考虑具有以下文件夹结构的闪亮应用程序 (github here):
├── data
│ └── import_finance.R
│ └── data.xlsx
├── dashboard.R
├── ui_elements
│ └── sidebar.R
│ └── body.R
import_finance.R
运行 在闪亮的应用程序中不 运行 时是正确的。但是,当 运行 启动闪亮的应用程序时,它无法识别路径。
# 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
闪亮说 Error: path does not exist: ‘NA’
。请注意 import_finance.R
通过 source("data/import_finance.R")
在 dashboard.R
中调用。
即使指定了完整路径,错误仍然存在。这个 thread 声称同样的错误:
> system.file("/Users/pblack/Documents/Git Projects/opensource-freetoplay-economics/dashboard/data/dashboard/data/ATVI 12-Quarter Financial Model Q1 CY20a.xlsx")
[1] ""
知道我犯的错误吗?奇怪的是脚本 运行 很好,但当 运行 宁作为一个闪亮的应用程序时就不行了。
这里的错误在
# list of quarterly earnings worksheets
file_paths <- list.files('dashboard/data', pattern = 'xlsx', full.names = TRUE)
当 shiny 应用 运行 时,它从 data
文件夹作为工作目录运行 当 运行 source("data/import_finance.R")
.
简单容纳
# list of quarterly earnings worksheets
file_paths <- list.files('data', pattern = 'xlsx', full.names = TRUE)