From: Jacob Colvin <jbcolvin_at_fastmail.fm>

Date: Wed, 29 Aug 2007 10:47:33 -0700

R-help_at_stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 29 Aug 2007 - 17:54:42 GMT

Date: Wed, 29 Aug 2007 10:47:33 -0700

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

R-help_at_stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 29 Aug 2007 - 17:54:42 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 29 Aug 2007 - 18:34:30 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*