I am merging two data frames however some data points are missing and I, therefore, want the merged data frame to use the last known value to overwrite the missing values.
Currently, my code is as follows:
CombData$`Price Close` <- CombData %>%
group_by(ISIN) %>%
mutate(na.locf(CombData$`Price Close`, na.rm = TRUE))
However, when looking at the output I can see that no missing values get replaced. Below is an example of how the data currently looks:
ISIN Date Price Close
20 BSP951331318 2010-01-29 434.0
21 BSP951331318 2010-01-31 NA
Here I would like row 21 to have a closing price of 434.