Skip to Content
R Programming By Example
book

R Programming By Example

by Omar Trejo Navarro
December 2017
Beginner to intermediate
470 pages
12h 29m
English
Packt Publishing
Content preview from R Programming By Example

Starting simple with timestamps using S3 classes

We start by programming a class that has no external dependencies, the TimeStamp. We will use this class to indicate dates and times together in a single string in the format YYYY-MM-DD-HH-mm, where MM means month and mm means minutes. As you can see, with one of these strings you have the information time and date, and it will be stored with the data we retrieve from time-series for analysis in Chapter 9, Implementing an Efficient Simple Moving Average.

Our TimeStamp class will be implemented using S3. As you can see, we include the lubridate package to do some heavy lifting for us when transforming dates, and provide a constructor that checks whether or not the string being passed is a valid ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Efficient R Programming

Efficient R Programming

Colin Gillespie, Robin Lovelace
R Programming

R Programming

Jared P. Lander

Publisher Resources

ISBN: 9781788292542Supplemental Content