Skip to content
Prev 274796 / 398506 Next

Detect and replace omitted data

Hi Jonny,

On Tue, Oct 18, 2011 at 1:02 PM, Jonny Armstrong
<jonny5armstrong at gmail.com> wrote:
Thanks for the actual reproducible example.
Here's one option, though it may not be terribly concise:

all.samples <- expand.grid(day=unique(x[,"day"]), unit=1:16)
all.samples <- all.samples[order(all.samples[,"day"], all.samples[,"unit"]),]
x.final <- merge(x, all.samples, all.y=TRUE)
x.final[is.na(x.final[,"value"]), "value"] <- 0

Sarah