Creating a new coloumn for date info with specific date format
Posted
by
Ayan
on Stack Overflow
See other posts from Stack Overflow
or by Ayan
Published on 2012-04-12T17:17:45Z
Indexed on
2012/04/12
17:28 UTC
Read the original article
Hit count: 275
r
Dear All I am working with a file which has few years data and I am trying to create an aditional coloumn that reads the year and month info from the date coloumn (e.g. 01/01/1997 12:00) and create a new coloumn with month and year together(e.g. Jan-97).
I am not sure how to proceed with this but what I am trying to code is the coloumn with name "new_date" in the following picture:
my sample data =
> dput(df)
structure(list(date = structure(c(1L, 4L, 7L, 2L, 5L, 8L, 3L,
6L, 9L), .Label = c("01/01/1997 12:00", "01/01/1998 15:00", "01/01/1999 18:00",
"01/02/1997 13:00", "01/02/1998 16:00", "01/02/1999 19:00", "01/03/1997 14:00",
"01/03/1998 17:00", "01/03/1999 19:00"), class = "factor"), value = c(29L,
31L, 42L, 42L, 52L, 61L, 57L, 55L, 56L)), .Names = c("date",
"value"), row.names = c(NA, -9L), class = "data.frame")
I would really appreciate if you could advise me about how should I proceed with this,
Many thanks,
Ayan
© Stack Overflow or respective owner