SixiangHu / DataMan

R package for data cleaning, preliminary data analysis and modeling assessing with visualisation.
3 stars 0 forks source link

[DataSummary]Weighted Mean Values are not correct when including NA #49

Closed SixiangHu closed 6 years ago

SixiangHu commented 6 years ago
test = data.frame(a = c(1,NA),b = c(1,1))
DataSummary(test)

VarName VarType Unique Missing Missing_pct Mean Min Max Entropy 1: a numeric 2 1 0.5 0.5 1 1 0 2: b numeric 1 0 0.0 1 1 1 0

It is related to: https://github.com/SixiangHu/DataMan/blob/master/R/DataSummary.R#L75

That when x include NAs, the sum of weighted is less than sum(weight,na.rm=TRUE) because there is no NA in weight.