This is probably not the most elegant way, but it works: basically, I'm recreating the full data vector from the information contained in the data.frame, then finding the median of that. Writing a function to do it lets me use apply
to quickly do it to each row of the data.frame.
find.median <- function(x) {
full.x <- rep(x[5:7],times=x[2:4])
return(median(full.x))
}
> apply(data,1,find.median)
[1] 19.5 78.0 14.0 31.0 29.0