[R] HELP ME: Fill NA Values from the previous Non-NA Values
Allan Tanaka
allantanaka11 at yahoo.com
Wed Mar 15 12:08:34 CET 2017
The following is an example:
| Item_Identifier | Item_Weight |
| FDP10 | 19 |
| FDP10 | |
| DRI11 | 8.26 |
| DRI11 | |
| FDW12 | 8.315 |
| FDW12 | |
The following is the one that i want to be. That is, filling NA values from the previous Non-NA values.
| Item_Identifier | Item_Weight |
| FDP10 | 19 |
| FDP10 | 19 |
| DRI11 | 8.26 |
| DRI11 | 8.26 |
| FDW12 | 8.315 |
| FDW12 | 8.315 |
My current code data frame: train <- read.csv("Train.csv", header=T,sep = ",",na.strings = c(""," ",NA))
Some people suggest to use na.locf function but in my case, i don't have numeric unique values in my Item_Identifier coloumn but rather it's characters. Not sure what to solve this problem.
[[alternative HTML version deleted]]
More information about the R-help
mailing list