View source: R/stabilize_dbl.R
| stabilize_dbl | R Documentation |
to_dbl() checks whether an argument can be coerced to double
without losing information, returning it silently if so. Otherwise an
informative error message is signaled.
stabilize_dbl() can check more details about the argument, but is slower
than to_dbl().
stabilize_dbl_scalar() and to_dbl_scalar() are optimized to check for
length-1 double vectors.
stabilize_dbl(
x,
...,
allow_null = TRUE,
allow_na = TRUE,
coerce_character = TRUE,
coerce_factor = TRUE,
min_size = NULL,
max_size = NULL,
min_value = NULL,
max_value = NULL,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
stabilize_dbl_scalar(
x,
...,
allow_null = TRUE,
allow_zero_length = TRUE,
allow_na = TRUE,
coerce_character = TRUE,
coerce_factor = TRUE,
min_value = NULL,
max_value = NULL,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
to_dbl(
x,
...,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
## S3 method for class ''NULL''
to_dbl(x, ..., allow_null = TRUE, x_arg = caller_arg(x), call = caller_env())
## S3 method for class 'character'
to_dbl(
x,
...,
coerce_character = TRUE,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
## S3 method for class 'factor'
to_dbl(
x,
...,
coerce_factor = TRUE,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
to_dbl_scalar(
x,
...,
allow_null = TRUE,
allow_zero_length = TRUE,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
x |
The argument to stabilize. |
... |
Arguments passed to methods. |
allow_null |
|
allow_na |
|
coerce_character |
|
coerce_factor |
|
min_size |
|
max_size |
|
min_value |
|
max_value |
|
x_arg |
|
call |
|
x_class |
|
allow_zero_length |
|
The argument as a double.
to_dbl(1:10)
to_dbl("1.1")
to_dbl(1 + 0i)
to_dbl(NULL)
try(to_dbl("a"))
try(to_dbl("1.1", coerce_character = FALSE))
to_dbl_scalar("1.1")
try(to_dbl_scalar(1:10))
stabilize_dbl(1:10)
stabilize_dbl("1.1")
stabilize_dbl(1 + 0i)
stabilize_dbl(NULL)
try(stabilize_dbl(NULL, allow_null = FALSE))
try(stabilize_dbl(c(1.1, NA), allow_na = FALSE))
try(stabilize_dbl(letters))
try(stabilize_dbl("1.1", coerce_character = FALSE))
try(stabilize_dbl(factor(c("1.1", "a"))))
try(stabilize_dbl(factor("1.1"), coerce_factor = FALSE))
try(stabilize_dbl(1:10, min_value = 3.5))
try(stabilize_dbl(1:10, max_value = 7.5))
stabilize_dbl_scalar(1.0)
stabilize_dbl_scalar("1.1")
try(stabilize_dbl_scalar(1:10))
stabilize_dbl_scalar(NULL)
try(stabilize_dbl_scalar(NULL, allow_null = FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.