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

2011-01-31 Thread Ista Zahn
Hi Sarah, Here is how I would do it. Not elegent, but fairly transparent, and it seems to give the desired result. DF <- as.data.frame(DF) pick.value <- function(x){ if(0 %in% x$PA1) { x <- x[x$PA1 == 0,] } x <- x[x$Area == max(x$Area, na.rm=T),] S <- x[sample(1:nrow(x),

[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(

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

2011-01-31 Thread Joshua Wiley
Dear Sarah, What you will need is a series of logical conditions. ?Logic or ?"|" should pull up the documentation on the logical operators available to use. Because this list does not accept HTML emails (see the posting guide), your data frame did not come through in any coherent form. Can you

[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