Skip to content

simple class for circular objects such as hour, day of week, etc

License

Notifications You must be signed in to change notification settings

sainathadapa/circularObjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

circularObjs

This is a trivial implementation for creation of 'circular' objects such as time of the day, month, etc.

source('circularObj.R')
## R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
monthClass <- circularObj(list(month = month.abb), 'monthClass')

monthClass(list(month = 'Jan')) + 5
## $month
## [1] "Jun"
monthClass(list(month = 'Jan')) + 12
## $month
## [1] "Jan"
hourMinute <- circularObj(list(minute = 1:60, hour = 1:12), 'hourMinute')

hourMinute(list(hour = 10, minute = 25))
## $minute
## [1] 25
## 
## $hour
## [1] 10
hourMinute(list(hour = 10, minute = 25)) + 180
## $minute
## [1] 25
## 
## $hour
## [1] 1
hourMinute(list(hour = 10, minute = 25)) + (-180)
## $minute
## [1] 25
## 
## $hour
## [1] 7
hourMinute(list(hour = 10, minute = 25)) - 180
## $minute
## [1] 25
## 
## $hour
## [1] 7
dayTime <- circularObj(list(second = 1:60, minute = 1:60, hour = 1:24,
                            day = c('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')),
                       'dayTime')

dayTime(list(day = 'Sun', hour = 10, second = 25, minute = 10)) + 86400
## $second
## [1] 25
## 
## $minute
## [1] 10
## 
## $hour
## [1] 10
## 
## $day
## [1] "Mon"

About

simple class for circular objects such as hour, day of week, etc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages