[R] Two quick questions

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Mar 3 08:50:34 CET 2006


On Fri, 3 Mar 2006, Serguei Kaniovski wrote:

> Hi all,
>
> 1. How to construct a date from three variables year, month, and day,
> where all three are integers?

?ISOdate (and perhaps use as.Date on the result)

> 2. I have a dataframe by date and sector. I would like to add-up all
> entries for all variable with identical date and sector, replacing the
> original entries, i.e. emulate the STATA command "collapse (sum) var1
> var2 var3, by(date sector)".

?by

(I am not sure how you replace the original entries, as the result 
is far shorter.  If you mean that you want to replace each of the entries 
for date/sector by the sum for that date/sector use indexing, but this is 
much more commonly done for the mean.  As ever, an example would have 
helped clarify your intentions.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list