[R] Replacing missing values with values before it

jim holtman jholtman at gmail.com
Sat May 7 04:36:19 CEST 2011


Look at the 'na.locf' function in the 'zoo' package.

On Fri, May 6, 2011 at 5:29 PM, Nick Manginelli <themang99 at yahoo.com> wrote:
> I'm using the survey api. I am taking 1000 samples of size of 100 and replacing 20 of those values with missing values. Im trying to use sequential hot deck imputation, and thus I am trying to figure out how to replace missing values with the value before it. Other things I have to keep in mind is if there are two missing values side by side, how do I replace both those values with the value before. Also if the first of the sample of 100 is a missing value  I will replace that with the mean of the population. Im pretty sure I have to write a loop, but if anyone can help me figuring how to write this I would appreciate it greatly. Thank you
>
> Nick Manginelli
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list