Generated from the R help files · v0.7.1
Function reference
Definitions, arguments and return values come from the same help files bundled with the package. Use ?read_natality in R to open its local help.
align_natality()Align Literal Source Codes by Annual Concept Identity
Align Literal Source Codes by Annual Concept Identity
Description
Provide consistently named access to exact annual source codes without changing their values. No numeric or categorical recode, trimming, missing-code conversion, population filter or reporting restriction is applied. A warning explicitly states that source alignment is not value harmonization.
Usage
align_natality(data, year, concepts, fields = NULL)
Arguments
data |
A single annual data frame with exact native character columns. Existing rows, columns, row order and input provenance are preserved. |
year |
One supported annual release year. Align separate years in separate calls. A supplied year column or package provenance must agree. |
concepts |
Unique exact identifiers from |
fields |
Optional named character vector mapping requested concept identifiers to exact annual native field names. Required when a concept has multiple annual variants, even if only one of those columns is present in the supplied data. |
Details
Character values, including leading zeros, spaces and NA, are copied literally.
Unknown and nonreporting source codes remain codes; aligned_source means
only that the declared source column was copied, not that it is an eligible or
clinically observed value. Numeric and factor source columns are rejected.
Missing annual concept fields produce NA with unavailable; they never
fall back to a related measure. If the concept exists but its selected column is
missing from the input, the function fails. Ambiguous variants require an explicit
fields choice. Existing output columns and previous alignment receipts are
not overwritten. Zero-row inputs follow the same preflight rules.
Inspect natality_crosswalk() and natality_transitions() before pooling
aligned source codes. standardize_natality() supplies a separate, bounded
set of explicit projections. Its defaults are unchanged. Alignment does not clear
clinical holds or independent scientific review.
Value
The original data frame plus four columns for each concept:
nat_<concept>_source_code, nat_<concept>_source_field,
nat_<concept>_rule_id, and nat_<concept>_alignment_status.
Statuses are aligned_source, input_missing for an input NA, or
unavailable when that concept has no registered field in that year.
The natality_alignment attribute records the software and catalog version,
exact annual selection, evidence, scope and review limitations.
See Also
natality_crosswalk, natality_transitions, standardize_natality
Examples
x <- data.frame(RF_GEST = c("Y", "N", "U", " ", NA_character_))
y <- suppressWarnings(align_natality(x, 2013, "gestational_diabetes"))
y$nat_gestational_diabetes_source_code
attr(y, "natality_alignment")$value_harmonization
natality_cache_dir()Manage the natality data cache
Manage the natality data cache
Description
Locates, inventories, and selectively clears package-managed annual data files. Downloads and local imports enter this cache only after size and SHA-256 verification. Locally validated private artifacts can be imported and read offline before public hosting is available.
Usage
natality_cache_dir(create = FALSE)
natality_cache_info()
natality_cache_import(year, path)
natality_cache_clear(years = NULL)
Arguments
year |
One supported data year. |
path |
Local release artifact matching the bundled size and SHA-256. The original is unchanged. |
create |
Create the cache directory when it does not exist. |
years |
Optional annual files to remove; omission selects all natality annual cache files. |
Value
The cache path, a cache inventory, or removed paths invisibly.
natality_changes()Inspect recorded annual changes for a variable
Inspect recorded annual changes for a variable
Description
Exposes documented annual differences without claiming that unchanged text establishes comparability.
Usage
natality_changes(variable, years = NULL)
## S3 method for class 'natality_changes'
print(x, ...)
Arguments
variable |
A source or local catalog variable name. |
years |
Optional years used to restrict comparisons and notes. |
x |
A natality change-history object. |
... |
Additional arguments reserved for print methods. |
Details
The comparisons table includes source_review_status and review_note for each annual boundary. These describe the source-document assessment; they do not approve automatic transformations or independent scientific validation. Native source identities remain distinct across renames.
Value
A change-history object with rule eras, adjacent-year comparisons, and notes.
natality_cite()Cite the source data and software separately
Cite the source data and software separately
Description
Generates separate source-data and software citations. Source data years are not asserted to be publication years. No DOI or CRAN release is implied.
Usage
natality_cite(years, format = c("text", "bibtex", "ris"))
Arguments
years |
One or more public source data years. |
format |
Plain text, BibTeX, or RIS. |
Value
Character vector with annual source citations and a software citation.
Examples
natality_cite(2024)
natality_codebook()Read annual source documentation for a variable
Read annual source documentation for a variable
Description
Returns source fields, locations, rules, review state, and manual links by year.
Usage
natality_codebook(variable, years = NULL)
## S3 method for class 'natality_codebook'
print(x, ...)
Arguments
variable |
A source or local catalog variable name. |
years |
Optional years to return. |
x |
A natality codebook object. |
... |
Additional arguments reserved for print methods. |
Details
The column observed_conversion_storage describes the inspected prior conversion, not the source-preserving package artifact. Printed width and position span remain separate so documentation discrepancies are visible. Package Parquet source fields are stored as character text.
The source_storage column describes the source-preserving package. The source_document_review column reports annual source issues separately from scientific comparability and independent review. Exact field/year issue scopes take precedence; otherwise an unscoped boundary question remains visible on both endpoints. The adjacent_comparison_review column reports unresolved boundary questions separately, without assigning an older manual's documented error to a corrected newer manual. Methodological notes identify the affected field, year and source.
The source_observations component reports recorded source-data discrepancies for the requested field and years. These observations do not assign undocumented code meanings or establish clinical comparability.
Publisher printed names and reviewed display descriptions are separate from v1 package column names and retained parser metadata. A documented presentation correction does not rename an immutable data artifact or transform its values.
Value
A codebook object containing annual source entries.
natality_concepts()Inspect Documented Natality Concept Families
Inspect Documented Natality Concept Families
Description
Inspect bundled, offline metadata connecting annual native fields by documented concept identity. Identity depends on both field name and year, so a reused name with a different role remains a separate concept. Related measures are discoverable without declaring equivalent values or national reporting coverage.
Usage
natality_concepts(concept = NULL)
Arguments
concept |
NULL lists all documented concept families. Otherwise supply one exact concept identifier returned in that list. |
Details
A family's harmonization_action is a summary. Only annual entries listing a
standardization_concepts identifier support its existing bounded projection;
other variants in that family need not support that transformation.
Gestational diabetes uses RF_GEST in 2004–2013 and RF_GDIAB in 2014–2024. Generic DIABETES and URF_DIAB cannot distinguish gestational from prepregnancy diabetes. DGESTAT is gestational age, not diabetes. These distinctions are preserved in the concept catalog. Original data are not changed by discovery. Independent scientific review remains pending.
Value
With NULL, a data frame containing concept, label, summary,
source_fields, years, and harmonization_action. With an
identifier, a list containing the family and annual evidence. The detailed
gestational_diabetes and prepregnancy_diabetes results retain
version 0.6.1's contract structure; other families expose annual_rules
from natality_crosswalk().
See Also
natality_crosswalk, natality_transitions,
align_natality, standardize_natality
Examples
head(natality_concepts())
natality_concepts("gestational_diabetes")$family$members
natality_crosswalk()Inspect Annual Native Fields and Source Evidence for a Concept
Inspect Annual Native Fields and Source Evidence for a Concept
Description
Inspect the annual source names, reporting dependencies and original definitions behind a concept without downloading record-level data. Multiple annual variants are retained separately. Unavailable years never receive a related or generic field as a substitute.
Usage
natality_crosswalk(concept, years = NULL)
Arguments
concept |
One exact identifier from |
years |
Optional unique supported annual years. NULL includes all supported years. |
Details
Rule IDs identify the recorded source rule and are not a clinical comparability
certificate. Reporting dependencies describe source evidence; this function does
not apply them or assert that they are a complete eligibility rule. For example,
the 2011 BMI reference to the mother's height flag does not cover its weight
input; it is exposed as an unresolved partial reference, not a complete BMI flag.
Annual reporting areas, population eligibility and source issues
must be reviewed before analysis. See the full source blocks in
attr(result, "source_codebook") and annual dependency evidence in
attr(result, "records").
Value
A data frame with one row per annual native variant, or one unavailable row when
no native field exists in a requested year. Columns include exact source names,
reporting dependencies, existing annual standardization identifiers, rule IDs,
positions, widths, guide URLs and PDF pages. source_review_status,
unresolved_reporting_references (a count), and
reporting_reference_notes make unresolved annual references visible in the
table. These columns are NA for unavailable years. The records attribute retains
the complete selected annual metadata; source_codebook retains the exact
source blocks and evidence. complete = TRUE means all registered variants
for the requested years are included, not that scientific validation is complete.
See Also
natality_concepts, natality_transitions, align_natality
Examples
natality_crosswalk("gestational_diabetes", years = c(2000, 2013, 2014))
natality_scientific_review()Inspect evidence and decisions for reviewed scientific questions
Inspect evidence and decisions for reviewed scientific questions
Description
Inspect the internal five-reviewer assessment of selected unresolved source comparisons and reporting references. Consensus is recorded separately from source-question resolution and transformation permission.
Usage
natality_scientific_review(variable = NULL, years = NULL)
Arguments
variable |
Optional native source field name, matched case-insensitively. |
years |
Optional years. Comparisons touching any selected year are included; the returned years retain the complete decision scope. |
Details
This function supplies analysis guidance. It does not transform data, authorize a new recode, certify all variables or replace external independent scientific review. A vote to retain original codes leaves the source question unresolved. An empty result means no entry in this scoped assessment, not that the field has been validated.
Value
A data frame with one row per annual issue. The records and
sources attributes retain full decisions and evidence.
Examples
natality_scientific_review("APGAR10", years = 2013)
natality_scientific_review("BMI_R", years = 2011:2014)
natality_sources()Discover public natality source years
Discover public natality source years
Description
Lists original CDC archives, annual guides, and package readiness separately. A listed source is not necessarily supported by read_natality.
Usage
natality_sources(years = NULL)
Arguments
years |
Optional unique data years. |
Value
A data frame of annual source metadata.
Examples
natality_sources(c(1968, 2024))
natality_transitions()Inspect Chronological Annual Source Comparisons
Inspect Chronological Annual Source Comparisons
Description
Inspect every recorded adjacent-year comparison, including unchanged definitions, layout changes, meaningful code changes, unresolved source discrepancies and same-name reuse as a different concept. This is a source-document ledger; comparison classification is separate from independent scientific review.
Usage
natality_transitions(concept = NULL, years = NULL)
Arguments
concept |
Optional exact concept identifier. NULL includes all concepts. |
years |
Optional supported years selecting the newer endpoint of each adjacent-year comparison. For example, 2014 selects 2013 to 2014. NULL includes all boundaries; 2000 alone returns an empty data frame because there is no registered 1999 comparison. |
Details
Filtering by concept retains comparisons involving that concept on either side
of a boundary. Added or removed names can therefore have one missing side.
automatic_recode_allowed is always FALSE: discovery does not authorize
new value transformations.
Value
A chronological data frame containing annual names, concept identities,
classification, review status, notes and exact source references. The
records attribute contains complete comparison records, including changed
source-rule text when supplied. The boundaries attribute describes the
selected annual boundaries. Empty results preserve the same column types.
See Also
natality_crosswalk, natality_changes
Examples
natality_transitions("plurality", years = 2020)
natality_vars()Search annual U.S. natality source variables
Search annual U.S. natality source variables
Description
Searches the bundled 2000–2024 annual source-variable catalog.
Usage
natality_vars(pattern = NULL, years = NULL)
Arguments
pattern |
Optional regular expression matched against source names, descriptions, and annual rule text. |
years |
Optional years used to restrict availability. |
Details
Searches the canonical U.S.-file layouts, excluding territory-only addenda. Spelling changes remain separate source names. No scientific equivalence is inferred from similar names or labels.
Value
A data frame with one row per matching canonical source name.
natality_years()List supported natality metadata years
List supported natality metadata years
Description
Lists years represented in the bundled annual variable catalog.
Usage
natality_years(details = FALSE)
Arguments
details |
Return annual metadata and package-data status when true. |
Details
Native source fields, prior imported-header counts and total artifact columns are distinct. Historical source-preserving artifacts include one auxiliary original-record column. Column availability does not establish clinical comparability or reporting completeness.
Value
An integer vector, or a data frame when details = TRUE.
read_natality()Read selected natality source variables
Read selected natality source variables
Description
Reads only requested source variables and applies an explicit residence-universe choice.
Usage
read_natality(
year,
vars,
path = NULL,
population = c("all_occurrence", "us_residents"),
download = TRUE
)
Arguments
year |
One or more supported data years. |
vars |
Source or local catalog variable names. |
path |
Optional local annual Stata, RDS, or Parquet file. For multiple years, a character vector named by every requested year. |
population |
All occurrence records or births to U.S. residents. |
download |
Allow a package-hosted download when a validated, published annual release exists. Cached files remain available when false. |
Details
When path is omitted, a verified cache entry is used. Private locally validated releases can first be imported with natality_cache_import(). Downloading requires a published release with an HTTPS URL. Multiple-year reads warn that comparability is not established, retain annual provenance, and refuse differing source names, types or labels. Fields must be present in every requested year; missing fields are not silently filled.
Recorded source-value discrepancies trigger a warning when their unlisted codes appear in a requested field. Values remain unchanged and the result's provenance records the issue. Published downloads may use manifest-listed HTTPS mirrors, each verified against the same pinned artifact. The complete annual file is downloaded once; selected-column reads do not reduce that initial download.
Requests for F_MAR_P warn that this is a paternity-acknowledgment reporting flag, not a validated marital-status reporting flag. Requests for DMAR from 2017 onward warn that NCHS withholds record-level marital status for births occurring in or to residents of California. Interpretation notes are retained in annual provenance; source fields and blanks remain unchanged.
Value
A data frame containing the requested source fields and an explicit year column.
standardize_natality()Add a Bounded Set of Source-Preserving Natality Standardizations
Add a Bounded Set of Source-Preserving Natality Standardizations
Description
An opt-in, additive projection of a small documented core. It preserves source data and separates standardized representations from scientific comparability. It does not provide full harmonization, independent scientific approval, automatic gestation substitution or clinical-hold promotion.
Usage
standardize_natality(
data, year,
concepts = c("birth_year", "birth_month", "residence", "sex", "plurality",
"birthweight", "low_birthweight", "maternal_age"),
population = c("as_supplied", "us_residents"), strict = TRUE
)
Arguments
data |
A data frame containing exact annual native character columns. Original columns, values, row order and row count are retained. |
year |
One supported whole-number annual release year, or one year per
row. The initial contract covers 2000–2024. This declaration does not
authenticate arbitrary supplied data. An existing year column or native
birth-year value must agree; |
concepts |
Unique names from the documented bounded core or the explicitly
requested |
population |
|
strict |
Reject unexpected source codes by default, including malformed
reporting/certificate codes for gestational diabetes. With
|
Details
The core comprises birth year, birth month, U.S. residence, recorded infant sex, common plurality groups, gram birthweight, a low-birthweight indicator, and maternal-age intervals. Native character widths and codes are checked before projection; original strings, including leading zeros and spaces, remain intact. Published native Parquet reads have these character codes. A legacy local file whose importer has converted codes to numbers or factors is rejected; the function does not reconstruct leading zeros or other original formatting.
Sex maps CSEX 1/2 in 2000–2002 and SEX M/F thereafter to
male/female. Plurality becomes 1, 2, 3,
4+; the earlier categories 4 and 5 explicitly lose their distinction in
this new output. The source DPLURAL is retained. A nat_singleton
indicator is also supplied when plurality is requested.
Maternal age uses DMAGE in 2000–2002, MAGER41 in 2003 and
MAGER thereafter. Exact recorded years appear only in
nat_maternal_age_years. Grouped endpoints instead have bounds and
granularity: 2003's under-15 code has upper bound 14 and no invented lower
bound; later lower endpoints cover 10–12. Upper endpoints cover 50–54 in
2004–2006, 50–64 in 2007–2013, and an open 50-plus group thereafter.
An NA exact-age value with observed_grouped status is not missing age.
No midpoint or exact endpoint age is imputed.
Birthweight uses DBIRWT in 2000–2002 and DBWT thereafter.
Documented 227–8165 g values are numeric. Code 9999 is documented as unknown
in 2000–2002 and 2014–2024; the 2003–2013 detailed rows omit its meaning.
For those historical years it remains undocumented_code, with NA
standardized weight and low-birthweight, rather than being silently assigned a
later year's meaning. Low birthweight is below 2500 g among known eligible
weights; unknown, unresolved and ineligible records are not negative outcomes.
Source unknown, unresolved blank, input NA, undocumented and invalid codes, grouped observations, and derived population exclusions retain distinct status labels. Original imputation/reporting flags remain unchanged if supplied; this function neither removes imputed records nor declares that values were not imputed. Gestation measures and ambiguous flags require separate contracts. Use the annual codebook and source-quality notes before analysis.
concepts = "gestational_diabetes" connects RF_GEST in
2004–2013 to RF_GDIAB in 2014–2024, preserving both native inputs.
It requires F_RF_GDIAB; historical 2004–2013 also requires
REVISION. Only reporting records (flag 1, and historical revised
certificate A) with Y or N produce TRUE or FALSE. Unknown U, documented blank,
input NA, nonreporting, unrevised certificates and malformed values do not
become negative outcomes. Exact native character widths are required; padded,
numeric and factor inputs are not silently converted. The 2000–2003 source
files do not provide this separately identified field and yield NA with
not_separately_available; generic diabetes is never substituted.
The extension adds nat_gestational_diabetes, an overall
nat_gestational_diabetes_status, and separate
nat_gestational_diabetes_source_status and
nat_gestational_diabetes_eligibility_status columns. These separate
dimensions retain unknown source responses even when records are nonreporting.
The overall status uses eligibility exclusions before source states, except
invalid source codes remain explicit; population exclusions apply last.
population = "us_residents" additionally requires exact annual
RESTATUS and masks foreign or unresolved-residence records without
filtering rows. Its annual contracts and both status summaries are retained in
the standardization attribute. Use natality_concepts("gestational_diabetes")
to inspect the complete mapping and source citations. This representation does
not establish comparable population coverage or clear clinical display holds.
Value
The original data frame plus requested nat_* values and status columns.
The natality_standardization attribute records the contract, declared
years, population, source references, source-status counts and pending review.
Existing output columns are never overwritten. Existing
natality_provenance from read_natality() is retained unchanged.
See Also
read_natality, natality_codebook,
natality_changes, natality_concepts
Examples
# Synthetic demonstration only: these are not actual birth records.
x <- data.frame(
DBWT = c("2499", "2500", "9999"), RESTATUS = c("1", "4", "1")
)
z <- standardize_natality(
x, 2024, concepts = c("birthweight", "low_birthweight"),
population = "us_residents"
)
z$nat_low_birthweight
# Original source codes are preserved.
identical(z$DBWT, x$DBWT)