change cells values in time series in data frame

Hello everyone,

I have a database and 3 columns (Fecha, Hora, PMNC).

I want to add 1 hour only for the date of 2016-02-29, which is from 0 to 23 and I want it to be from 1 to 24 and the PMNC value of hour 0 to be 1 and so on, but only for that day because all other hours have the format 1 to 24

I add a photo of the database output and a link to download the database in .rds and .csv


I think this does what you want. On 2016-02-29, both Hora and Fecha run from 1 to 24.

DF <- read.csv("~/R/Play/2016.csv")
DF <- DF |> 
  mutate(Hora = ifelse(Fecha == "2016-02-29", Hora + 1, Hora),
                   PMNC = ifelse(Fecha == "2016-02-29", Hora, PMNC))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.