Is anyone hit with the fact that Min/Max with na.rm = TRUE will return different class from the input if there are no non-NA values?
In particular scenario I use min with na.rm = TRUE with group_by/summarise on a column which is of type integer. I then found the result is numeric - not integer. because min is returning -Inf for groups with no non-NA values.
Is there a library which gets around this or do I need to put a wrapper function around min?
To be frank I programmed around this in the early days but just letting my integers become numeric - but it doesn't seem right.
It cant be that the end result is both Inf and integer, so one or the other will have to go...
If you want the vector class containing a mix of integers and Inf values to be integer you could cast them to integer and the Inf's will go to NA, is that acceptable ? otherwise what integer value would be ?
I want a vector with integers and NAs to always be returned as class integer.
Even if a vector is all NA (of class integer)
My criticism of min/max is that they don't return the same class for a given class of input.
Here is my best shot as a workaround - to be used in the situation where I know I want to use na.rm = TRUE