Re: [R] Detect and replace omitted data

2011-10-18 Thread David Winsemius
On Oct 18, 2011, at 2:53 PM, Dennis Murphy wrote: Prompted by David's xtabs() suggestion, one way to do what I think the OP wants is to * define day and unit as factors whose levels comprise the full range of desired values; * use xtabs(); * return the result as a data frame. Something like x

Re: [R] Detect and replace omitted data

2011-10-18 Thread Jonny Armstrong
Thanks you for the quick and helpful replies. Problem solved. Jonny On Tue, Oct 18, 2011 at 11:33 AM, David Winsemius wrote: > > On Oct 18, 2011, at 2:24 PM, Sarah Goslee wrote: > > Hi Jonny, >> >> On Tue, Oct 18, 2011 at 1:02 PM, Jonny Armstrong >> wrote: >> >>> I am analyzing the spatial distr

Re: [R] Detect and replace omitted data

2011-10-18 Thread Dennis Murphy
Prompted by David's xtabs() suggestion, one way to do what I think the OP wants is to * define day and unit as factors whose levels comprise the full range of desired values; * use xtabs(); * return the result as a data frame. Something like x <- data.frame( day = factor(rep(c(4, 6), each = 8),

Re: [R] Detect and replace omitted data

2011-10-18 Thread David Winsemius
On Oct 18, 2011, at 2:24 PM, Sarah Goslee wrote: Hi Jonny, On Tue, Oct 18, 2011 at 1:02 PM, Jonny Armstrong wrote: I am analyzing the spatial distribution of fish in a stream. The stream is divided into equally sized units, and the number of fish in each unit is counted. My problem is tha

Re: [R] Detect and replace omitted data

2011-10-18 Thread Trevor Davies
Here is one option: a<- data.frame(day=c(rep(4,8),rep(6,8)),unit= c((1:8),seq(2,16,2)),value=round(runif(16,1,34),0)) #approx your data b<- data.frame(day=c(rep(4,16),rep(6,16)),unit= 1:16) #fake df b1<-merge (a,b, by=c('day','unit'),all.y=T) b1$value[is.na(b1$value)]<-0

Re: [R] Detect and replace omitted data

2011-10-18 Thread Sarah Goslee
Hi Jonny, On Tue, Oct 18, 2011 at 1:02 PM, Jonny Armstrong wrote: > I am analyzing the spatial distribution of fish in a stream. The stream is > divided into equally sized units, and the number of fish in each unit is > counted. My problem is that my dataset is missing rows where the count in a >