Im running several loops for my project. Im trying to make a "if" statement to do some calculations based on a sample. The dataset consists of :
ID Height Diameter Rank
(Where rank is based on diameter. Meaning rank 1 is the largest and rank 2 is the second largest etc.)
Im then taking a sample from this dataset.
What I would like to do is:
if (rows with rank 1 or 2 is found in the sample) #Do some calculations based on that single observation
OR
if(rows with rank 1 and 2 is found in the sample) #Do some calculations based on the two observations.
else (if neither of the "if" statements are true) #Do some calculations
Hopefully I was able to explain to problem Im having.
Thanks for any help in advance!
I hope this will sufficiently illustrate the logic of doing what you want in code. Notice that the first if test is the most restrictive, both 1 and 2 are in the sample. I did not really do any calculation but I treated the rows differently depending on there Rank. For a calculation you could use the filter() function to grab the row(s) with the desired Rank.