[R] putting stuff into bins...
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Tue Sep 26 14:00:20 CEST 2006
probably a combination of cut() and tapply() could be of help in this
case, e.g.,
x <- rnorm(100)
tapply(x, cut(x, -4:4), mean)
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Federico Calboli" <f.calboli at imperial.ac.uk>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, September 26, 2006 1:44 PM
Subject: [R] putting stuff into bins...
> Hi All,
>
> I have a vector of data, a vector of bin breakpoints and I want to
> put my data
> in the bins and then extract fanciful informations like the mean
> value of each bin.
>
> I know I can write my own function, but I would have thought that R
> should have
> somewhere a function that took as arguments something like (data,
> breaks, what
> to do with the data in the bins). I surey could not find it trawling
> the R-help
> archives though.
>
> If such a function exists I'd be grateful to anyone pointing it out
> to me.
>
> Cheers,
>
> Fede
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Public Health
> Imperial College, St Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list