Aan de slagGa gratis aan de slag

Arithmetic with timespans

You can add and subtract timespans to create different length timespans, and even multiply them by numbers. For example, to create a duration of three days and three hours you could do: ddays(3) + dhours(3), or 3*ddays(1) + 3*dhours(1) or even 3*(ddays(1) + dhours(1)).

There was an eclipse over North America on 2017-08-21 at 18:26:40. It's possible to predict the next eclipse with similar geometry by calculating the time and date one Saros in the future. A Saros is a length of time that corresponds to 223 Synodic months, a Synodic month being the period of the Moon's phases, a duration of 29 days, 12 hours, 44 minutes and 3 seconds.

Do just that in this exercise!

Deze oefening maakt deel uit van de cursus

Working with Dates and Times in R

Cursus bekijken

Oefeninstructies

  • Create a duration corresponding to one Synodic Month: 29 days, 12 hours, 44 minutes and 3 seconds.
  • Create a duration corresponding to one Saros by multiplying synodic by 223.
  • Add saros to eclipse_2017 to predict the next eclipse.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Time of North American Eclipse 2017
eclipse_2017 <- ymd_hms("2017-08-21 18:26:40")

# Duration of 29 days, 12 hours, 44 mins and 3 secs
synodic <- ___

# 223 synodic months
saros <- ___

# Add saros to eclipse_2017

Code bewerken en uitvoeren