Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Row-wise entry population based on previous row

$
0
0

I have a R data frame that looks like this:

Category Date        Column
Cat1     2018-03-23  19
Cat1     2018-03-24  19
Cat1     2018-03-25  19
Cat1     2018-03-26  NULL
Cat1     2018-03-27  NULL
...      ....        ...
Cat2     2018-03-23  25
Cat2     2018-03-24  25
Cat2     2018-03-25  25
Cat2     2018-03-26  NULL
Cat2     2018-03-27  NULL
...      ....        ...

and want to replace NULL values with the last number. So for Cat1 the NULL becomes 19 and for Cat2 rows NULL becomes 25. How may I achieve this?


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>