bigvis icon indicating copy to clipboard operation
bigvis copied to clipboard

`weighted.median(NA, na.rm=T)` returns `logical(0)`, expected `NA_real_`

Open danielkrizian opened this issue 9 years ago • 0 comments

I'd propose that weighted.median function returns NA_real_ instead of logical(0), when all x are NAs:

weighted.median(NA, 1, na.rm=T) # returns `logical(0)`

The problem with logical(0) output is that calculating weighted mean summaries by group causes an error when using dplyr::group_by and dplyr::summarise

  ## Column 2 of result for group 2 is type 'double' but expecting type 'logical'. Column types must be consistent for each group. 

danielkrizian avatar Nov 06 '14 16:11 danielkrizian