Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] qsu() inconsistent results when passed NA weights #772

@ummel

Description

@ummel

When qsu() is passed all NA weights, it (correctly) returns NA -- but only if no groups are used. If groups are used, it (incorrectly) returns zeros for Mean, Min, and Max instead of NA. This is inconsistent with the behavior of fsum() in the same situation.

data <- num_vars(wlddev)

# Vector of all NA weights
# This can happen for individual groups in a large-scale analysis
wgt <- rep(NA, nrow(wlddev))

# Correct: Returns NA values in presence of NA weights if 'by = NULL'
qsu(data, by = NULL, w = wgt)

# Incorrect: When groups are used, returns zero values for Mean, Min, and Max instead of NA/dash
qsu(data, by = wlddev$region, w = wgt)

# Note that fsum() correctly returns NA in both cases
fsum(data, g = NULL, w = wgt)
fsum(data, g = wlddev$region, w = wgt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions