[R] To many NA's from mean(..., na.rm=T) when a column is all NA's

2005-06-13 Thread Jim Robison-Cox
Dear R-help folks, I am seeing unexpected behaviour from the function mean with option na.rm =TRUE (which is removing a whole column of a data frame or matrix. example: testcase - data.frame( x = 1:3, y = rep(NA,3)) mean(testcase[,1], na.rm=TRUE) [1] 2 mean(testcase[,2], na.rm = TRUE) [1] NaN

Re: [R] To many NA's from mean(..., na.rm=T) when a column is all NA's

2005-06-13 Thread Sundar Dorai-Raj
Jim Robison-Cox wrote: Dear R-help folks, I am seeing unexpected behaviour from the function mean with option na.rm =TRUE (which is removing a whole column of a data frame or matrix. example: testcase - data.frame( x = 1:3, y = rep(NA,3)) mean(testcase[,1], na.rm=TRUE) [1] 2

Re: [R] To many NA's from mean(..., na.rm=T) when a column is all NA's

2005-06-13 Thread Peter Dalgaard
Jim Robison-Cox [EMAIL PROTECTED] writes: Summary: If I have a data frame or a matrix where one entire column is NA's, mean(x, na.rm=T) works on that column, returning NaN, but fails using apply, in that apply returns NA for ALL columns. lapply works fine on the data frame. If you

Re: [R] To many NA's from mean(..., na.rm=T) when a column is all NA's

2005-06-13 Thread Achim Zeileis
On Mon, 13 Jun 2005 11:05:46 -0600 (MDT) Jim Robison-Cox wrote: Dear R-help folks, I am seeing unexpected behaviour from the function mean with option na.rm =TRUE (which is removing a whole column of a data frame or matrix. example: testcase - data.frame( x = 1:3, y = rep(NA,3)) In

Re: [R] To many NA's from mean(..., na.rm=T) when a column is all NA's

2005-06-13 Thread Jim Robison-Cox
I see. So apply() first changes the dataframe to a matrix, which made it a matrix of text values, then mean made no sense for any column, so I got all NA's. Thanks, Peter, Jim On 13 Jun 2005, Peter Dalgaard wrote: Jim Robison-Cox [EMAIL PROTECTED] writes: Summary: If I have a data