Skip to content
Prev 78071 / 398502 Next

reshaping data?

you could use something like this (but maybe there are better 
proposals):

dat <- data.frame(g = rep(letters[1:3], each = 5), val = runif(15))

out <- do.call(rbind, lapply(split(dat$val, dat$g), function(x){
    f <- factor(findInterval(x, vec = seq(0, 1, 0.1)), levels = 1:10)
    table(f)
    }))
colnames(out) <- seq(0.1, 1, 0.1)
out


I hope it helps.

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://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Karin Lagesen" <karin.lagesen at medisin.uio.no>
To: <r-help at r-project.org>
Sent: Thursday, September 29, 2005 3:16 PM
Subject: [R] reshaping data?
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm