Re: [R] NA values trimming

2009-07-06 Thread nyk
Thanks again for all the help, now I was able to write the function I need: namax <- function(m,mp) { # arguments: matrix, maximum percentage of NA values allowed in rows/colums c1 <- 0 c2 <- 0 repeat { nas1 <- rowMeans(is.na(m)) nas2 <- col

Re: [R] NA values trimming

2009-07-06 Thread nyk
Thanks a lot, this works! The one I used before was wrong: > data_matrix [,1] [,2] [,3] [,4] [,5] [1,]11 NA11 [2,]22222 [3,]33333 [4,] NA NA NA NA NA [5,]55555 [6,] NA66 NA6 [7,] NA NA

Re: [R] NA values trimming

2009-07-06 Thread hadley wickham
On Mon, Jul 6, 2009 at 12:12 AM, nyk wrote: > > Thanks for your reply! This is what I was looking for! > I'm using > nas1 <- apply(data_matrix,1,function(x)sum(is.na(x))/nrow(data_matrix)) > nas2 <- apply(data_matrix,2,function(x)sum(is.na(x))/ncol(data_matrix)) You can simplify this a little: pe

Re: [R] NA values trimming

2009-07-06 Thread nyk
Thanks for your reply! This is what I was looking for! I'm using nas1 <- apply(data_matrix,1,function(x)sum(is.na(x))/nrow(data_matrix)) nas2 <- apply(data_matrix,2,function(x)sum(is.na(x))/ncol(data_matrix)) The thing about "significantly more" isn't really a helpful as I look at the data now. I

Re: [R] NA values trimming

2009-07-05 Thread David Winsemius
On Jul 4, 2009, at 9:22 PM, nyk wrote: I have a data matrix containing quite a lot of missing values (NA). I know how to remove all column or rows containing NA values, but is there a some standard method for removing not all NA containing rows/column, but only those which have signific

[R] NA values trimming

2009-07-05 Thread nyk
I have a data matrix containing quite a lot of missing values (NA). I know how to remove all column or rows containing NA values, but is there a some standard method for removing not all NA containing rows/column, but only those which have significantly more NAs than others? -- View this message