Reputation: 1946
I ran analysis yesterday and have dates in one data.frame as follows:
$ Start : POSIXct, format: "2017-04-30 00:00:00" "2017-04-30 00:09:39" "2017-04-30 00:00:00" "2017-04-30 00:08:42" ...
However, I am working on analysis today and trying to lookup a median time within the date range of a data.frame. The dates in this data.frame are today's date:
$ MedianR: POSIXct, format: "2017-05-01 00:00:08" "2017-05-01 00:01:09" "2017-05-01 00:01:33" "2017-05-01 00:01:51" ...
Is it possible to edit the date and month only, in either data.frame, so they are the same?
Upvotes: 2
Views: 1095
Reputation: 492
If you want to extract out parts of the date you can use:
dataframe$dateonly <- ymd(strptime(as.character(dataframe$datetime), "%Y-%m-%d"))
you could pull that out or you can also pull out year month and day using lubridate
dataframe$year <- year(dataframe$date)
and do this for month and day and whatever else and then paste them back together to make a new date if that makes any sense at all?
Upvotes: 2