I want to generate a vector of 21 years starting from 1990 to 2010. I am using the as.POSIXct
function as follows
time=as.POSIXct("1990-01-01", tz="GMT")+0:20*3600*(24*365)
and i get the following answer
[1] "1990-01-01 GMT" "1991-01-01 GMT" "1992-01-01 GMT" "1992-12-31 GMT" "1993-12-31 GMT" "1994-12-31 GMT"
[7] "1995-12-31 GMT" "1996-12-30 GMT" "1997-12-30 GMT" "1998-12-30 GMT" "1999-12-30 GMT" "2000-12-29 GMT"
[13] "2001-12-29 GMT" "2002-12-29 GMT" "2003-12-29 GMT" "2004-12-28 GMT" "2005-12-28 GMT" "2006-12-28 GMT"
[19] "2007-12-28 GMT" "2008-12-27 GMT" "2009-12-27 GMT"
which ends in 2009 instead of 2010 as desired.
Can anyone help and if possible on how to generate years without the month and dates, only the years alone using as.POSIXct
function?