[R] Two quick questions

ronggui ronggui.huang at gmail.com
Fri Mar 3 10:34:08 CET 2006

The second question:

use auto
collapse (sum)  price mpg,by( make foreign)

if you have the same data set named auto in R

whatyouwant <- aggregate(auto[,c("mpg","price")],by=auto[,c("make","foreign")],FUN=sum)

2006/3/3, Serguei Kaniovski <kaniovsk at wsr.ac.at>:
> 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
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Deparment of Sociology
Fudan University

More information about the R-help mailing list