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")
head( index )
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.
%>%
concordance filter( rdb_table == table.name )
xpath | id |
---|---|
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/AnyLeaseArrangements | 1 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/AnyResearchAgreements | 2 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/BondIssMeetPrvtSecurityPayTest | 3 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/BondReferenceCd | 4 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/ChangeInUseBondFinancedProp | 5 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/EngageBondCounselContracts | 6 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/EngageBondCounselResearch | 7 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/MngmentCntrctBondFinancdPrprty | 8 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/NonQualifiedBondRemedProcdrs | 9 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/OwningBondFinancedProperty | 10 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PercentageOfPrvtBusinessReUBI | 11 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PrcntgeBondFinancedProp | 12 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PrcntgePrvtBusinessUseByOthers | 13 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/RemedialActionTaken | 14 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/TotalOfLines4And5 | 15 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/TotalPrivateBusinessUse | 16 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/AnyLeaseArrangementsInd | 17 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/AnyResearchAgreementsInd | 18 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/BondIssMeetPrvtSecPymtTestInd | 19 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/BondReferenceCd | 20 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropInd | 21 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropPct | 22 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/EngageBondCounselContractsInd | 23 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/EngageBondCounselResearchInd | 24 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/MgmtContractBondFincdPropInd | 25 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/OwningBondFinancedPropertyInd | 26 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/PrivateBusConcerningUBIPct | 27 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/PrivateBusUseByOthersPct | 28 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ProcsNonqualifiedBondRemdtdInd | 29 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/RemedialActionTakenInd | 30 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/TotalPrivateBusinessUsePct | 31 |
<- as.character( t.xpaths$xpath )
xpaths <- create_edgelist_v1( xpaths )
el <- FromDataFrameNetwork( network=el )
nd print( nd )
## levelName
## 1 Return
## 2 °--ReturnData
## 3 °--IRS990ScheduleK
## 4 ¦--Form990ScheduleKPartIII
## 5 ¦ ¦--AnyLeaseArrangements
## 6 ¦ ¦--AnyResearchAgreements
## 7 ¦ ¦--BondIssMeetPrvtSecurityPayTest
## 8 ¦ ¦--BondReferenceCd
## 9 ¦ ¦--ChangeInUseBondFinancedProp
## 10 ¦ ¦--EngageBondCounselContracts
## 11 ¦ ¦--EngageBondCounselResearch
## 12 ¦ ¦--MngmentCntrctBondFinancdPrprty
## 13 ¦ ¦--NonQualifiedBondRemedProcdrs
## 14 ¦ ¦--OwningBondFinancedProperty
## 15 ¦ ¦--PercentageOfPrvtBusinessReUBI
## 16 ¦ ¦--PrcntgeBondFinancedProp
## 17 ¦ ¦--PrcntgePrvtBusinessUseByOthers
## 18 ¦ ¦--RemedialActionTaken
## 19 ¦ ¦--TotalOfLines4And5
## 20 ¦ °--TotalPrivateBusinessUse
## 21 °--TaxExemptBondsPrivateBusUseGrp
## 22 ¦--AnyLeaseArrangementsInd
## 23 ¦--AnyResearchAgreementsInd
## 24 ¦--BondIssMeetPrvtSecPymtTestInd
## 25 ¦--BondReferenceCd
## 26 ¦--ChangeInUseBondFinancedPropInd
## 27 ¦--ChangeInUseBondFinancedPropPct
## 28 ¦--EngageBondCounselContractsInd
## 29 ¦--EngageBondCounselResearchInd
## 30 ¦--MgmtContractBondFincdPropInd
## 31 ¦--OwningBondFinancedPropertyInd
## 32 ¦--PrivateBusConcerningUBIPct
## 33 ¦--PrivateBusUseByOthersPct
## 34 ¦--ProcsNonqualifiedBondRemdtdInd
## 35 ¦--RemedialActionTakenInd
## 36 °--TotalPrivateBusinessUsePct
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] "//Form990ScheduleKPartIII" "//TaxExemptBondsPrivateBusUseGrp"
# new version
find_table_headers( table.name )
## [1] "//Form990ScheduleKPartIII/BondReferenceCd"
## [2] "//Form990ScheduleKPartIII/OwningBondFinancedProperty"
## [3] "//Form990ScheduleKPartIII/AnyLeaseArrangements"
## [4] "//Form990ScheduleKPartIII/MngmentCntrctBondFinancdPrprty"
## [5] "//Form990ScheduleKPartIII/EngageBondCounselContracts"
## [6] "//Form990ScheduleKPartIII/AnyResearchAgreements"
## [7] "//Form990ScheduleKPartIII/EngageBondCounselResearch"
## [8] "//Form990ScheduleKPartIII/PrcntgePrvtBusinessUseByOthers"
## [9] "//Form990ScheduleKPartIII/PercentageOfPrvtBusinessReUBI"
## [10] "//Form990ScheduleKPartIII/TotalOfLines4And5"
## [11] "//Form990ScheduleKPartIII/TotalPrivateBusinessUse"
## [12] "//Form990ScheduleKPartIII/BondIssMeetPrvtSecurityPayTest"
## [13] "//Form990ScheduleKPartIII/ChangeInUseBondFinancedProp"
## [14] "//Form990ScheduleKPartIII/PrcntgeBondFinancedProp"
## [15] "//Form990ScheduleKPartIII/RemedialActionTaken"
## [16] "//Form990ScheduleKPartIII/NonQualifiedBondRemedProcdrs"
## [17] "//Form990ScheduleKPartIII/BondCounselRoutinelyEngaged"
## [18] "//Form990ScheduleKPartIII/PostIssuanceComplianceProcdrs"
## [19] "//TaxExemptBondsPrivateBusUseGrp/BondReferenceCd"
## [20] "//TaxExemptBondsPrivateBusUseGrp/OwningBondFinancedPropertyInd"
## [21] "//TaxExemptBondsPrivateBusUseGrp/AnyLeaseArrangementsInd"
## [22] "//TaxExemptBondsPrivateBusUseGrp/MgmtContractBondFincdPropInd"
## [23] "//TaxExemptBondsPrivateBusUseGrp/EngageBondCounselContractsInd"
## [24] "//TaxExemptBondsPrivateBusUseGrp/AnyResearchAgreementsInd"
## [25] "//TaxExemptBondsPrivateBusUseGrp/EngageBondCounselResearchInd"
## [26] "//TaxExemptBondsPrivateBusUseGrp/PrivateBusUseByOthersPct"
## [27] "//TaxExemptBondsPrivateBusUseGrp/PrivateBusConcerningUBIPct"
## [28] "//TaxExemptBondsPrivateBusUseGrp/TotalPrivateBusinessUsePct"
## [29] "//TaxExemptBondsPrivateBusUseGrp/BondIssMeetPrvtSecPymtTestInd"
## [30] "//TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropInd"
## [31] "//TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropPct"
## [32] "//TaxExemptBondsPrivateBusUseGrp/RemedialActionTakenInd"
## [33] "//TaxExemptBondsPrivateBusUseGrp/ProcsNonqualifiedBondRemdtdInd"
# manual
if( ! is.null(table.headers) )
{table.headers}
# create new folder
dir.create( folder.name )
setwd( folder.name )
# create sample
set.seed( 1234 )
<- sample_n( index, sample.size )
sample.index write.csv( index, "sample-index.csv", row.names=F )
<- sample.index$URL
sample.urls
# erase existing log files
file.create("XPATH-LOG.txt")
file.create("FAIL-LOG.txt")
<- Sys.time() # --------------------
start.build.time
<- list()
results.list <- list()
xpath.list
for( i in 1:length( sample.urls ) )
{
<- sample.urls[i]
url
<-
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) }
}
<- Sys.time() # --------------------
end.build.time
<- dplyr::bind_rows( results.list )
df
<- readLines( "FAIL-LOG.txt" )
fail.log <- xpath.list %>% unlist() %>% unique() %>% sort()
all.xpaths cat( all.xpaths, sep="\n", file="XPATH-LOG.txt" )
TABLE: SK-P03-T01-BOND-PRIVATE-BIZ-USE
## [1] "NUMBER OF RETURNS PROCESSED: 1000"
## [1] "TOTAL NUMBER OF TABLE ROWS: 1930"
TOTAL RUN TIME:
## Time difference of 31.5952 mins
## Time difference of -0.5265866 hours
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] "SK_03_BOND_ISSUE_REFERENCE_NUM" "SK_03_BOND_BIZUSE_PTR_OWN_X"
## [9] "SK_03_BOND_BIZUSE_LEASEARRANGE_X" "SK_03_BOND_BIZUSE_MGMT_KONTR_X"
## [11] "SK_03_BOND_BIZUSE_PCT_BY_OTH" "SK_03_BOND_BIZUSE_PRIVATE_SEC_X"
## [13] "SK_03_BOND_BIZUSE_CHANGE_X" "SK_03_BOND_BIZUSE_REMEDIAL_ACT_X"
## [15] "SK_03_BOND_BIZUSE_REMEDIATED_X" "SK_03_BOND_BIZUSE_COUNS_KONTR_X"
## [17] "SK_03_BOND_BIZUSE_RSRCH_AGREE_X" "SK_03_BOND_BIZUSE_COUNS_RSRCH_X"
## [19] "SK_03_BOND_BIZUSE_PCT_UBIZ" "SK_03_BOND_BIZUSE_PCT_TOT_L45"
## [21] "SK_03_BOND_BIZUSE_CHANGE_PCT"
Check for xpaths that were used in the tables but do not exist in the Concordance file.
<- dplyr::filter( concordance, rdb_table == table.name )
c.table <- c.table$xpath
xpath.concordance setdiff( all.xpaths, xpath.concordance )
## [1] ""
Capture to update the Concordance file.
<- setdiff( all.xpaths, xpath.concordance )
these cat( these, sep="\n", file=paste0( folder.name, "/MISSING-XPATHS.txt" ) )
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"
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
<- create_edgelist_v1( all.xpaths ) el
Edgelist format:
V1 | V2 |
---|---|
Return | ReturnData |
ReturnData | IRS990 |
IRS990 | Form990PartVIISectionAGrp |
Form990PartVIISectionAGrp | PersonNm |
Form990PartVIISectionAGrp | TitleTxt |
Form990PartVIISectionAGrp | AverageHoursPerWeekRt |
Form990PartVIISectionAGrp | IndividualTrusteeOrDirectorInd |
Form990PartVIISectionAGrp | OfficerInd |
Form990PartVIISectionAGrp | ReportableCompFromOrgAmt |
Form990PartVIISectionAGrp | ReportableCompFromRltdOrgAmt |
# library( data.tree )
<- FromDataFrameNetwork( network=el )
nd print( nd )
## levelName
## 1 Return
## 2 °--ReturnData
## 3 °--IRS990ScheduleK
## 4 °--TaxExemptBondsPrivateBusUseGrp
## 5 ¦--AnyLeaseArrangementsInd
## 6 ¦--AnyResearchAgreementsInd
## 7 ¦--BondIssMeetPrvtSecPymtTestInd
## 8 ¦--BondReferenceCd
## 9 ¦--ChangeInUseBondFinancedPropInd
## 10 ¦--ChangeInUseBondFinancedPropPct
## 11 ¦--EngageBondCounselContractsInd
## 12 ¦--EngageBondCounselResearchInd
## 13 ¦--MgmtContractBondFincdPropInd
## 14 ¦--OwningBondFinancedPropertyInd
## 15 ¦--PrivateBusConcerningUBIPct
## 16 ¦--PrivateBusUseByOthersPct
## 17 ¦--ProcsNonqualifiedBondRemdtdInd
## 18 ¦--RemedialActionTakenInd
## 19 °--TotalPrivateBusinessUsePct
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
<- ToListExplicit( nd, unname = TRUE )
radnet radialNetwork( radnet, fontSize = 12 )
<-
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/IRS990ScheduleK/Form990ScheduleKPartIII/AnyLeaseArrangements | 1 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/AnyResearchAgreements | 2 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/BondIssMeetPrvtSecurityPayTest | 3 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/BondReferenceCd | 4 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/ChangeInUseBondFinancedProp | 5 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/EngageBondCounselContracts | 6 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/EngageBondCounselResearch | 7 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/MngmentCntrctBondFinancdPrprty | 8 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/NonQualifiedBondRemedProcdrs | 9 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/OwningBondFinancedProperty | 10 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PercentageOfPrvtBusinessReUBI | 11 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PrcntgeBondFinancedProp | 12 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/PrcntgePrvtBusinessUseByOthers | 13 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/RemedialActionTaken | 14 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/TotalOfLines4And5 | 15 |
/Return/ReturnData/IRS990ScheduleK/Form990ScheduleKPartIII/TotalPrivateBusinessUse | 16 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/AnyLeaseArrangementsInd | 17 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/AnyResearchAgreementsInd | 18 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/BondIssMeetPrvtSecPymtTestInd | 19 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/BondReferenceCd | 20 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropInd | 21 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropPct | 22 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/EngageBondCounselContractsInd | 23 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/EngageBondCounselResearchInd | 24 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/MgmtContractBondFincdPropInd | 25 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/OwningBondFinancedPropertyInd | 26 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/PrivateBusConcerningUBIPct | 27 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/PrivateBusUseByOthersPct | 28 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/ProcsNonqualifiedBondRemdtdInd | 29 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/RemedialActionTakenInd | 30 |
/Return/ReturnData/IRS990ScheduleK/TaxExemptBondsPrivateBusUseGrp/TotalPrivateBusinessUsePct | 31 |
Identify all unique groups used in xpaths.
if( is.null(table.headers) )
find_table_headers( table.name ) } else
{ table.headers
## [1] "//Form990ScheduleKPartIII/BondReferenceCd"
## [2] "//Form990ScheduleKPartIII/OwningBondFinancedProperty"
## [3] "//Form990ScheduleKPartIII/AnyLeaseArrangements"
## [4] "//Form990ScheduleKPartIII/MngmentCntrctBondFinancdPrprty"
## [5] "//Form990ScheduleKPartIII/EngageBondCounselContracts"
## [6] "//Form990ScheduleKPartIII/AnyResearchAgreements"
## [7] "//Form990ScheduleKPartIII/EngageBondCounselResearch"
## [8] "//Form990ScheduleKPartIII/PrcntgePrvtBusinessUseByOthers"
## [9] "//Form990ScheduleKPartIII/PercentageOfPrvtBusinessReUBI"
## [10] "//Form990ScheduleKPartIII/TotalOfLines4And5"
## [11] "//Form990ScheduleKPartIII/TotalPrivateBusinessUse"
## [12] "//Form990ScheduleKPartIII/BondIssMeetPrvtSecurityPayTest"
## [13] "//Form990ScheduleKPartIII/ChangeInUseBondFinancedProp"
## [14] "//Form990ScheduleKPartIII/PrcntgeBondFinancedProp"
## [15] "//Form990ScheduleKPartIII/RemedialActionTaken"
## [16] "//Form990ScheduleKPartIII/NonQualifiedBondRemedProcdrs"
## [17] "//Form990ScheduleKPartIII/BondCounselRoutinelyEngaged"
## [18] "//Form990ScheduleKPartIII/PostIssuanceComplianceProcdrs"
## [19] "//TaxExemptBondsPrivateBusUseGrp/BondReferenceCd"
## [20] "//TaxExemptBondsPrivateBusUseGrp/OwningBondFinancedPropertyInd"
## [21] "//TaxExemptBondsPrivateBusUseGrp/AnyLeaseArrangementsInd"
## [22] "//TaxExemptBondsPrivateBusUseGrp/MgmtContractBondFincdPropInd"
## [23] "//TaxExemptBondsPrivateBusUseGrp/EngageBondCounselContractsInd"
## [24] "//TaxExemptBondsPrivateBusUseGrp/AnyResearchAgreementsInd"
## [25] "//TaxExemptBondsPrivateBusUseGrp/EngageBondCounselResearchInd"
## [26] "//TaxExemptBondsPrivateBusUseGrp/PrivateBusUseByOthersPct"
## [27] "//TaxExemptBondsPrivateBusUseGrp/PrivateBusConcerningUBIPct"
## [28] "//TaxExemptBondsPrivateBusUseGrp/TotalPrivateBusinessUsePct"
## [29] "//TaxExemptBondsPrivateBusUseGrp/BondIssMeetPrvtSecPymtTestInd"
## [30] "//TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropInd"
## [31] "//TaxExemptBondsPrivateBusUseGrp/ChangeInUseBondFinancedPropPct"
## [32] "//TaxExemptBondsPrivateBusUseGrp/RemedialActionTakenInd"
## [33] "//TaxExemptBondsPrivateBusUseGrp/ProcsNonqualifiedBondRemdtdInd"
Groups can then be used to extract the 1:M RDB tables:
if( is.null(table.headers) )
<- find_table_headers( table.name ) }
{ table.headers <- "https://nccs-efile.s3.us-east-1.amazonaws.com/xml/201913079349300206_public.xml"
demo.url <- xml2::read_xml( demo.url )
doc ::xml_ns_strip( doc )
xml2<- get_table_v2( doc, table.name, table.headers )
df.demo df.demo
## NULL
Mapping of xml variable names to concordance variable names:
get_var_map( table.name=table.name )
A table with proper names:
<- get_var_map( table.name=table.name )
v.map
if( ! is.null(df.demo) )
re_name( df.demo, v.map ) %>% as.data.frame()} {
Demo of functions - demo data only.
[[1]]
<Form990PartVIISectionAGrp>
<PersonNm>
{text}
<TitleTxt>
{text}
<AverageHoursPerWeekRt>
{text}
<IndividualTrusteeOrDirectorInd>
{text}
<OfficerInd>
{text}
<ReportableCompFromOrgAmt>
{text}
<ReportableCompFromRltdOrgAmt>
{text}
<OtherCompensationAmt>
{text}
1]] %>% xml_parent() %>% xmltools::xml_view_trees() node.list[[
(1) ------------
+-- Form990PartVIISectionAGrp
+-- PersonNm
+-- TitleTxt
+-- AverageHoursPerWeekRt
+-- IndividualTrusteeOrDirectorInd
+-- OfficerInd
+-- ReportableCompFromOrgAmt
+-- ReportableCompFromRltdOrgAmt
++-- OtherCompensationAmt
(2) ------------
+-- Form990PartVIISectionAGrp
+-- PersonNm
+-- TitleTxt
+-- AverageHoursPerWeekRt
+-- IndividualTrusteeOrDirectorInd
+-- OfficerInd
+-- ReportableCompFromOrgAmt
+-- ReportableCompFromRltdOrgAmt
++-- OtherCompensationAmt