value_convert {scribe} | R Documentation |
Simple conversions
Description
Convert character to data types
Usage
value_convert(x, to = default_convert)
scribe_convert(method = c("default", "evaluate", "none"))
Arguments
x |
A vector of character values |
to |
What to convert |
method |
The conversion method:
|
Details
to
can be one of several values. Firstly the default of default
calls several additional functions that attempt to resolve a transformation
from a character
vector to a different type. It is recommended for users
to enter their own specifications instead. Secondly, a function
(with a
single argument) can be passed which will then be applied directly to x
.
Third, a prototype value can be passed. This might be risky for special
types. Here, the values of mode()
, storage.mode()
, attributes()
, and
class()
are captured and reassigned from to
to x
. A special check is
implemented for factor
s to more safely convert. Lastly, NULL
will do
nothing and will simply return x
.
Value
-
value_convert()
: A parsed value fromx
-
scribe_convert()
: A function that takes a argumentx
and converts it
Examples
str(value_convert("2023-03-05", as.Date))
value_convert("a", factor(letters))