Skip to content
Prev 86728 / 398513 Next

(Newbie) Functions on vectors

Vivek,

For the tests you can do, for example:

if(any(quarter < 1 | quarter > 4)) stop('invalid quarter(s)')

For the dates you can do:

ret <- paste(c('6/30', '9/30', '12/31', '3/31')[quarter],
    year + quarter == 4, sep='/')

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
Vivek Satsangi wrote: