addmargins(table(df)) On 14/11/06, Michael Graber <[EMAIL PROTECTED]> wrote: > Dear R List, > > I am a new to R, so my question may be easy to answer for you: > > I have a dataframe, for example: > > df<-data.frame(loc=c("A","B","A","A","A"), > year=as.numeric(c("1970","1970","1970","1976","1980"))) > > and I want to create the following table without using loops: > > 1970-74 ; 1975-79 ; 1980-85; rowsum > A 2 1 1 4 > B 1 0 0 1 > colsum 3 1 1 5 > > so that the frequencies of df$loc are shown in the table for different > time intervals. > > Thanks in advance for any hint, > > Michael Graber > > ______________________________________________ > R-help@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 > and provide commented, minimal, self-contained, reproducible code. >
-- ================================= David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.