Skip to content

Replace sapply() with vapply() for type safety #516

@utkarshpawade

Description

@utkarshpawade

Description

Nine uses of sapply() can silently return a list() instead of the expected atomic vector on zero-length input, causing hard-to-diagnose downstream failures. vapply() enforces a declared return type and is faster due to pre-allocation.

The two sapply(x, colnames) calls at helpers-mcmc.R:277,303 should be intentionally kept as they rely on sapply()'s flexible return to detect mismatched column names across chains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions