Skip to content
Prev 86725 / 398513 Next

(Newbie) Functions on vectors

You can use ifelse but even better note that
the zoo package has the yearqtr class which represents years
and quarters internally as years + (qtr-1)/4 where qtr is 0,1,2,3
so as to be consistent with ts class.   It also
has an as.Date.yearqtr method which will convert them
to class Date.  Using these the code is really just one line:


# test data
year <- 2001:2004
qtr  <- 1:4

library(zoo)
as.Date(as.yearqtr(year + qtr/4), frac = 1)
On 2/17/06, Vivek Satsangi <vivek.satsangi at gmail.com> wrote: