I have a dummy data frame that contains 10 date time stamps in POSIXct. Now i would like to evaluate each row, replace the cell value with a different one if above a date time threshold, otherwise keep it. I found a helpful thread here using the dplyr package, but i cannot get it to work for my particular case. Any suggestions?
The code for the dummy data frame:
df<-structure(list(Date.Out = structure(c(1478699520, 1493934000,
1510243080, 1524862800, 1541776440, 1559243220, 1475417460, 1493930940,
1495304760, 1504640100), class = c("POSIXct", "POSIXt"), tzone = "US/Eastern")), row.names = c(6L,
7L, 8L, 9L, 10L, 11L, 15L, 16L, 17L, 18L), class = "data.frame")
The code that i tried using the dplyr package that doesn't work:
df %>%
mutate(new = as.POSIXct(ifelse(Date.Out>="2019-05-01 00:00:00", "2019-05-01 00:00:00", Date.Out), origin='1970-01-01', na.rm=T))
Aucun commentaire:
Enregistrer un commentaire