5) Perform Date Arithmetic.

This Blog entry is from the Loading and Shaping section in Learn R.

Upon a date object, having been created it is possible to perform arithmetic on the dates.  In this example one day is going to be added to the dates in the vector.  To add a day to each value in vector type:

DatesPlusOne <- Dates + 1

a-script-to-perform-date-math-in-r.png

Run the line of script to console:

date-math-written-out-to-the-r-console.png

Write the new vector out by typing:

a-script-to-write-out-a-date-vector-after-adding-a-value-in-r.png

Run the line of script to console:

dates-written-out-to-the-r-console.png

It can be observed that a day has been subtracted from the Dates vector.