Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread David Winsemius
On Jul 29, 2013, at 9:39 AM, iza.ch1 wrote: > Hi everyone > > I have a problem with replacing the NA values with the mean of the column > which contains them. If I replace Na with the means of the rest values in the > column, the mean of the whole column will be still the same as if I would >

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread William Dunlap
': 5 obs. of 3 variables: $ AllNAs : num NaN NaN NaN NaN NaN $ NoNAs : num 1 2 3 4 5 $ SomeNAs: cplx 100+1i 100+1i 100+1i ... Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread arun
Hi, de<- structure(c(NA, NA, NA, NA, NA, NA, NA, NA, 0.27500571, -3.07568579, -0.42240954, -0.26901731, 0.01766284, -0.8099958, 0.20805934, 0.03036708, -0.26928087, 1.20925752, 0.38012008, -0.41778861, -0.49677462, -0.13248754, -0.54179054, 0.35788624, -0.41467591, -0.59234248, 0.73642396, -0.

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread Berend Hasselman
On 29-07-2013, at 18:39, "iza.ch1" wrote: > Hi everyone > > I have a problem with replacing the NA values with the mean of the column > which contains them. If I replace Na with the means of the rest values in the > column, the mean of the whole column will be still the same as if I would >

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread Jorge I Velez
Consider the following: f <- function(x){ m <- mean(x, na.rm = TRUE) x[is.na(x)] <- m x } apply(de, 2, f) HTH, Jorge.- On Tue, Jul 30, 2013 at 2:39 AM, iza.ch1 wrote: > Hi everyone > > I have a problem with replacing the NA values with the mean of the column > which contains them. If I repla

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread John Fox
Dear iza.ch1, I hesitate to say this, because mean imputation is such a bad idea, but it's easy to do what you want with a loop, rather than puzzling over a "cleverer" way to accomplish the task. Here's an example using the Freedman data set in the car package: > colSums(is.na(Freedman)) popul

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread Berend Hasselman
On 29-07-2013, at 18:39, "iza.ch1" wrote: > Hi everyone > > I have a problem with replacing the NA values with the mean of the column > which contains them. If I replace Na with the means of the rest values in the > column, the mean of the whole column will be still the same as if I would >

[R] replace Na values with the mean of the column which contains them

2013-07-29 Thread iza.ch1
Hi everyone I have a problem with replacing the NA values with the mean of the column which contains them. If I replace Na with the means of the rest values in the column, the mean of the whole column will be still the same as if I would have omitted NA values. I have the following data de