My data frame looks like:
   SightingID PA1 PA2 PlotID InOverlap Area1        2001   1 -99    392         
Y        0.22        2002   1 -99    388         Y        0.253        2008   1 
 NA    104         N        0.344        2010   1  NA     71         N        
0.185        2012   1  NA     61         N         0.166        2013   1  NA    
 61         N         0.227        2014   1  NA     62         N          0.258 
       2015   1  NA     63         N         0.199        2016   1  NA     63   
      N          0.310       2017   1  NA     63         N         0.2511       
2018   1  NA     63         N        0.2612       2019   1  NA     63         N 
        0.2613       2020   1  NA     64         N         0.33  14       2021  
 1  NA     64         N         0.4215       2022   1  NA     85         N      
   0.0816       2023   0   1     95         Y           0.11 17       2024   1  
NA     93         N         0.2318       2025   1  NA    106         N         
0.419       2026   1  NA    134 !
         N        0.28
The only unique values in the data frame are the SightingID. I would like to 
obtain a new data frame with unique PlotID values based on several conditions:- 
return the row if there is only one SightingID for the PlotID- if there is 
several SightingID for the same PlotID value:     -select first the SightingID 
for which PA1=0,      if there is several SightingID with PA1=0 for the same 
PlotID select the one with the highest value in Area,     if there is several 
SightingID with PA1=0 for the same PlotID with the highest value for Area 
select one SightingID at random     - select the SightingID for which PA1 is 
not equal to 0 based on the highest value in Area (and at random if there are 
several with the highest value in Area)
I have no idea how to do that, can someone help me please ?     Sarah           
                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to