Hello,
sum(data.frame(),na.rm=TRUE) still throws an Error, is this really the
intended behavior?
> sum(data.frame())
Error in FUN(X[[1L]], ...) : only defined on a data frame with all
numeric or complex variables> sum(data.frame(),na.rm=TRUE)
Error in FUN(X[[1L]], ...) : only defined on a data frame with all
numeric or complex variables
The context is
# x is a data frame generated from read.csv()
# bins is an index for histogram bins stored in csv
file.> sum(x[is.element(x$color,0:3),bins],na.rm=TRUE)
Which works when is.element() returns any TRUE values.
It would be nice if i could avoid coding this up this way...
> sum(as.matrix(x[is.element(x$color,0:3)),bins],na.rm=TRUE)
I'm just wondering if this is really the intended behavior, noting that
> sum(matrix())
[1] NA> sum(matrix(),na.rm=TRUE)
[1] 0
behave as i would have expected. [using R 2.5.1 under windows ]
Thanks
Jacob Colvin