Hello, I use the function rowMeans(x,na.rm=T). The result is the mean of valid values in each row, with NA removed. A for me very important information is, from how many valid "n" this mean has computed. The thing is, that I apply this function on many millions of rows, so the time it takes is multiplied by this factor! (so getting this with "rowSums(is.na(x))" it takes much to long) I was trying to look inside the function maybe to get not only the means but the valid "n" too, but I wasn't able. Thanks for help Matteo DI Matteo Mattiuzzi, Institut für Vermessung, Fernerkundung und Landinformation Peter Jordan Str. 82 A-1190 Wien Tel.: 0043/(0)1/47654-5114 [[alternative HTML version deleted]]
On 09/28/2009 10:47 PM, Matteo Mattiuzzi wrote:> Hello, > > I use the function rowMeans(x,na.rm=T). The result is the mean of valid > values in each row, with NA removed. A for me very important information > is, from how many valid "n" this mean has computed. > > The thing is, that I apply this function on many millions of rows, so > the time it takes is multiplied by this factor! (so getting this with > "rowSums(is.na(x))" it takes much to long) > > I was trying to look inside the function maybe to get not only the > means but the valid "n" too, but I wasn't able. > >Hi Matteo, The number of observations that are NOT NA can be calculated with: sum(!is.na(x)) and you can see this in action in the valid.n function in the prettyR package. Jim