I am new to R programming and i am trying to do some work in my office. I have a dataframe as below:
Sale_date    Sale_State  units_sold   Cummulative_unit_sold
30/1/2020    Kerala          1               1
1/2/2020     Kerala          1               2
2/2/2020     Kerala          2               4
3/2/2020     Tamil Nadu      1               1
3/2/2020     Rajasthan       2               2
3/2/2020     Delhi           1               1
4/2/2020     Kerala          1               5
4/2/2020     Rajasthan       1               3
etc.... So the data is in this kind.
I want the output in the below format
Sale_date    Sale_State  units_sold   Cummulative_unit_sold
30/1/2020    Kerala          1               1
1/2/2020     Kerala          1               2
2/2/2020     Kerala          2               4
3/2/2020     Tamil Nadu      1               1
3/2/2020     Rajasthan       2               2
3/2/2020     Delhi           1               1
3/2/2020     Kerala          2               4(Please observe here in rawdata no sales on 3/2/2020 for kerala state so it should copy the same data as previous date data)
4/2/2020     Kerala          1               5
4/2/2020     Rajasthan       1               3
4/2/2020     Tamil Nadu      1               1(Please observe here in rawdata no sales on 4/2/2020 for Tamil Nadu state, so it should copy the same data as previous data)
I am not getting how to do this. This is not directly something replacing NA values, but instead I want to create a dummy row of State for which there is no sales on respective day and add the previous data which is available.
Thanks, Hemanth
 
    