r - convert year-doy to mdy -


I would like to change a column (or create a new one) which is the year of year M / D / y. Originally I had two different columns of year and year, but I combined them together (Paste) because I thought that year will be required yearly because of the leap of the year I have not been opposed to using an additional package such as date .

Here's my data:

  dat < - Structure (List (Doy = c (320, 350, 309, 310, 328, 321, 301, 338, 304, 304, 308), Year = Structure (1:11, .label = C ("2000",) "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010"), class = "factor"), conc = C ("2000-320", "2001-350", "2002-309", "2003-310", "2004-328", "2005-321", "2006-301", "2007-338", "2008-304", "2009-304", "2010-308"), line.Name = C (NA, -11 L), class = "data.frame", name = c ("doo" "Year", "Conak"))  

And it looks like:

  Two years of concert 1 320 2000 2000-320 2 350 2001 2001- 350 3 30 9 2002 2002-30 9 4 310 2003 2003-310 5 328 2004 2004-328 6 321 2005 2005-321 7 301 2006 2006-301 8 338 2007 2007-338 9 304 2008 2008-304 10 304 2009 2009- 304 11 308 2010 2010-308  

-O

No additional packages required:

  within (dat, Dtime & lt; - as.POSIXct (conc, format = '% Y-% j'))  

Comments