Orbit code in R