s-news
[Top] [All Lists]

Re: simple question

To: Eric yang <yang_eric9@yahoo.com>
Subject: Re: simple question
From: David L Lorenz <lorenz@usgs.gov>
Date: Fri, 24 Mar 2006 10:38:28 -0600
Cc: s-news@wubios.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <20060324161840.66999.qmail@web33904.mail.mud.yahoo.com>

Eric,
  A combination of the quarters() and years() functions should work for you. Each would create a factor, but if you extract the integer value, you could produce the desired sequence as months + (years - 1) * 4.
Dave


Eric yang <yang_eric9@yahoo.com>
Sent by: s-news-owner@lists.biostat.wustl.edu

03/24/2006 10:18 AM

To
s-news@wubios.wustl.edu
cc
Subject
[S] simple question





 
Dear all,
 
Can someone help me with a very simple question. Suppose I have the dates
 
 
my.dates <- c("03/01/05", "04/01/05", "05/01/05", "06/01/05", "07/01/05", "08/01/05", "09/01/05", "10/01/05", "11/01/05", "12/01/05", "01/01/06", "02/01/06", "03/01/06", "04/01/06", "05/01/06", "06/01/06", "07/01/06", "08/01/06", "09/01/06", "10/01/06", "11/01/06")
 
 
and I want to split the my.dates into a sequence related to the quarterly period, i.e. grouping into ("01", "02", "03"), ("04", "05", "06"), ("07", "08", "09") and ("10", "11", "12")
 
to give
> my.sequence
[1] 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8
Thanks in advance for any help.
 
Regards
Eric


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

<Prev in Thread] Current Thread [Next in Thread>