Hi,
c1 = (1,2,3,4,5,6,NA,7,8,NA,9,10,NA)
library(zoo)
na.locf(c1)
# [1] 1 2 3 4 5 6 6 7 8 8 9 10 10
A.K.
Hi, I want to "fix" an array that contains several NA elements. And I
would like to replace them with the previous valid element.
So my array c = (1,2,3,4,5,6,NA,7,8,NA,9,10,NA
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
>
': 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
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.
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
>
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
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
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
>
try 'na.locf' in the zoo package
On Mon, Jun 21, 2010 at 7:52 AM, Patrick Hausmann
wrote:
> Dear list,
>
> I'm trying to replace NA-values with the preceding values in that column.
> This code works, but I am sure there is a more elegant way...
>
> df <- data.frame(id = c("A1", NA, NA, NA, "B1",
9 matches
Mail list logo