Finite States Machine concepts are usually implemented under Object Oriented Programming (OOP) languages, for example using Java language, based on the State pattern defined in GOF (refers to the book: "Design Patterns").
R provides several mechanisms to simulate the OO paradigm, let's apply S4 Object System for implementing this pattern.