Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Nov 12, 2024
1 parent 9cdf61c commit f246b88
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 101 deletions.
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

S3method(as.data.frame,TimeIntervals)
S3method(as.data.frame,TimeSeries)
S3method(end,TimeIntervals)
S3method(end,TimeSeries)
S3method(frequency,TimeSeries)
S3method(image,TimeSeries)
S3method(labels,TimeIntervals)
S3method(labels,TimeSeries)
S3method(length,TimeIntervals)
S3method(plot,TimeIntervals)
S3method(plot,TimeSeries)
S3method(start,TimeIntervals)
S3method(start,TimeSeries)
S3method(time,TimeSeries)
S3method(window,TimeSeries)
export(AD)
export(BC)
export(BCE)
Expand All @@ -30,6 +37,8 @@ export(fixed_to_CE)
export(fixed_to_b2k)
export(fixed_to_julian)
export(year_axis)
exportClasses(GregorianCalendar)
exportClasses(JulianCalendar)
exportClasses(RataDie)
exportClasses(TimeIntervals)
exportClasses(TimeScale)
Expand Down
5 changes: 2 additions & 3 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ NULL
#' @author N. Frerebeau
#' @family classes
#' @family calendar classes
#' @family gregorian era classes
#' @docType class
#' @aliases GregorianCalendar-class
#' @keywords internal
#' @exportClass GregorianCalendar
.GregorianCalendar <- setClass(
Class = "GregorianCalendar",
prototype = list(
Expand All @@ -67,7 +66,7 @@ NULL
#' @family calendar classes
#' @docType class
#' @aliases JulianCalendar-class
#' @keywords internal
#' @exportClass JulianCalendar
.JulianCalendar <- setClass(
Class = "JulianCalendar",
prototype = list(
Expand Down
3 changes: 3 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ setGeneric(
#' @param x A [`TimeSeries-class`] object.
#' @param calendar A [`TimeScale-class`] object specifying the target calendar
#' (see [calendar()]). If `NULL` (the default), *rata die* are returned.
#' @param ... Currently not used.
#' @return
#' A [`numeric`] vector of decimal years (if `calendar` is not `NULL`).
#' @example inst/examples/ex-series.R
Expand All @@ -578,6 +579,7 @@ NULL
#' @param x A [`TimeSeries-class`] object.
#' @param calendar A [`TimeScale-class`] object specifying the target calendar
#' (see [calendar()]). If `NULL` (the default), *rata die* are returned.
#' @param ... Currently not used.
#' @return
#' A [`numeric`] vector of decimal years (if `calendar` is not `NULL`).
#' @example inst/examples/ex-series.R
Expand All @@ -598,6 +600,7 @@ NULL
#' period of interest.
#' @param end A length-one [`numeric`] vector specifying the end time of the
#' period of interest.
#' @param ... Currently not used.
#' @return
#' A [`TimeSeries-class`] object.
#' @example inst/examples/ex-window.R
Expand Down
19 changes: 11 additions & 8 deletions R/calendar.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ setMethod(
)

#' @export
#' @describeIn gregorian Gregorian BP era.
#' @rdname gregorian
BP <- function(...) {
.GregorianCalendar(
label = tr_("BP"),
Expand All @@ -35,7 +35,7 @@ BP <- function(...) {
}

#' @export
#' @describeIn gregorian Gregorian b2k era.
#' @rdname gregorian
b2k <- function(...) {
.GregorianCalendar(
label = tr_("b2k"),
Expand All @@ -46,7 +46,7 @@ b2k <- function(...) {
}

#' @export
#' @describeIn gregorian Gregorian BC era.
#' @rdname gregorian
BC <- function(...) {
.GregorianCalendar(
label = tr_("BC"),
Expand All @@ -56,7 +56,7 @@ BC <- function(...) {
}

#' @export
#' @describeIn gregorian Gregorian BCE era.
#' @rdname gregorian
BCE <- function(...) {
.GregorianCalendar(
label = tr_("BCE"),
Expand All @@ -66,7 +66,7 @@ BCE <- function(...) {
}

#' @export
#' @describeIn gregorian Gregorian AD era.
#' @rdname gregorian
AD <- function(...) {
.GregorianCalendar(
label = tr_("AD"),
Expand All @@ -75,7 +75,7 @@ AD <- function(...) {
}

#' @export
#' @describeIn gregorian Gregorian CE era.
#' @rdname gregorian
CE <- function(...) {
.GregorianCalendar(
label = tr_("CE"),
Expand All @@ -84,7 +84,7 @@ CE <- function(...) {
}

# @export
# @describeIn gregorian Gregorian AUC era.
# @rdname gregorian
# AUC <- function(...) {
# .GregorianCalendar(
# label = tr_("AUC"),
Expand All @@ -104,7 +104,10 @@ J <- function(...) {
}

# Mutators =====================================================================
calendar_year <- function(object) object@year
calendar_year <- function(object) {
if (is.null(object)) return(NULL)
object@year
}

## Getters ---------------------------------------------------------------------
#' @export
Expand Down
24 changes: 12 additions & 12 deletions R/subset.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ setMethod(
)

# Window =======================================================================
#' @export
#' @method window TimeSeries
window.TimeSeries <- function(x, start = NULL, end = NULL, ...) {
if (is.null(start)) start <- start(x)
if (is.null(end)) end <- end(x)
years <- time(x)

i <- which(years >= start & years <= end)
x[i, , , drop = FALSE]
}

#' @export
#' @rdname window
#' @aliases window,TimeSeries-method
setMethod(
f = "window",
signature = "TimeSeries",
definition = function(x, start = NULL, end = NULL) {
if (is.null(start)) start <- start(x)
if (is.null(end)) end <- end(x)
years <- time(x)

i <- which(years >= start & years <= end)
x[i, , , drop = FALSE]
}
)
setMethod("window", "TimeSeries", window.TimeSeries)
102 changes: 52 additions & 50 deletions R/time.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,78 @@
#' @include AllGenerics.R
NULL

#' @export
#' @method start TimeSeries
start.TimeSeries <- function(x, calendar = NULL, ...) {
z <- min(x@.Time)
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}

#' @export
#' @rdname start
#' @aliases start,TimeSeries-method
setMethod(
f = "start",
signature = "TimeSeries",
definition = function(x, calendar = NULL) {
z <- min(x@.Time)
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}
)
setMethod("start", "TimeSeries", start.TimeSeries)

#' @export
#' @method start TimeIntervals
start.TimeIntervals <- function(x, calendar = NULL, ...) {
z <- x@.Start
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}

#' @export
#' @rdname start
#' @aliases start,TimeIntervals-method
setMethod(
f = "start",
signature = "TimeIntervals",
definition = function(x, calendar = NULL) {
z <- x@.Start
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}
)
setMethod("start", "TimeIntervals", start.TimeIntervals)

#' @export
#' @method end TimeSeries
end.TimeSeries <- function(x, calendar = NULL, ...) {
z <- max(x@.Time)
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}

#' @export
#' @rdname start
#' @aliases end,TimeSeries-method
setMethod(
f = "end",
signature = "TimeSeries",
definition = function(x, calendar = NULL) {
z <- max(x@.Time)
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}
)
setMethod("end", "TimeSeries", end.TimeSeries)

#' @export
#' @method end TimeIntervals
end.TimeIntervals <- function(x, calendar = NULL, ...) {
z <- x@.End
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}

#' @export
#' @rdname start
#' @aliases end,TimeIntervals-method
setMethod(
f = "end",
signature = "TimeIntervals",
definition = function(x, calendar = NULL) {
z <- x@.End
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}
)
setMethod("end", "TimeIntervals", end.TimeIntervals)

#' @export
#' @method time TimeSeries
time.TimeSeries <- function(x, calendar = NULL, ...) {
z <- x@.Time
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}

#' @export
#' @rdname time
#' @aliases time,TimeSeries-method
setMethod(
f = "time",
signature = "TimeSeries",
definition = function(x, calendar = NULL) {
z <- x@.Time
if (is.null(calendar)) return(z)
as_year(z, calendar = calendar, decimal = TRUE)
}
)
setMethod("time", "TimeSeries", time.TimeSeries)

#' @export
#' @method frequency TimeSeries
frequency.TimeSeries <- function(x, ...) {
mean(abs(1 / diff(time(x))))
}

#' @export
#' @rdname time
#' @aliases frequency,TimeSeries-method
setMethod(
f = "frequency",
signature = "TimeSeries",
definition = function(x) mean(abs(1 / diff(time(x))))
)
setMethod("frequency", "TimeSeries", frequency.TimeSeries)
2 changes: 0 additions & 2 deletions man/GregorianCalendar-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/JulianCalendar-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions man/gregorian.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/start.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions man/subset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f246b88

Please sign in to comment.