I have a variable with some missing values
a <- rnorm(100);
a[sample(1:100,10)] <- NA;
a;
How can I fill missing values with previous non missing value?
for example if I have sequence:
a<- (3, 2, 1, 6, 3, NA, 23, 23, NA);
first NA should be replaced by first previous non NA number 3, second NA should be replaced with 23 etc.
Thanks