[R-sig-ME] Aggregate binary response variable

Highland Statistics Ltd. highstat at highstat.com
Fri Dec 25 12:11:00 CET 2009


> Message: 2
> Date: Thu, 24 Dec 2009 12:33:21 +0000
> From: Graham Leask <grahamleask at btinternet.com>
> Subject: [R-sig-ME] Aggregate binary response variable
> To: r-sig-mixed-models at r-project.org
> Message-ID: <BE3C17F1-1940-471A-A80F-216621DCE35E at btinternet.com>
> Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes
>
> Dear list
>
> I have a response variable coded 0/1 i.e. a binary response. There are  
> 20,000 individual responses that I would like to aggregate into  
> numbers of each category (i.e. 0/1) by
> group (350 different groups) and by month (there are several hundred  
> responses per month.
>
> What is the simplest way to perform this operation in R?
>
>   


Hello Graham,

tapply is your best friend here.

There will be plenty of examples online...and if you can't find it..see 
Section 4.2 in our "Beginner's Guide to R" book...(and change mean by sum)

Happy New Year.
Alain

-- 


Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highstat at highstat.com
URL: www.highstat.com
URL: www.brodgar.com




More information about the R-sig-mixed-models mailing list