Skip to content
Prev 348467 / 398500 Next

double if else

The corrected version is below. I found an error.


areaKM<-7500 #test for 7500 and 30000

dat<-data.frame(x=1:30,y=31:60,cellvalue=c(5,6,7,rep(10,10),rep(20,17)))#fake
data
cells<-unique(as.numeric(dat$cellvalue))#find unique cellvalues
pres100km <- list() #empty list

for (ii in 1:length(cells)){ #make loop to find 100km cells with at least
30% of 10km cells being within the alpha hull,
  #or if area of alpha hull less that 15000km2 keep all 100km2 cells where
points fall
  subdat<-subset(dat,cellvalue ==cells[ii])
  if (areaKM >= 15000) {
    if (nrow(subdat) < 30) {
      next
    } else {
      pres100km[[ii]]<-cells[ii] #100kmcells >= 30% coverage of 10kmcells
    }
  } else {
    if(nrow(subdat) < 5) {
      next
    } else {
      pres100km[[ii]]<-cells[ii] #more than 5 obs
    }
  }
}



On Mon, Feb 23, 2015 at 1:54 PM, Daisy Englert Duursma <
daisy.duursma at gmail.com> wrote: