I need help. I am trying to copy the date_time column values into new column based on matching values of txt_col column and those that are not matched mark as NA. Here is my code:
df$new_col <- ifelse(df$txt_col == "apple", df$date_time, NA)
However, I get numbers in the new column, instead of date-time :
   new_col
1477962000
1451755980
1451755980
1451755980
When looking at the str(df), the column date_time is POSIXct.  I tried to convert as.numeric and POSIXct, it didn't work. If you have more elegant ways to do what I am trying to achieve, it would be much appreciated if you share. Thank you.