Skip to content
Prev 75223 / 398502 Next

more on vector vs array

you could use something like this:

dat1 <- data.frame(station = rep(letters[1:5], 4), temp = 
round(rnorm(20, 15, 3)))
dat2 <- data.frame(station = letters[1:5], temp = round(rnorm(5, 15, 
4)))
################
dat <- merge(dat1, dat2, by = "station")
do.call("rbind", lapply(split(dat, dat$station), function(x){
        out <- x[x$temp.x > x$temp.y, ]
        if(nrow(out)) out else rep(NA, length(x))
    }))


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/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "alessandro carletti" <alxmilton at yahoo.it>
To: "rHELP" <R-help at stat.math.ethz.ch>
Sent: Tuesday, August 09, 2005 9:58 AM
Subject: [R] more on vector vs array