R365: Day 44 – Cumulative Index with Upper and Lower Boundaries

This topic sounds SUPER specific, when I was writing that title I was like “no one is going to read this, oh well.”

BUT! What this is useful for is setting up an index where you know that the index should not go above or below a certain point.

Yeah…thats pretty specific…

BUT it is useful in plant pathology for calculating the Gubler-Thomas (GT) powdery mildew risk index. I need to program the index for work.

Here is some example script for how to set upper and lower thresholds using iflese() statements

#set up a vector with data
#set up a function, name it whatever
 #have one of your functions do what you want;
 #this function checks if a is divisible by 3, if yes, sqrt(a), if no, (a)^4
 #this checks if the value is over 10
 #this checks if the value is under -10
#run the function
#...and plot it out

Then see the beautiful plot:




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s