library(dplyr)
library(data.table)
library(readxl)
macro <-
list()
macro$filepath <-
'C:\\Users\\TMC\\Documents'
macro$file <-
list.files(
macro$filepath,
pattern = 'EventData.xlsx',
full.names = TRUE)
macro$sheet <-
'FY21'
macro$first_dt <-
'2021-02-01' %>% as.Date
dat <-
macro$file[regexpr('~', macro$file) < 0] %>%
read_xlsx(., sheet = macro$sheet) %>%
data.table
dat <-
dat[!(DESCRIPTION %in% 'AEG')]
macro$keep <-
c(
'Product vs. buzz',
'CATEGORY',
'JUN',
'JUL',
'AUG',
'SEP',
'OCT',
'NOV',
'DEC',
'JAN',
'FEB',
'MAR',
'APR',
'MAY')
dat <-
dat[
,
intersect(macro$keep, dat %>% names),
with = FALSE]
setnames(
dat,
c('Product vs. buzz', 'CATEGORY'),
c('evt_type', 'raw'))
dat[, raw := (raw %>% tolower)]
##ISSUE IS HERE
macro$category <-
list.files(
macro$filepath,
pattern = 'BrandEventCategoryMapping',
full.names = TRUE) %>%
read_xlsx %>%
data.table
Hi all, I am trying to run the above code in R. when I try to read the excel file in the macro$category section I get the following error:
Error: `path` must be a string
Can anyone please help me out and let me know what I should do or edit to fix this? I am not good at R and have to unfortunately run someone else's script for a time sensitive deadline. I would really appreciate some help!