na.interpolation imputeTS. na.interpolation - , , .
library(dplyr)
library(imputeTS)
dt2 <- dt %>%
replace(. == 0, NA) %>%
mutate(Sales = na.interpolation(Sales))
dt2
Date Sales
1 09/01/2017 9000
2 09/02/2017 12000
3 09/03/2017 11500
4 09/04/2017 11000
5 09/05/2017 14400
6 09/06/2017 16600
7 09/07/2017 18800
8 09/08/2017 21000
9 09/09/2017 15000
10 09/10/2017 23100
11 09/11/2017 27550
12 09/12/2017 32000
13 09/13/2017 8000
dt <- read.table(text = "Date Sales
09/01/2017 9000
09/02/2017 12000
09/03/2017 0
09/04/2017 11000
09/05/2017 14400
09/06/2017 0
09/07/2017 0
09/08/2017 21000
09/09/2017 15000
09/10/2017 23100
09/11/2017 0
09/12/2017 32000
09/13/2017 8000",
header = TRUE, stringsAsFactors = FALSE)