jeudi 3 décembre 2020

Change value of variables for certain months of an R data.frame?

I would like to change the values of Obs and Sim to -1.23 when Month =< 2 & Month >= 11. Seems something simple but am not coming up with any solution.

library(tidyverse)
library(lubridate)

set.seed(123)

DF <- data.frame(Date = seq(as.Date("2001-01-01"), to = as.Date("2003-12-31"), by = "day"),
                  Ob = runif(1095,1,5), Sim = runif(1095,1,5)) %>% 
        separate(Date, into = c("Year", "Month", "Day"))

Aucun commentaire:

Enregistrer un commentaire