0

How can I replace the value/date 1970-01-01 00:00:00 in one columne with NA in R?

tried this:

ESM13$Committed[ESM13$Committed == "1970-01-01 00:00:00"] <- NA

didn't work. Couldn't figure out how to use mutate either.

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. It's not clear why that wouldn't work. There must be something going on with the data itself. Is the column imported as a POSIXct value? or a character value? or something else? – MrFlick Nov 08 '22 at 18:44
  • what if you do: `ESM13[ESM13$Committed == "1970-01-01 00:00:00",]$Committed <- NA` – MarBlo Nov 08 '22 at 18:59

1 Answers1

0

I think 1970-01-01 00:00:00 is the datetime associated with the internal value of 0. So I'm guessing the following should work:

ESM13$Committed[as.numeric(ESM13$Committed) == 0] <- NA
shaun_m
  • 1,213
  • 3
  • 13