I need to use dplyr mutate to create a new column that can show me (perhaps repeated values) of each maximum date what the respective value is.
library(dplyr)
set.seed(1234)
df <- data.frame(
dates = seq.Date(as.Date("2022-08-23"),
as.Date("2022-09-11"),
by = "days"),
names = c(
"a",
"a",
"b",
"c",
"a",
"a",
"c",
"b",
"a",
"a",
"b",
"c",
"a",
"b",
"c",
"d",
"b",
"a",
"b",
"c"
),
value = rnorm(20,0,1)
)
glimpse(df)
df
How could I use mutate to insert a column that repeats the largest date value for each name until the name changes?