Skip to content

computeAvgCommunProb_LR_Avg/Sum: format(x, digits=1) >= min.percent performs lexicographic string comparison instead of numeric #5

Description

@gettygugu-dot

In computeAvgCommunProb_LR_Avg (modeling.R L1276) and computeAvgCommunProb_LR_Sum (L1345):

dataLR_percent <- 1 * (format(dataLR_temp[, -1], digits = 1) >= min.percent)

format() returns a character string. For small values, R uses scientific notation:

format(0.00032, digits = 1)
# [1] "3e-04"
"3e-04" >= 0.005
# [1] TRUE   # lexicographic: "3" > "0" → TRUE
# Should be FALSE because 0.00032 < 0.005

Fix: Replace format() with direct numeric comparison in both functions:

# Before (bug):
dataLR_percent <- 1 * (format(dataLR_temp[, -1], digits = 1) >= min.percent)

# After (fix):
dataLR_percent <- 1 * (dataLR_temp[, -1] >= min.percent)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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