I have built a report with a Shiny front-end which uses some macros to inform the population of my final table.
Eg - User selects metric 'Revenue' from dropdown, which pulls in the numerical value from the variable 'total_revenue', as per the IF statement below.
if(metric == 'Revenue') {
report_metric <- 'total_revenue'
} else if (metric == 'Sales'){
thing_name <- 'total_sales'
} else if (metric == 'Refunds'){
thing_name <- 'total_refunds'
} else if (metric == 'Cancellations'){
thing_name <- 'total_cancellations'
}else {
}
The report itself works fine and end result looks something like that below, but what I'd really like to do is have the name of col4 be dynamically changed according the metric choice, in this case 'Revenue'
| date | store_number | manager | report_metric |
|2017-01-01 | 0286 | john appleseed | 2,309 |
|2017-01-01 | 0761 | jane doe | 1,712 |
Is this possible and if so, what is the best way of achieving this?