Description Usage Arguments Functions See Also Examples
This function splits an input data frame into a list with 2 data frames: (1) a sheet header with activity details used by implan, and (2) the sector spending with additional columns which implan will calculate. The data portion is also grouped by sector-retail to ensure the minimum number of rows.
1 2 3 4 5 | input_prep(dat, activity_name, event_year, group)
input_prep_ind(dat, activity_name, event_year)
input_prep_comm(dat, activity_name, event_year)
|
dat |
data frame with spending by sector with 4 required columns: group ("Ind" or "Comm"), sector (numeric), retail ("Yes" or "No"), spend (numeric) |
activity_name |
Activity Name used for Implan |
event_year |
Activity Year for Implan |
group |
Either "Ind" or "Comm" |
input_prep_ind
: Prepare industry data
input_prep_comm
: Prepare commodity data
Other functions for implan input:
check_implan_sums()
,
input_header()
,
input_write()
,
input()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # get necessary sectoring
data(category_to_sector536, sector536_to_sector546, sectors546)
category_to_sector546 <- sector_update(category_to_sector536, sector536_to_sector546, sectors546)
# calculate total spending by sector
library(dplyr)
data(spending, item_to_category)
spend_category <- spending %>%
left_join(item_to_category, by = c("activity_group", "type", "item")) %>%
mutate(spend = spend * share)
check_spend_sums(spending, spend_category, spend, activity_group, type, item)
spend_sector <- spend_category %>%
select(-share) %>%
left_join(category_to_sector546, by = "category") %>%
mutate(spend = spend * share)
check_spend_sums(spend_category, spend_sector, spend, type, item, category)
# allocate for implan import (Industry)
comm <- input_prep_comm(spend_sector, "huntComm", 2019)
ind <- input_prep_ind(spend_sector, "huntInd", 2019)
ind
# write to an excel worksheet
# you'll need to manually save as ".xls" (in Excel) from Implan import
## Not run:
input_write(ind, "tmp.xlsx")
## End(Not run)
# write sheets by activity
## Not run:
input(spend_sector, "tmp2.xlsx", 2019, act)
check_implan_sums(spend_sector, "tmp2.xlsx", act, print_compare = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.