raw <- read_excel('discharge_data_1.xlsx')
df <- raw[,c(colnames(raw[1]),colnames(raw[2]))]
df %>% ptd_spc(value_field = "Actual pre 12pm discharges", date_field = "Date", improvement_direction = "decrease")`
I’m trying to understand why I can’t run using the below instead:
df %>% ptd_spc(value_field = colnames(df[2]) , date_field = colnames(df[1]), improvement_direction = "decrease")
I get the error: value_field: 'colnames(df[2])' must be a valid column name in the data frame. Is there a way that I can create a variable for these fields which will be pulled directly from read_excel if the data changes (assume the columns of interest will always be the first two columns in the excel file)