I have some data with names I'm trying to rename based on certain date ranges. For now I don't have an end date, but in the future there will be so it would be nice to have both options. I'm fine converting date back to date if ifelse()
coerces it into numeric format unless there is a better way. Do I just have to convert to numeric first and figure out which numbers correspond to my date range, run ifelse()
, then convert back to date when done? I tried to get some insight from this but i'm not sure if it will work for me. Ifelse statement in R with multiple conditions
structure(list(Serial = c("580300", "380201", "380201", "480862",
"480862", "480862"), Name = c("Gomex", "Clammy",
"Clammy", "Channel Islands", "Channel Islands", "Channel Islands"
), Date = structure(c(1476928800, 1553619600, 1476932400, 1503777600,
1476936000, 1604070000), class = c("POSIXct", "POSIXt"), tzone = "")), row.names = c(NA,
6L), class = "data.frame")
I'm trying to do something like this...
vue$Name <- ifelse(vue$Serial == "480862" & Date >= "2019-8-23 10:00:00", "newname", vue$Name)
Error in Date >= "2019-8-23 10:00:00" :
comparison (5) is possible only for atomic and list types
Aucun commentaire:
Enregistrer un commentaire