Thanks! na.locf was spot on
Very fast approach to this type of problem.
--
View this message in context:
http://r.789695.n4.nabble.com/Replacing-values-without-looping-tp3602247p3605203.html
Sent from the R help mailing list archive at Nabble.com.
__
Hi
> Hi,
>
> If you truly have an array, this is option that should be much faster
> than a loop:
>
> index <- which(is.na(dat))
> dat[index] <- dat[index - 1]
>
> the only catch is that when there previous value is NA, you may have
> to go through the process a few times to get them all. One
Hi,
If you truly have an array, this is option that should be much faster
than a loop:
index <- which(is.na(dat))
dat[index] <- dat[index - 1]
the only catch is that when there previous value is NA, you may have
to go through the process a few times to get them all. One way to
automate this wou
I got an array similar to the one below, and want to replace all NAs with the
previous value.
99 8.2 b
NA 8.3 x
NA 7.9 x
98 8.1 b
NA 7.7 x
99 9.3 b
...
i.e. the first two NAs should be replaced to 99, whereas the last one should
be 98.
I would like to apply a function to reach row, checking if th
4 matches
Mail list logo