[R] Error loop: missing value where TRUE/FALSE needed

2011-02-25 Thread sarah bauduin
Dear R-help community, I often get this error "missing value where TRUE/FALSE needed" when I'm doing some loops, like with this one for (i in 1:nrow(survey)) { if (survey[i,7]==survey[i,3]) {survey[i,14]<-survey[i,6]} else if(survey[i,11]==0 && survey[i,12]==0) {survey[i,14]<-sur

[R] Select rows with distinct values in a column and other conditions

2011-01-31 Thread sarah bauduin
My dataframe looks like this one: SightingID<-c(2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013)PA1<-c(0,1,0,0,1,1,1,1,0,0,-99,1,1)PA2<-c(1,NA,1,1,NA,-99,-99,NA,1,1,1,NA,NA)PlotID<-c(1,1,2,2,2,3,3,3,4,4,4,4,5)Area<-c(0.2,0.3,0.25,0.2,0.3,0.4,0.3,0.35,0.4,0.4,0.5,0.3,0.2)DF<-cbind(

[R] Select rows with distinct values in a column and other conditions

2011-01-31 Thread sarah bauduin
My data frame looks like: SightingID PA1 PA2 PlotID InOverlap Area12001 1 -99392 Y0.222002 1 -99388 Y0.2532008 1 NA104 N0.3442010 1 NA 71 N 0.1852012 1 NA 6