Sorry if this a simple question, I am fairly new to R and still trying to grasp some of these concepts. I am having problems doing automated age class advancements in R and I was wondering if I could possibly get some help as to how to address this.
Currently, I am attempting to use if-else statements to solve my problem but I feel that I am shooting in the dark on how to format it correctly. Basically, what I need is for my code to recognize the season of the observation, if the season is not three, then the output should be the original age class (if its the first observation) or the prior observation's age class.
If the season is 3, then I would need to have an age class advancement. For example, if the individual was a yearling in the prior observation, the next season 3 entry would shift the individual's age class from Yearling to Adult. But, if the individual was an adult, then the age class would remain the same.
Below is an example of what I would need the data to look like.
+----+--------+--------------------+----------------+
| ID | Season | Original Age Class | Desired Output |
+----+--------+--------------------+----------------+
| 1 | 1 | New_Born | New_Born |
| 1 | 2 | | New_Born |
| 1 | 3 | | Yearling |
| 1 | 4 | | Yearling |
| 1 | 1 | | Yearling |
| 1 | 2 | | Yearling |
| 1 | 3 | | Adult |
| 1 | 4 | | Adult |
| 1 | 1 | | Adult |
| 1 | 2 | | Adult |
+----+--------+--------------------+----------------+
I would appreciate any help with my problem and I thank you in advance.