Setup

Load Packages

library( irs990efile )  # functions for parsing efile XMLs
library( dplyr )        # data wrangling
library( purrr )        # data wrangling 
library( pander )       # formatting
library( knitr )        # formatting
library( DT )           # table printing
library( httr )         # web requests 
library( xmltools )     # xml utilities
library( xml2 )         # xml utilities
library( XML )          # xml utilities 
library( data.tree )    # network visualization
library( networkD3 )    # network visualization
library( igraph )       # network visualization

source( "R/rdb-functions-v2.R")
source( "R/utils.R")

Data

head( index )

The Concordance File

The concordance is an RDB to XML Crosswalk that maps all xpaths onto a specified set of variables. It is located in the irs990efile package.


The full data dictionary is available on GitHub.

DATA DICTIONARY


concordance %>% 
  filter( rdb_table == table.name )  








xpath id
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesEvent1 1
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesEvent2 2
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesOtherEvents 3
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContribOtherEvents 4
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContributionsEvent1 5
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContributionsEvent2 6
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentEvent1 7
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentEvent2 8
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentOtherEvents 9
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageEvent1 10
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageEvent2 11
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageOtherEvents 12
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsEvent1 13
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsEvent2 14
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsOtherEvents 15
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueEvent1 16
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueEvent2 17
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueOtherEvents 18
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NameOfEvent1 19
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NameOfEvent2 20
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesEvent1 21
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesEvent2 22
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesOtherEvents 23
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesEvent1 24
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesEvent2 25
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesOtherEvents 26
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsEvent1 27
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsEvent2 28
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsOtherEvents 29
/Return/ReturnData/IRS990ScheduleG/EventsInformation/TotalNumberOfOtherEvents 30
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesEvent1 31
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesEvent2 32
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesOtherEvents 33
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContribOtherEvents 34
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContributionsEvent1 35
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContributionsEvent2 36
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsEvent1 37
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsEvent2 38
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsOtherEvents 39
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueEvent1 40
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueEvent2 41
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueOtherEvents 42
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NameOfEvent1 43
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NameOfEvent2 44
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesEvent1 45
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesEvent2 46
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesOtherEvents 47
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesEvent1 48
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesEvent2 49
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesOtherEvents 50
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsEvent1 51
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsEvent2 52
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsOtherEvents 53
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/TotalNumberOfOtherEvents 54
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesEvent1Amt 55
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesEvent2Amt 56
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesOtherEventsAmt 57
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriEvent1Amt 58
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriEvent2Amt 59
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriOtherEventsAmt 60
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentEvent1Amt 61
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentEvent2Amt 62
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentOtherEventsAmt 63
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/Event1Nm 64
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/Event2Nm 65
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageEvent1Amt 66
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageEvent2Amt 67
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageOtherEventsAmt 68
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsEvent1Amt 69
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsEvent2Amt 70
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsOtherEventsAmt 71
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueEvent1Amt 72
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueEvent2Amt 73
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueOtherEventsAmt 74
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NameOfEvent1Amt 75
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NameOfEvent2Amt 76
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesEvent1Amt 77
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesEvent2Amt 78
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesOtherEventsAmt 79
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OthDirectExpnssOtherEventsAmt 80
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherDirectExpensesEvent1Amt 81
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherDirectExpensesEvent2Amt 82
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherEventsTotalCnt 83
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFacilityCostsEvent1Amt 84
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFacilityCostsEvent2Amt 85
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFcltyCostsOtherEventsAmt 86
xpaths <- as.character( t.xpaths$xpath )
el <- create_edgelist_v1( xpaths )
nd <- FromDataFrameNetwork( network=el )
print( nd )
##                                             levelName
## 1  Return                                            
## 2   °--ReturnData                                    
## 3       °--IRS990ScheduleG                           
## 4           ¦--EventsInformation                     
## 5           ¦   ¦--CashPrizesEvent1                  
## 6           ¦   ¦--CashPrizesEvent2                  
## 7           ¦   ¦--CashPrizesOtherEvents             
## 8           ¦   ¦--CharitableContribOtherEvents      
## 9           ¦   ¦--CharitableContributionsEvent1     
## 10          ¦   ¦--CharitableContributionsEvent2     
## 11          ¦   ¦--EntertainmentEvent1               
## 12          ¦   ¦--EntertainmentEvent2               
## 13          ¦   ¦--EntertainmentOtherEvents          
## 14          ¦   ¦--FoodAndBeverageEvent1             
## 15          ¦   ¦--FoodAndBeverageEvent2             
## 16          ¦   ¦--FoodAndBeverageOtherEvents        
## 17          ¦   ¦--GrossReceiptsEvent1               
## 18          ¦   ¦--GrossReceiptsEvent2               
## 19          ¦   ¦--GrossReceiptsOtherEvents          
## 20          ¦   ¦--GrossRevenueEvent1                
## 21          ¦   ¦--GrossRevenueEvent2                
## 22          ¦   ¦--GrossRevenueOtherEvents           
## 23          ¦   ¦--NameOfEvent1                      
## 24          ¦   ¦--NameOfEvent2                      
## 25          ¦   ¦--NonCashPrizesEvent1               
## 26          ¦   ¦--NonCashPrizesEvent2               
## 27          ¦   ¦--NonCashPrizesOtherEvents          
## 28          ¦   ¦--OtherDirectExpensesEvent1         
## 29          ¦   ¦--OtherDirectExpensesEvent2         
## 30          ¦   ¦--OtherDirectExpensesOtherEvents    
## 31          ¦   ¦--RentFacilityCostsEvent1           
## 32          ¦   ¦--RentFacilityCostsEvent2           
## 33          ¦   ¦--RentFacilityCostsOtherEvents      
## 34          ¦   °--TotalNumberOfOtherEvents          
## 35          ¦--Form990ScheduleGPartII                
## 36          ¦   °--EventsInformation                 
## 37          ¦       ¦--CashPrizesEvent1              
## 38          ¦       ¦--CashPrizesEvent2              
## 39          ¦       ¦--CashPrizesOtherEvents         
## 40          ¦       ¦--CharitableContribOtherEvents  
## 41          ¦       ¦--CharitableContributionsEvent1 
## 42          ¦       ¦--CharitableContributionsEvent2 
## 43          ¦       ¦--EntertainmentEvent1           
## 44          ¦       ¦--EntertainmentEvent2           
## 45          ¦       ¦--EntertainmentOtherEvents      
## 46          ¦       ¦--FoodAndBeverageEvent1         
## 47          ¦       ¦--FoodAndBeverageEvent2         
## 48          ¦       ¦--FoodAndBeverageOtherEvents    
## 49          ¦       ¦--GrossReceiptsEvent1           
## 50          ¦       ¦--GrossReceiptsEvent2           
## 51          ¦       ¦--GrossReceiptsOtherEvents      
## 52          ¦       ¦--GrossRevenueEvent1            
## 53          ¦       ¦--GrossRevenueEvent2            
## 54          ¦       ¦--GrossRevenueOtherEvents       
## 55          ¦       ¦--NameOfEvent1                  
## 56          ¦       ¦--NameOfEvent2                  
## 57          ¦       ¦--NonCashPrizesEvent1           
## 58          ¦       ¦--NonCashPrizesEvent2           
## 59          ¦       ¦--NonCashPrizesOtherEvents      
## 60          ¦       ¦--OtherDirectExpensesEvent1     
## 61          ¦       ¦--OtherDirectExpensesEvent2     
## 62          ¦       ¦--OtherDirectExpensesOtherEvents
## 63          ¦       ¦--RentFacilityCostsEvent1       
## 64          ¦       ¦--RentFacilityCostsEvent2       
## 65          ¦       ¦--RentFacilityCostsOtherEvents  
## 66          ¦       °--TotalNumberOfOtherEvents      
## 67          °--FundraisingEventInformationGrp        
## 68              ¦--CashPrizesEvent1Amt               
## 69              ¦--CashPrizesEvent2Amt               
## 70              ¦--CashPrizesOtherEventsAmt          
## 71              ¦--CharitableContriEvent1Amt         
## 72              ¦--CharitableContriEvent2Amt         
## 73              ¦--CharitableContriOtherEventsAmt    
## 74              ¦--EntertainmentEvent1Amt            
## 75              ¦--EntertainmentEvent2Amt            
## 76              ¦--EntertainmentOtherEventsAmt       
## 77              ¦--Event1Nm                          
## 78              ¦--Event2Nm                          
## 79              ¦--FoodAndBeverageEvent1Amt          
## 80              ¦--FoodAndBeverageEvent2Amt          
## 81              ¦--FoodAndBeverageOtherEventsAmt     
## 82              ¦--GrossReceiptsEvent1Amt            
## 83              ¦--GrossReceiptsEvent2Amt            
## 84              ¦--GrossReceiptsOtherEventsAmt       
## 85              ¦--GrossRevenueEvent1Amt             
## 86              ¦--GrossRevenueEvent2Amt             
## 87              ¦--GrossRevenueOtherEventsAmt        
## 88              ¦--NameOfEvent1Amt                   
## 89              ¦--NameOfEvent2Amt                   
## 90              ¦--NonCashPrizesEvent1Amt            
## 91              ¦--NonCashPrizesEvent2Amt            
## 92              ¦--NonCashPrizesOtherEventsAmt       
## 93              ¦--OthDirectExpnssOtherEventsAmt     
## 94              ¦--OtherDirectExpensesEvent1Amt      
## 95              ¦--OtherDirectExpensesEvent2Amt      
## 96              ¦--OtherEventsTotalCnt               
## 97              ¦--RentFacilityCostsEvent1Amt        
## 98              ¦--RentFacilityCostsEvent2Amt        
## 99              °--RentFcltyCostsOtherEventsAmt
SetGraphStyle( nd, rankdir = "LR")
SetEdgeStyle( nd, arrowhead = "vee", color = "grey20", penwidth = 2 )
SetNodeStyle( nd, 
              style = "filled,rounded", 
              shape = "box", 
              fillcolor = "LightBlue", 
              fontname = "helvetica", 
              fontcolor="black",
              tooltip = GetDefaultTooltip )

# SetNodeStyle(acme$IT, fillcolor = "LightBlue", penwidth = "5px")
plot( nd )
# old version
find_group_names( table.name )
## [1] "//Form990ScheduleGPartII"         "//EventsInformation"             
## [3] "//FundraisingEventInformationGrp"
# new version
find_table_headers( table.name )
##  [1] "//Form990ScheduleGPartII/NameOfEvent1"                          
##  [2] "//Form990ScheduleGPartII/NameOfEvent2"                          
##  [3] "//Form990ScheduleGPartII/TotalNumberOfOtherEvents"              
##  [4] "//Form990ScheduleGPartII/GrossReceiptsEvent1"                   
##  [5] "//Form990ScheduleGPartII/GrossReceiptsEvent2"                   
##  [6] "//Form990ScheduleGPartII/GrossReceiptsOtherEvents"              
##  [7] "//Form990ScheduleGPartII/GrossReceiptsTotal"                    
##  [8] "//Form990ScheduleGPartII/CharitableContributionsEvent1"         
##  [9] "//Form990ScheduleGPartII/CharitableContributionsEvent2"         
## [10] "//Form990ScheduleGPartII/CharitableContribOtherEvents"          
## [11] "//Form990ScheduleGPartII/CharitableContributionsTotal"          
## [12] "//Form990ScheduleGPartII/GrossRevenueEvent1"                    
## [13] "//Form990ScheduleGPartII/GrossRevenueEvent2"                    
## [14] "//Form990ScheduleGPartII/GrossRevenueOtherEvents"               
## [15] "//Form990ScheduleGPartII/GrossRevenueTotalEvents"               
## [16] "//Form990ScheduleGPartII/CashPrizesEvent1"                      
## [17] "//Form990ScheduleGPartII/CashPrizesEvent2"                      
## [18] "//Form990ScheduleGPartII/CashPrizesOtherEvents"                 
## [19] "//Form990ScheduleGPartII/CashPrizesTotalEvents"                 
## [20] "//Form990ScheduleGPartII/NonCashPrizesEvent1"                   
## [21] "//Form990ScheduleGPartII/NonCashPrizesEvent2"                   
## [22] "//Form990ScheduleGPartII/NonCashPrizesOtherEvents"              
## [23] "//Form990ScheduleGPartII/NonCashPrizesTotalEvents"              
## [24] "//Form990ScheduleGPartII/RentFacilityCostsEvent1"               
## [25] "//Form990ScheduleGPartII/RentFacilityCostsEvent2"               
## [26] "//Form990ScheduleGPartII/RentFacilityCostsOtherEvents"          
## [27] "//Form990ScheduleGPartII/RentFacilityCostsTotalEvents"          
## [28] "//Form990ScheduleGPartII/OtherDirectExpensesEvent1"             
## [29] "//Form990ScheduleGPartII/OtherDirectExpensesEvent2"             
## [30] "//Form990ScheduleGPartII/OtherDirectExpensesOtherEvents"        
## [31] "//Form990ScheduleGPartII/OtherDirectExpensesTotalEvents"        
## [32] "//Form990ScheduleGPartII/DirectExpenseSummaryEvents"            
## [33] "//Form990ScheduleGPartII/NetIncomeSummary"                      
## [34] "//EventsInformation/Form990ScheduleGPartII"                     
## [35] "//EventsInformation/EventsInformation"                          
## [36] "//FundraisingEventInformationGrp/Event1Nm"                      
## [37] "//FundraisingEventInformationGrp/NameOfEvent1Amt"               
## [38] "//FundraisingEventInformationGrp/Event2Nm"                      
## [39] "//FundraisingEventInformationGrp/NameOfEvent2Amt"               
## [40] "//FundraisingEventInformationGrp/OtherEventsTotalCnt"           
## [41] "//FundraisingEventInformationGrp/GrossReceiptsEvent1Amt"        
## [42] "//FundraisingEventInformationGrp/GrossReceiptsEvent2Amt"        
## [43] "//FundraisingEventInformationGrp/GrossReceiptsOtherEventsAmt"   
## [44] "//FundraisingEventInformationGrp/GrossReceiptsTotalAmt"         
## [45] "//FundraisingEventInformationGrp/CharitableContriEvent1Amt"     
## [46] "//FundraisingEventInformationGrp/CharitableContriEvent2Amt"     
## [47] "//FundraisingEventInformationGrp/CharitableContriOtherEventsAmt"
## [48] "//FundraisingEventInformationGrp/CharitableContributionsTotAmt" 
## [49] "//FundraisingEventInformationGrp/GrossRevenueEvent1Amt"         
## [50] "//FundraisingEventInformationGrp/GrossRevenueEvent2Amt"         
## [51] "//FundraisingEventInformationGrp/GrossRevenueOtherEventsAmt"    
## [52] "//FundraisingEventInformationGrp/GrossRevenueTotalEventsAmt"    
## [53] "//FundraisingEventInformationGrp/CashPrizesEvent1Amt"           
## [54] "//FundraisingEventInformationGrp/CashPrizesEvent2Amt"           
## [55] "//FundraisingEventInformationGrp/CashPrizesOtherEventsAmt"      
## [56] "//FundraisingEventInformationGrp/CashPrizesTotalEventsAmt"      
## [57] "//FundraisingEventInformationGrp/NonCashPrizesEvent1Amt"        
## [58] "//FundraisingEventInformationGrp/NonCashPrizesEvent2Amt"        
## [59] "//FundraisingEventInformationGrp/NonCashPrizesOtherEventsAmt"   
## [60] "//FundraisingEventInformationGrp/NonCashPrizesTotalEventsAmt"   
## [61] "//FundraisingEventInformationGrp/RentFacilityCostsEvent1Amt"    
## [62] "//FundraisingEventInformationGrp/RentFacilityCostsEvent2Amt"    
## [63] "//FundraisingEventInformationGrp/RentFcltyCostsOtherEventsAmt"  
## [64] "//FundraisingEventInformationGrp/RentFcltyCostsTotalEventsAmt"  
## [65] "//FundraisingEventInformationGrp/FoodAndBeverageEvent1Amt"      
## [66] "//FundraisingEventInformationGrp/FoodAndBeverageEvent2Amt"      
## [67] "//FundraisingEventInformationGrp/FoodAndBeverageOtherEventsAmt" 
## [68] "//FundraisingEventInformationGrp/FoodAndBeverageTotalEventsAmt" 
## [69] "//FundraisingEventInformationGrp/EntertainmentEvent1Amt"        
## [70] "//FundraisingEventInformationGrp/EntertainmentEvent2Amt"        
## [71] "//FundraisingEventInformationGrp/EntertainmentOtherEventsAmt"   
## [72] "//FundraisingEventInformationGrp/EntertainmentTotalEventsAmt"   
## [73] "//FundraisingEventInformationGrp/OtherDirectExpensesEvent1Amt"  
## [74] "//FundraisingEventInformationGrp/OtherDirectExpensesEvent2Amt"  
## [75] "//FundraisingEventInformationGrp/OthDirectExpnssOtherEventsAmt" 
## [76] "//FundraisingEventInformationGrp/OthDirectExpnssTotalEventsAmt" 
## [77] "//FundraisingEventInformationGrp/DirectExpenseSummaryEventsAmt" 
## [78] "//FundraisingEventInformationGrp/NetIncomeSummaryAmt"
# manual
if( ! is.null(table.headers) )
{table.headers}








Build the Table

# create new folder
dir.create( folder.name )
setwd( folder.name )

# create sample
set.seed( 1234 )
sample.index <- sample_n( index, sample.size )
write.csv( index, "sample-index.csv", row.names=F )
sample.urls <- sample.index$URL

# erase existing log files
file.create("XPATH-LOG.txt") 
file.create("FAIL-LOG.txt")


start.build.time <- Sys.time()    # --------------------

results.list <- list()
xpath.list <- list()


for( i in 1:length( sample.urls ) )
{
  
  url <- sample.urls[i]
  
  results.list[[i]] <- 
    build_rdb_table_v2( url, 
                        table.name, 
                        table.headers=table.headers )
  
  xpath.list[[i]]   <- 
    get_table_xpaths( url, 
                      table.name, 
                      table.headers=table.headers )
  
  if( i %% 100 == 0 ){ print(i) }
  
}


end.build.time <- Sys.time()      # --------------------


df <- dplyr::bind_rows( results.list )


fail.log <- readLines( "FAIL-LOG.txt" )
all.xpaths <- xpath.list %>% unlist() %>% unique() %>% sort()
cat( all.xpaths, sep="\n", file="XPATH-LOG.txt" )

TABLE: SG-P02-T01-FUNDRAISING-EVENTS

## [1] "NUMBER OF RETURNS PROCESSED:   1000"
## [1] "TOTAL NUMBER OF TABLE ROWS:   868"

TOTAL RUN TIME:

## Time difference of 17.7166 mins
## Time difference of -0.2952767 hours

Write to File

write.csv( df, paste0( folder.name, "/", table.name, ".csv" ), row.names=F )
head(df) 

Are all names standardized?

names(df)
##  [1] "OBJECT_ID"                        "EIN"                             
##  [3] "NAME"                             "TAXYR"                           
##  [5] "FORMTYPE"                         "URL"                             
##  [7] "SG_02_FUNDR_EVNT_1_NAME"          "SG_02_FUNDR_EVNT_REV_GRORCPT_1"  
##  [9] "SG_02_FUNDR_EVNT_REV_GRO_1"       "GrossReceiptsTotalAmt"           
## [11] "GrossRevenueTotalEventsAmt"       "NetIncomeSummaryAmt"             
## [13] "SG_02_FUNDR_EVNT_2_NAME"          "SG_02_FUNDR_EVNT_REV_GRORCPT_2"  
## [15] "SG_02_FUNDR_EVNT_REV_GRO_2"       "SG_02_FUNDR_EVNT_REV_CONTR_1"    
## [17] "SG_02_FUNDR_EVNT_EXP_OTH_1"       "SG_02_FUNDR_EVNT_REV_CONTR_2"    
## [19] "SG_02_FUNDR_EVNT_EXP_OTH_2"       "SG_02_FUNDR_EVNT_OTH_TOT_NUM"    
## [21] "SG_02_FUNDR_EVNT_REV_GRORCPT_OTH" "SG_02_FUNDR_EVNT_REV_CONTR_OTH"  
## [23] "SG_02_FUNDR_EVNT_REV_GRO_OTH"     "SG_02_FUNDR_EVNT_EXP_OTH_OTH"    
## [25] "CharitableContributionsTotAmt"    "OthDirectExpnssTotalEventsAmt"   
## [27] "DirectExpenseSummaryEventsAmt"    "SG_02_FUNDR_EVNT_EXP_FOOD_1"     
## [29] "SG_02_FUNDR_EVNT_EXP_ENTMT_1"     "SG_02_FUNDR_EVNT_EXP_FOOD_2"     
## [31] "SG_02_FUNDR_EVNT_EXP_FOOD_OTH"    "FoodAndBeverageTotalEventsAmt"   
## [33] "EntertainmentTotalEventsAmt"      "SG_02_FUNDR_EVNT_EXP_RENT_1"     
## [35] "RentFcltyCostsTotalEventsAmt"     "SG_02_FUNDR_EVNT_EXP_ENTMT_2"    
## [37] "SG_02_FUNDR_EVNT_EXP_ENTMT_OTH"   "SG_02_FUNDR_EVNT_EXP_RENT_2"     
## [39] "SG_02_FUNDR_EVNT_EXP_NONCSH_OTH"  "SG_02_FUNDR_EVNT_EXP_RENT_OTH"   
## [41] "NonCashPrizesTotalEventsAmt"      "CashPrizesTotalEventsAmt"        
## [43] "SG_02_FUNDR_EVNT_EXP_NONCSH_1"    "SG_02_FUNDR_EVNT_EXP_NONCSH_2"   
## [45] "SG_02_FUNDR_EVNT_EXP_CASH_1"      "SG_02_FUNDR_EVNT_EXP_CASH_2"     
## [47] "SG_02_FUNDR_EVNT_EXP_CASH_OTH"








Diagnostics

Missing or Extra XPATHS

Check for xpaths that were used in the tables but do not exist in the Concordance file.

c.table <- dplyr::filter( concordance, rdb_table == table.name ) 
xpath.concordance <- c.table$xpath
setdiff( all.xpaths, xpath.concordance )
##  [1] ""                                                                                               
##  [2] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesTotalEventsAmt"     
##  [3] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContributionsTotAmt"
##  [4] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/DirectExpenseSummaryEventsAmt"
##  [5] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentTotalEventsAmt"  
##  [6] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageTotalEventsAmt"
##  [7] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsTotalAmt"        
##  [8] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueTotalEventsAmt"   
##  [9] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NetIncomeSummaryAmt"          
## [10] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesTotalEventsAmt"  
## [11] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OthDirectExpnssTotalEventsAmt"
## [12] "/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFcltyCostsTotalEventsAmt"

Capture to update the Concordance file.

these <- setdiff( all.xpaths, xpath.concordance )
cat( these, sep="\n", file=paste0( folder.name, "/MISSING-XPATHS.txt" ) )

Failes URLs

Check the status of failed URLs.

if( length(fail.log) > 0 )
{ 
  sapply( fail.log, get_message ) %>% 
  table() %>% 
  pander() 
} else {
  print("ALL URLs ARE VALID")
}
## [1] "ALL URLs ARE VALID"








XML Table Structure

Create Network Edgelists

The create_edgelist() functions v1 and v2 are in R/utils.R.

V1 retains the root nodes Return and ReturnData.

V2 drops the root nodes and uses form versions “990” and “990EZ” as the root to visualize the sets of tables separately.

# KEEP ROOT NOTES Return & ReturnData
el <- create_edgelist_v1( all.xpaths )



Edgelist format:

V1 V2
Return ReturnData
ReturnData IRS990
IRS990 Form990PartVIISectionAGrp
Form990PartVIISectionAGrp PersonNm
Form990PartVIISectionAGrp TitleTxt
Form990PartVIISectionAGrp AverageHoursPerWeekRt
Form990PartVIISectionAGrp IndividualTrusteeOrDirectorInd
Form990PartVIISectionAGrp OfficerInd
Form990PartVIISectionAGrp ReportableCompFromOrgAmt
Form990PartVIISectionAGrp ReportableCompFromRltdOrgAmt








Visualize Tree Structure

# library( data.tree )
nd <- FromDataFrameNetwork( network=el )
print( nd )
##                                         levelName
## 1  Return                                        
## 2   °--ReturnData                                
## 3       °--IRS990ScheduleG                       
## 4           °--FundraisingEventInformationGrp    
## 5               ¦--CashPrizesEvent1Amt           
## 6               ¦--CashPrizesEvent2Amt           
## 7               ¦--CashPrizesOtherEventsAmt      
## 8               ¦--CashPrizesTotalEventsAmt      
## 9               ¦--CharitableContributionsTotAmt 
## 10              ¦--CharitableContriEvent1Amt     
## 11              ¦--CharitableContriEvent2Amt     
## 12              ¦--CharitableContriOtherEventsAmt
## 13              ¦--DirectExpenseSummaryEventsAmt 
## 14              ¦--EntertainmentEvent1Amt        
## 15              ¦--EntertainmentEvent2Amt        
## 16              ¦--EntertainmentOtherEventsAmt   
## 17              ¦--EntertainmentTotalEventsAmt   
## 18              ¦--Event1Nm                      
## 19              ¦--Event2Nm                      
## 20              ¦--FoodAndBeverageEvent1Amt      
## 21              ¦--FoodAndBeverageEvent2Amt      
## 22              ¦--FoodAndBeverageOtherEventsAmt 
## 23              ¦--FoodAndBeverageTotalEventsAmt 
## 24              ¦--GrossReceiptsEvent1Amt        
## 25              ¦--GrossReceiptsEvent2Amt        
## 26              ¦--GrossReceiptsOtherEventsAmt   
## 27              ¦--GrossReceiptsTotalAmt         
## 28              ¦--GrossRevenueEvent1Amt         
## 29              ¦--GrossRevenueEvent2Amt         
## 30              ¦--GrossRevenueOtherEventsAmt    
## 31              ¦--GrossRevenueTotalEventsAmt    
## 32              ¦--NetIncomeSummaryAmt           
## 33              ¦--NonCashPrizesEvent1Amt        
## 34              ¦--NonCashPrizesEvent2Amt        
## 35              ¦--NonCashPrizesOtherEventsAmt   
## 36              ¦--NonCashPrizesTotalEventsAmt   
## 37              ¦--OthDirectExpnssOtherEventsAmt 
## 38              ¦--OthDirectExpnssTotalEventsAmt 
## 39              ¦--OtherDirectExpensesEvent1Amt  
## 40              ¦--OtherDirectExpensesEvent2Amt  
## 41              ¦--OtherEventsTotalCnt           
## 42              ¦--RentFacilityCostsEvent1Amt    
## 43              ¦--RentFacilityCostsEvent2Amt    
## 44              ¦--RentFcltyCostsOtherEventsAmt  
## 45              °--RentFcltyCostsTotalEventsAmt
SetGraphStyle( nd, rankdir = "LR")
SetEdgeStyle( nd, arrowhead = "vee", color = "grey20", penwidth = 2 )
SetNodeStyle( nd, 
              style = "filled,rounded", 
              shape = "box", 
              fillcolor = "LightBlue", 
              fontname = "helvetica", 
              fontcolor="black",
              tooltip = GetDefaultTooltip )

# SetNodeStyle(acme$IT, fillcolor = "LightBlue", penwidth = "5px")
plot( nd )
# library( networkD3 )
# net <- ToDataFrameNetwork( nd, "name" )
# simpleNetwork( net, fontSize = 12 )
simpleNetwork( el, fontSize = 12 )
#plot with networkD3
radnet <- ToListExplicit( nd, unname = TRUE )
radialNetwork( radnet, fontSize = 12 )








XPATH Summary

Unique Xpaths for this RDB Table

t.xpaths <- 
  concordance %>%
  filter( rdb_table == table.name ) %>% 
  select( xpath ) %>% 
  unique() %>% 
  arrange( xpath ) %>% 
  mutate( id=row_number() ) 

t.xpaths %>% 
  kable( align="l" )
xpath id
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesEvent1 1
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesEvent2 2
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CashPrizesOtherEvents 3
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContribOtherEvents 4
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContributionsEvent1 5
/Return/ReturnData/IRS990ScheduleG/EventsInformation/CharitableContributionsEvent2 6
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentEvent1 7
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentEvent2 8
/Return/ReturnData/IRS990ScheduleG/EventsInformation/EntertainmentOtherEvents 9
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageEvent1 10
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageEvent2 11
/Return/ReturnData/IRS990ScheduleG/EventsInformation/FoodAndBeverageOtherEvents 12
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsEvent1 13
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsEvent2 14
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossReceiptsOtherEvents 15
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueEvent1 16
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueEvent2 17
/Return/ReturnData/IRS990ScheduleG/EventsInformation/GrossRevenueOtherEvents 18
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NameOfEvent1 19
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NameOfEvent2 20
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesEvent1 21
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesEvent2 22
/Return/ReturnData/IRS990ScheduleG/EventsInformation/NonCashPrizesOtherEvents 23
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesEvent1 24
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesEvent2 25
/Return/ReturnData/IRS990ScheduleG/EventsInformation/OtherDirectExpensesOtherEvents 26
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsEvent1 27
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsEvent2 28
/Return/ReturnData/IRS990ScheduleG/EventsInformation/RentFacilityCostsOtherEvents 29
/Return/ReturnData/IRS990ScheduleG/EventsInformation/TotalNumberOfOtherEvents 30
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesEvent1 31
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesEvent2 32
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CashPrizesOtherEvents 33
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContribOtherEvents 34
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContributionsEvent1 35
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/CharitableContributionsEvent2 36
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsEvent1 37
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsEvent2 38
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossReceiptsOtherEvents 39
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueEvent1 40
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueEvent2 41
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/GrossRevenueOtherEvents 42
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NameOfEvent1 43
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NameOfEvent2 44
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesEvent1 45
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesEvent2 46
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/NonCashPrizesOtherEvents 47
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesEvent1 48
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesEvent2 49
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/OtherDirectExpensesOtherEvents 50
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsEvent1 51
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsEvent2 52
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/RentFacilityCostsOtherEvents 53
/Return/ReturnData/IRS990ScheduleG/Form990ScheduleGPartII/EventsInformation/TotalNumberOfOtherEvents 54
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesEvent1Amt 55
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesEvent2Amt 56
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CashPrizesOtherEventsAmt 57
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriEvent1Amt 58
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriEvent2Amt 59
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/CharitableContriOtherEventsAmt 60
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentEvent1Amt 61
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentEvent2Amt 62
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/EntertainmentOtherEventsAmt 63
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/Event1Nm 64
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/Event2Nm 65
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageEvent1Amt 66
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageEvent2Amt 67
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/FoodAndBeverageOtherEventsAmt 68
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsEvent1Amt 69
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsEvent2Amt 70
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossReceiptsOtherEventsAmt 71
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueEvent1Amt 72
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueEvent2Amt 73
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/GrossRevenueOtherEventsAmt 74
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NameOfEvent1Amt 75
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NameOfEvent2Amt 76
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesEvent1Amt 77
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesEvent2Amt 78
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/NonCashPrizesOtherEventsAmt 79
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OthDirectExpnssOtherEventsAmt 80
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherDirectExpensesEvent1Amt 81
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherDirectExpensesEvent2Amt 82
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/OtherEventsTotalCnt 83
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFacilityCostsEvent1Amt 84
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFacilityCostsEvent2Amt 85
/Return/ReturnData/IRS990ScheduleG/FundraisingEventInformationGrp/RentFcltyCostsOtherEventsAmt 86

Grouping Variables

Identify all unique groups used in xpaths.

if( is.null(table.headers) )
{ find_table_headers( table.name ) } else
table.headers
##  [1] "//Form990ScheduleGPartII/NameOfEvent1"                          
##  [2] "//Form990ScheduleGPartII/NameOfEvent2"                          
##  [3] "//Form990ScheduleGPartII/TotalNumberOfOtherEvents"              
##  [4] "//Form990ScheduleGPartII/GrossReceiptsEvent1"                   
##  [5] "//Form990ScheduleGPartII/GrossReceiptsEvent2"                   
##  [6] "//Form990ScheduleGPartII/GrossReceiptsOtherEvents"              
##  [7] "//Form990ScheduleGPartII/GrossReceiptsTotal"                    
##  [8] "//Form990ScheduleGPartII/CharitableContributionsEvent1"         
##  [9] "//Form990ScheduleGPartII/CharitableContributionsEvent2"         
## [10] "//Form990ScheduleGPartII/CharitableContribOtherEvents"          
## [11] "//Form990ScheduleGPartII/CharitableContributionsTotal"          
## [12] "//Form990ScheduleGPartII/GrossRevenueEvent1"                    
## [13] "//Form990ScheduleGPartII/GrossRevenueEvent2"                    
## [14] "//Form990ScheduleGPartII/GrossRevenueOtherEvents"               
## [15] "//Form990ScheduleGPartII/GrossRevenueTotalEvents"               
## [16] "//Form990ScheduleGPartII/CashPrizesEvent1"                      
## [17] "//Form990ScheduleGPartII/CashPrizesEvent2"                      
## [18] "//Form990ScheduleGPartII/CashPrizesOtherEvents"                 
## [19] "//Form990ScheduleGPartII/CashPrizesTotalEvents"                 
## [20] "//Form990ScheduleGPartII/NonCashPrizesEvent1"                   
## [21] "//Form990ScheduleGPartII/NonCashPrizesEvent2"                   
## [22] "//Form990ScheduleGPartII/NonCashPrizesOtherEvents"              
## [23] "//Form990ScheduleGPartII/NonCashPrizesTotalEvents"              
## [24] "//Form990ScheduleGPartII/RentFacilityCostsEvent1"               
## [25] "//Form990ScheduleGPartII/RentFacilityCostsEvent2"               
## [26] "//Form990ScheduleGPartII/RentFacilityCostsOtherEvents"          
## [27] "//Form990ScheduleGPartII/RentFacilityCostsTotalEvents"          
## [28] "//Form990ScheduleGPartII/OtherDirectExpensesEvent1"             
## [29] "//Form990ScheduleGPartII/OtherDirectExpensesEvent2"             
## [30] "//Form990ScheduleGPartII/OtherDirectExpensesOtherEvents"        
## [31] "//Form990ScheduleGPartII/OtherDirectExpensesTotalEvents"        
## [32] "//Form990ScheduleGPartII/DirectExpenseSummaryEvents"            
## [33] "//Form990ScheduleGPartII/NetIncomeSummary"                      
## [34] "//EventsInformation/Form990ScheduleGPartII"                     
## [35] "//EventsInformation/EventsInformation"                          
## [36] "//FundraisingEventInformationGrp/Event1Nm"                      
## [37] "//FundraisingEventInformationGrp/NameOfEvent1Amt"               
## [38] "//FundraisingEventInformationGrp/Event2Nm"                      
## [39] "//FundraisingEventInformationGrp/NameOfEvent2Amt"               
## [40] "//FundraisingEventInformationGrp/OtherEventsTotalCnt"           
## [41] "//FundraisingEventInformationGrp/GrossReceiptsEvent1Amt"        
## [42] "//FundraisingEventInformationGrp/GrossReceiptsEvent2Amt"        
## [43] "//FundraisingEventInformationGrp/GrossReceiptsOtherEventsAmt"   
## [44] "//FundraisingEventInformationGrp/GrossReceiptsTotalAmt"         
## [45] "//FundraisingEventInformationGrp/CharitableContriEvent1Amt"     
## [46] "//FundraisingEventInformationGrp/CharitableContriEvent2Amt"     
## [47] "//FundraisingEventInformationGrp/CharitableContriOtherEventsAmt"
## [48] "//FundraisingEventInformationGrp/CharitableContributionsTotAmt" 
## [49] "//FundraisingEventInformationGrp/GrossRevenueEvent1Amt"         
## [50] "//FundraisingEventInformationGrp/GrossRevenueEvent2Amt"         
## [51] "//FundraisingEventInformationGrp/GrossRevenueOtherEventsAmt"    
## [52] "//FundraisingEventInformationGrp/GrossRevenueTotalEventsAmt"    
## [53] "//FundraisingEventInformationGrp/CashPrizesEvent1Amt"           
## [54] "//FundraisingEventInformationGrp/CashPrizesEvent2Amt"           
## [55] "//FundraisingEventInformationGrp/CashPrizesOtherEventsAmt"      
## [56] "//FundraisingEventInformationGrp/CashPrizesTotalEventsAmt"      
## [57] "//FundraisingEventInformationGrp/NonCashPrizesEvent1Amt"        
## [58] "//FundraisingEventInformationGrp/NonCashPrizesEvent2Amt"        
## [59] "//FundraisingEventInformationGrp/NonCashPrizesOtherEventsAmt"   
## [60] "//FundraisingEventInformationGrp/NonCashPrizesTotalEventsAmt"   
## [61] "//FundraisingEventInformationGrp/RentFacilityCostsEvent1Amt"    
## [62] "//FundraisingEventInformationGrp/RentFacilityCostsEvent2Amt"    
## [63] "//FundraisingEventInformationGrp/RentFcltyCostsOtherEventsAmt"  
## [64] "//FundraisingEventInformationGrp/RentFcltyCostsTotalEventsAmt"  
## [65] "//FundraisingEventInformationGrp/FoodAndBeverageEvent1Amt"      
## [66] "//FundraisingEventInformationGrp/FoodAndBeverageEvent2Amt"      
## [67] "//FundraisingEventInformationGrp/FoodAndBeverageOtherEventsAmt" 
## [68] "//FundraisingEventInformationGrp/FoodAndBeverageTotalEventsAmt" 
## [69] "//FundraisingEventInformationGrp/EntertainmentEvent1Amt"        
## [70] "//FundraisingEventInformationGrp/EntertainmentEvent2Amt"        
## [71] "//FundraisingEventInformationGrp/EntertainmentOtherEventsAmt"   
## [72] "//FundraisingEventInformationGrp/EntertainmentTotalEventsAmt"   
## [73] "//FundraisingEventInformationGrp/OtherDirectExpensesEvent1Amt"  
## [74] "//FundraisingEventInformationGrp/OtherDirectExpensesEvent2Amt"  
## [75] "//FundraisingEventInformationGrp/OthDirectExpnssOtherEventsAmt" 
## [76] "//FundraisingEventInformationGrp/OthDirectExpnssTotalEventsAmt" 
## [77] "//FundraisingEventInformationGrp/DirectExpenseSummaryEventsAmt" 
## [78] "//FundraisingEventInformationGrp/NetIncomeSummaryAmt"

Groups can then be used to extract the 1:M RDB tables:

if( is.null(table.headers) )
{ table.headers <- find_table_headers( table.name ) }
demo.url <- "https://nccs-efile.s3.us-east-1.amazonaws.com/xml/201913079349300206_public.xml"
doc <- xml2::read_xml( demo.url )
xml2::xml_ns_strip( doc )
df.demo <- get_table_v2( doc, table.name, table.headers )
df.demo 
## # A tibble: 1 × 13
##   Event1Nm Gross…¹ Gross…² Other…³ Event…⁴ Gross…⁵ Gross…⁶ Other…⁷ Gross…⁸
##   <chr>    <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
## 1 Greens … 14164   14164   10742   Tourna… 7024    7024    1871    21188  
## # … with 4 more variables: GrossRevenueTotalEventsAmt <chr>,
## #   OthDirectExpnssTotalEventsAmt <chr>,
## #   DirectExpenseSummaryEventsAmt <chr>, NetIncomeSummaryAmt <chr>, and
## #   abbreviated variable names ¹​GrossReceiptsEvent1Amt,
## #   ²​GrossRevenueEvent1Amt, ³​OtherDirectExpensesEvent1Amt, ⁴​Event2Nm,
## #   ⁵​GrossReceiptsEvent2Amt, ⁶​GrossRevenueEvent2Amt,
## #   ⁷​OtherDirectExpensesEvent2Amt, ⁸​GrossReceiptsTotalAmt

Standardize Variable Names

Mapping of xml variable names to concordance variable names:

get_var_map( table.name=table.name )

A table with proper names:

v.map <- get_var_map( table.name=table.name )

if( ! is.null(df.demo) )
{re_name( df.demo, v.map ) %>% as.data.frame()}
##   SG_02_FUNDR_EVNT_1_NAME SG_02_FUNDR_EVNT_REV_GRORCPT_1
## 1             Greens Sale                          14164
##   SG_02_FUNDR_EVNT_REV_GRO_1 SG_02_FUNDR_EVNT_EXP_OTH_1
## 1                      14164                      10742
##   SG_02_FUNDR_EVNT_2_NAME SG_02_FUNDR_EVNT_REV_GRORCPT_2
## 1              Tournament                           7024
##   SG_02_FUNDR_EVNT_REV_GRO_2 SG_02_FUNDR_EVNT_EXP_OTH_2
## 1                       7024                       1871
##   GrossReceiptsTotalAmt GrossRevenueTotalEventsAmt
## 1                 21188                      21188
##   OthDirectExpnssTotalEventsAmt DirectExpenseSummaryEventsAmt
## 1                         12613                         12613
##   NetIncomeSummaryAmt
## 1                8575