Skip to content

A14-36: Bootstrap.R: sample() length-1 vector trap (base R sample() gotcha, currently unreachable with normal weights) #119

Description

@ms609

R/Bootstrap.R:22sample(deindexedChars, replace = TRUE) is subject to the classic base-R sample() gotcha: when deindexedChars has length 1 and holds a value k, sample() treats it as sample(1:k, ...) rather than sampling the single value k itself. Essentially unreachable with normal phyDat weights (which rarely produce a length-1 deindexedChars), but a one-line fix.

Verified REAL (haiku verifier, code-read).

Fix: use sample.int-based indexing, or wrap with the standard idiom (x[sample.int(length(x), ..., replace=TRUE)]) that avoids the vector/scalar ambiguity.

Filed by /red-team area 14 (opus finder, 2026-08-05).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:14Red-team focus area 14in-progressBeing fixed; claiming comment names the branchred-teamFiled by the /red-team rotationsev:lowP3: robustness / polish

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions