numericise: Numericise (or Numericize)

Description Usage Arguments Details Value Methods (by class) Examples

View source: R/numericise.R

Description

Coerce an R object to a numeric atomic object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
numericise(x, ...)

numericize(x, ...)

## S3 method for class 'logical'
numericise(x, ...)

## S3 method for class 'integer'
numericise(x, ...)

## S3 method for class 'double'
numericise(x, ...)

## S3 method for class 'factor'
numericise(x, ...)

## S3 method for class 'Date'
numericise(x, ...)

## S3 method for class 'POSIXct'
numericise(x, ...)

## S3 method for class 'hms'
numericise(x, ...)

## S3 method for class 'matrix'
numericise(x, ...)

## S3 method for class 'array'
numericise(x, ...)

## S3 method for class 'data.frame'
numericise(x, ...)

Arguments

x

An object.

...

Other arguments passed to methods.

Details

numericize() is an alias for numericise. If you want to implement a method for a class "foo", implement numericise.foo().

Value

A numeric atomic object.

Methods (by class)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# logical
numericise(TRUE)
numericise(matrix(c(TRUE, FALSE), nrow = 2))

# integer
numericise(2L)

# double
numericise(c(1, 3))

# factor
numericise(factor(c("c", "a")))

# Date
numericise(as.Date("1972-01-01"))

# POSIXct
numericise(as.POSIXct("1972-01-01", tz = "UTC"))

# hms
numericise(hms::as_hms("00:01:03"))

# matrix
numericise(matrix(TRUE))

# array
numericise(array(TRUE))

# data.frame
numericise(data.frame(
  logical = c(TRUE, FALSE, NA),
  integer = 1:3,
  numeric = c(4, 10, NA),
  factor = as.factor(c("c", "A", "green"))
))

extras documentation built on Oct. 23, 2020, 6:17 p.m.