I have a sequence of operations that I use the R 4.3 pipe to execute:
df <- alfred::get_alfred_series(CHAUVET_PIGER_PROB)
unrevised_df <- df |>
within(Delta <- realtime_period - date) |>
na.omit() |>
subset(Delta == ave(Delta, date, FUN = min)) |>
subset(Delta <60) |>
within(date <- zoo::as.yearmon(format(date, format = '%Y-%m-%d'))) |>
subset(select = -c(Delta, realtime_period))
> head(unrevised_df)
date UNRATE
146 1960-02-01 4.8
1065 1960-03-01 5.4
1984 1960-04-01 5.0
2903 1960-05-01 4.9
3822 1960-06-01 5.5
4741 1960-07-01 5.4
I would like to add one more line to my sequence to change the name of the first column from date
to Date
without having to invoke dplyr
. I’m aware that I can simply add a separate line that reads
colnames(unrevised_df[1]) <- "Date"
but I would like to make this a line in the pipe. How can I do this?
Your help is greatly appreciated.
Sincerely
Thomas Philips