I have a file with multiple data formats :
date<-structure(list(date = structure(c(10L, 45L, 40L, 24L, 53L, 51L,
13L, 68L, 29L, 11L, 40L, 47L, 52L, 34L, 39L, 46L, 20L, 15L, 26L,
72L), .Label = c("", "01/2005", "01/2015", "03/2008", "05/2008",
"05/2012", "06/2014", "08/2008", "09/2010", "1/12/2001", "1/2002",
"10/2007", "10/2010", "10/2011", "11/2013", "12/2004", "12/2006",
"12/2010", "12/2014", "15/02/2014", "16/04/2014", "16/12/2014",
"17/07/2006", "1968", "1979", "1982", "1984", "1985", "1986",
"1992", "1993", "1994", "1997", "1998", "1998/02", "2/2008",
"2/8/2000", "2000", "2001", "2002", "2002/08", "2003", "2004",
"2005-01-01", "2006-06-01", "2007", "2007-12-20", "2008", "2008-06-28",
"2009", "2010", "2011", "2012", "2012/03", "2013", "2014", "21/10/2014",
"23/10/2014", "24/2000", "3/2007", "5/2009", "6/2001", "6/2012",
"8/5/1993", "9/2009", "April 2012", "Jan 1975", "Jan 1976", "Mar 1976",
"May 1976", "Nov 18, 1975", "Sep 10, 1976"), class = "factor")), .Names = "date", row.names = c(NA,
-20L), class = "data.frame")
What I would like to do is extract the year part of these dates.
How can I do this? My idea was to put all dates in a standard format then extract the year with a subsrtring. However, I tried to standardise the dates using as.POSIXct
but given the lack of a standard format this doesn't work.