shide-math {shide}R Documentation

Mathematical operations for jdate and jdatetime

Description

Math and Summary group of functions for jdate and jdatetime objects. Only methods for is.finite() and is.infinite() are provided and other functions from the groups, such as mean(), median() and summary() are not implemented.

Usage

## S3 method for class 'jdate'
vec_math(.fn, .x, ...)

## S3 method for class 'jdatetime'
vec_math(.fn, .x, ...)

Arguments

.fn

A mathematical function from the base package, as a string.

.x

A vector of jdate or jdatetime objects.

...

Additional arguments passed to .fn.

Details

vctrs implementation of Date and POSIXct does not include methods for is.finite() and is.infinite(). But these method are implemented in shide so that jdate and jdatetime vectors could be used as ggplot scales.

Value

For is.finite() and is.infinite(), a logical vector of the same length as x. Using all the other math and summary group generics will signal an error.

Examples

# Unlike a `Date` vector, `mean()` is not defined for a `jdate` vector
try(mean(c(jdate_now(), jdate_now() + 2)))

[Package shide version 0.2.1 Index]