I have a current DataFrame that looks like this:
DATETIME MEAS_AVG TARG_MIN TARG_AVG TARG_MAX DESPORT_NOTE
1 2012/04/10 14:03:37 0.2888 0.22 0.25 0.27 GOOD_PT
2 2012/03/30 07:48:17 0.2544 0.22 0.25 0.27 GOOD_PT
3 2012/03/24 19:23:08 0.2333 0.22 0.25 0.27 GOOD_PT
4 2012/03/25 16:10:17 0.2111 0.22 0.25 0.27 GOOD_PT
5 2012/04/10 00:58:29 0.2222 0.22 0.25 0.27 GOOD_PT
6 2012/04/14 18:32:52 0.2888 0.22 0.25 0.27 GOOD_PT
7 2012/04/21 14:47:47 0.2777 0.22 0.25 0.27 GOOD_PT
The data frame is called df3
and the specific column I am looking to replace the dates for are df3$DATETIME
.
I have this function in my code already in order to strip the datetime:
date <- strptime(df3$DATETIME, "%Y/%m/%d %H:%M:%S")
All I am looking to replace all the datetime information with simple month names. This is what it should look like after the replace function:
DATETIME MEAS_AVG TARG_MIN TARG_AVG TARG_MAX DESPORT_NOTE
1 April 0.2888 0.22 0.25 0.27 GOOD_PT
2 March 0.2544 0.22 0.25 0.27 GOOD_PT
3 March 0.2333 0.22 0.25 0.27 GOOD_PT
4 March 0.2111 0.22 0.25 0.27 GOOD_PT
5 April 0.2222 0.22 0.25 0.27 GOOD_PT
6 April 0.2888 0.22 0.25 0.27 GOOD_PT
7 April 0.2777 0.22 0.25 0.27 GOOD_PT
I am been looking all over for a simple replace column function, but can't seem to find it. I know that I can use the as.Date()
function with the formated %B
to return the unabreviated month. The only problem is I do not know how to use this to replace the column values already existing.
I can list the months using this function:
list(month=months(as.Date(df3$DATETIME)))