Skip to contents

Functions to retrieve information about agency sub-components, sub-agencies, and organizational structure.

Usage

agency_sub_agency(toptier_code, fiscal_year = NULL, .page_all = FALSE, ...)

agency_sub_agency_count(
  toptier_code,
  fiscal_year = NULL,
  .page_all = FALSE,
  ...
)

agency_sub_components(toptier_code, fiscal_year = NULL, ...)

agency_sub_components_accounts(
  toptier_code,
  bureau_slug,
  fiscal_year = NULL,
  ...
)

Arguments

toptier_code

A character string containing a 3-4 digit numeric code that uniquely identifies a top-tier federal agency (e.g., "086" for Department of Housing and Urban Development). Must be a valid CGAC (Common Government-wide Accounting Classification) or FREC (Federal Record Classification) code.

fiscal_year

Optional numeric value specifying the fiscal year for the query. If NULL (default), the API will use the current fiscal year. Must be 2017 or later.

.page_all

Logical indicating whether to retrieve all pages of results (TRUE) or just the first page (FALSE, default). When TRUE, the function will automatically handle pagination to retrieve the complete dataset.

...

Additional parameters passed to specific API endpoints. Common options include:

  • page: Integer specifying the page number to retrieve (default: 1)

  • limit: Integer specifying number of records per page (default: 10)

  • sort: Field to sort results by (varies by endpoint)

  • order: Sort direction: "asc" or "desc" (default varies by endpoint)

bureau_slug

A character string representing the URL-friendly identifier for a specific bureau (e.g., "bureau_of_the_census")

Value

Each function returns a tibble with different structures:

  • agency_sub_components() returns:

    • name: Sub-component name

    • id: Sub-component identifier (bureau_slug)

    • total_budgetary_resources: Total resources

    • total_obligations: Total obligations

    • total_outlays: Total outlays

  • agency_sub_components_accounts() returns:

    • name: Federal account name

    • id: Federal account number

    • total_budgetary_resources: Total resources

    • total_obligations: Total obligations

    • total_outlays: Total outlays

  • agency_sub_agency() returns:

    • name: Sub-agency name

    • abbreviation: Sub-agency abbreviation

    • total_obligations: Total obligations

    • transaction_count: Number of transactions

    • new_award_count: Number of new awards

    • children: Nested data frame of offices

  • agency_sub_agency_count() returns:

    • toptier_code: Agency identifier code

    • fiscal_year: Fiscal year

    • sub_agency_count: Number of sub-agencies

    • office_count: Number of offices

Examples

if (FALSE) { # interactive()
# Get sub-components for HUD
sub_comps <- agency_sub_components("086", fiscal_year = 2023)

# Get federal accounts for a specific bureau
bureau_accounts <- agency_sub_components_accounts(
  "086",
  bureau_slug = "federal_housing_administration",
  fiscal_year = 2023
)

# Get sub-agencies
sub_agencies <- agency_sub_agency("086", fiscal_year = 2023)

# Get sub-agency counts
agency_counts <- agency_sub_agency_count("086", fiscal_year = 2023)
}