DF$date <- as.Date(paste(DF$day,DF$month,DF$year), "%d %m %Y")   # if 
4-figure year
aggregate(DF[c(var1, var2, var3)], DF[c(date, sector)], sum,  is.na=T)

Serguei Kaniovski a écrit :

>Hi all,
>
>1. How to construct a date from three variables year, month, and day,
>where all three are integers?
>
>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)".
>
>Thank you,
>Serguei Kaniovski
>
>______________________________________________
>[email protected] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>  
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to