Skip to content

merge industry subsector structuremappingIO files back into originals #448

Description

Running calcOutput("IO", subtype = "output", file = "f04_IO_output.cs4r") once with structuremappingIO_outputs.csv and once with structuremappingIO_outputs_Industry_subsectors.csv as the mapping file yields two results:
f04_IO_output.csv
f04_IO_output_Industry_subsectors.csv

comp <- full_join(
  read_csv(file = '/tmp/f04_IO_output.csv',
                      col_names = c('t', 'regi', 'enty.1', 'enty.2', 'te',
                                    'value_outputs'),
                      col_types = 'iccccd',
                      comment = '*') %>% 
  arrange(t, regi, enty.1, enty.2, te),
  
  read_csv(file = '/tmp/f04_IO_output_Industry_subsectors.csv',
                         col_names = c('t', 'regi', 'enty.1', 'enty.2', 'te',
                                       'value_subsectors'),
                         col_types = 'iccccd',
                         comment = '*') %>% 
  arrange(t, regi, enty.1, enty.2, te),
  
  c('t', 'regi', 'enty.1', 'enty.2', 'te')
)

Differences where outputs and subsectors have different values are limited to

comp %>% 
  filter(value_outputs != value_subsectors) %>% 
  mutate(diff = value_subsectors - value_outputs) %>% 
  distinct(enty.1, enty.2, te)
  enty.1   enty.2   te      
  <chr>    <chr>    <chr>   
1 pecoal   segafos  coalgas 
2 pecoal   sesofos  coaltr  
3 seliqfos fehoi_cs tdhoi_cs

Differences where outputs has values, but subsectors does not:

comp %>% 
  filter(is.na(value_subsectors)) %>% 
  distinct(enty.1, enty.2, te)
   enty.1   enty.2   te      
   <chr>    <chr>    <chr>   
 1 seel     feelcb   tdelb   
 2 seel     feeli    tdeli   
 3 segabio  fegai    tdbiogai
 4 segafos  fegai    tdfosgai
 5 segafos  fegai_cs tdgai_cs
 6 sehe     fehei    tdhei   
 7 seliqbio fehoi    tdbiohoi
 8 seliqfos fehoi    tdfoshoi
 9 sesobio  fesoi    tdbiosoi
10 sesofos  fesoi    tdfossoi

Differences where subsectors has values, but outputs does not:

comp %>% 
  filter(is.na(value_outputs)) %>% 
  distinct(enty.1, enty.2, te) %>% 
  print(n = Inf)
   enty.1   enty.2             te                
   <chr>    <chr>              <chr>             
 1 seel     feel_cement        tdel_cement       
 2 seel     feel_steel         tdel_steel        
 3 seel     feelwlth_chemicals tdelwlth_chemicals
 4 seel     feelwlth_otherInd  tdelwlth_otherInd 
 5 segabio  fega_cement        tdga_cement       
 6 segabio  fega_chemicals     tdga_chemicals    
 7 segabio  fega_otherInd      tdga_otherInd     
 8 segabio  fega_steel         tdga_steel        
 9 segafos  fega_cement        tdga_cement       
10 segafos  fega_chemicals     tdga_chemicals    
11 segafos  fega_otherInd      tdga_otherInd     
12 segafos  fega_steel         tdga_steel        
13 segafos  fegai_cs           tdfosgai_cs       
14 sehe     fehe_otherInd      tdhe_otherInd     
15 seliqbio feli_cement        tdli_cement       
16 seliqbio feli_chemicals     tdli_chemicals    
17 seliqbio feli_otherInd      tdli_otherInd     
18 seliqbio feli_steel         tdli_steel        
19 seliqfos feli_cement        tdli_cement       
20 seliqfos feli_chemicals     tdli_chemicals    
21 seliqfos feli_otherInd      tdli_otherInd     
22 seliqfos feli_steel         tdli_steel        
23 sesobio  feso_cement        tdso_cement       
24 sesobio  feso_chemicals     tdso_chemicals    
25 sesobio  feso_otherInd      tdso_otherInd     
26 sesobio  feso_steel         tdso_steel        
27 sesofos  feso_cement        tdso_cement       
28 sesofos  feso_chemicals     tdso_chemicals    
29 sesofos  feso_otherInd      tdso_otherInd     
30 sesofos  feso_steel         tdso_steel   

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions