[Rd] There is pmin and pmax each taking na.rm, how about psum?
mdowle at mdowle.plus.com
Tue Oct 30 12:03:00 CET 2012
Please consider the following :
x = c(1,3,NA,5)
y = c(2,NA,4,1)
min(x,y,na.rm=TRUE) # ok
max(x,y,na.rm=TRUE) # ok
sum(x,y,na.rm=TRUE) # ok
pmin(x,y,na.rm=TRUE) # ok
 1 3 4 1
pmax(x,y,na.rm=TRUE) # ok
 2 3 4 5
 3 3 4 6 # expected result
Error: could not find function "psum" # actual result
I realise that + is already like psum, but what about NA?
 3 NA NA 6 # can't supply `na.rm=TRUE` to `+`
Is there a case to add psum? Or have I missed something.
This question survived when I asked on Stack Overflow :
And a search of the archives found that has Gabor has suggested it too as
an aside :
If someone from R core is willing to sponsor the idea, I am willing to
write, test and submit the code for psum. Implemented in a very similar
fashion to pmin and pmax. Or perhaps it exists already in a package
somewhere (I searched but didn't find it).
More information about the R-devel