| Title: | Display Idiomatic Code to Construct Most R Objects |
|---|---|
| Description: | Prints code that can be used to recreate R objects. In a sense it is similar to 'base::dput()' or 'base::deparse()' but 'constructive' strives to use idiomatic constructors. |
| Authors: | Antoine Fabri [aut, cre], Kirill Müller [ctb] (ORCID: <https://orcid.org/0000-0002-1416-3412>), Jacob Scott [ctb], cynkra GmbH [fnd] (ROR: <https://ror.org/0335t7e62>) |
| Maintainer: | Antoine Fabri <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.3.0 |
| Built: | 2026-10-17 04:46:14 UTC |
| Source: | https://github.com/cynkra/constructive |
Exported for custom constructor design. If recurse is TRUE (default), we
recurse to construct args and insert their construction code in a fun(...) call returned
as a character vector. If args already contains code rather than object to
construct one should set recurse to FALSE.
.cstr_apply( args, fun = "list", ..., trailing_comma = FALSE, recurse = TRUE, implicit_names = FALSE, new_line = TRUE, one_liner = FALSE, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE ).cstr_apply( args, fun = "list", ..., trailing_comma = FALSE, recurse = TRUE, implicit_names = FALSE, new_line = TRUE, one_liner = FALSE, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE )
args |
A list of arguments to construct recursively, or code if |
fun |
The function name to use to build code of the form "fun(...)" |
... |
Options passed recursively to the further methods |
trailing_comma |
Boolean. Whether to leave a trailing comma after the last argument if
the code is multiline, some constructors allow it (e.g. |
recurse |
Boolean. Whether to recursively generate the code to construct |
implicit_names |
When data is provided, compress calls of the form |
new_line |
Boolean. Forwarded to |
one_liner |
Boolean. Whether to return a one line call. |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
A character vector of code
a <- 1 .cstr_apply(list(a=a), "foo") .cstr_apply(list(a=a), "foo", data = list(a=1)) .cstr_apply(list(a=a), "foo", data = list(a=1), implicit_names = TRUE) .cstr_apply(list(b=a), "foo", data = list(a=1), implicit_names = TRUE) .cstr_apply(list(a="c(1,2)"), "foo") .cstr_apply(list(a="c(1,2)"), "foo", recurse = FALSE)a <- 1 .cstr_apply(list(a=a), "foo") .cstr_apply(list(a=a), "foo", data = list(a=1)) .cstr_apply(list(a=a), "foo", data = list(a=1), implicit_names = TRUE) .cstr_apply(list(b=a), "foo", data = list(a=1), implicit_names = TRUE) .cstr_apply(list(a="c(1,2)"), "foo") .cstr_apply(list(a="c(1,2)"), "foo", recurse = FALSE)
Exported for custom constructor design. This function allows combining independent checks so information is given about
all failing checks rather than the first one. All parameters except ... are
forwarded to rlang::abort()
.cstr_combine_errors( ..., class = NULL, call, header = NULL, body = NULL, footer = NULL, trace = NULL, parent = NULL, use_cli_format = NULL, .internal = FALSE, .file = NULL, .frame = parent.frame(), .trace_bottom = NULL ).cstr_combine_errors( ..., class = NULL, call, header = NULL, body = NULL, footer = NULL, trace = NULL, parent = NULL, use_cli_format = NULL, .internal = FALSE, .file = NULL, .frame = parent.frame(), .trace_bottom = NULL )
... |
check expressions |
class |
Subclass of the condition. |
call |
The execution environment of a currently running
function, e.g. You only need to supply Can also be For more information about error calls, see Including function calls in error messages. |
header |
An optional header to precede the errors |
body, footer
|
Additional bullets. |
trace |
A |
parent |
Supply
For more information about error calls, see Including contextual information with error chains. |
use_cli_format |
Whether to format If set to |
.internal |
If |
.file |
A connection or a string specifying where to print the
message. The default depends on the context, see the |
.frame |
The throwing context. Used as default for
|
.trace_bottom |
Used in the display of simplified backtraces
as the last relevant call frame to show. This way, the irrelevant
parts of backtraces corresponding to condition handling
( |
Returns NULL invisibly, called for side effects.
Exported for custom constructor design. .cstr_construct() is basically a
naked construct(), without the checks, the style, the object post processing etc...
.cstr_construct(x, ..., data = NULL, classes = NULL).cstr_construct(x, ..., data = NULL, classes = NULL)
x |
An object, for |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
classes |
A character vector of classes for which to use idiomatic
constructors when available, we can provide a package instead of all its
classes, in the "{pkg}" form, and we can use a minus sign (inside the quotes)
to exclude rather than include. By default we use idiomatic constructors
whenever possible. The special values |
A character vector
Exported for custom constructor design.
.cstr_options(class, ...).cstr_options(class, ...)
class |
A string. An S3 class. |
... |
Options to set |
An object of class c(paste0("constructive_options_", class), "constructive_options")
Exported for custom constructor design.
.cstr_pipe(x, y, ..., pipe = NULL, one_liner = FALSE, indent = TRUE).cstr_pipe(x, y, ..., pipe = NULL, one_liner = FALSE, indent = TRUE)
x |
A character vector. The code for the left hand side call. |
y |
A character vector. The code for the right hand side call. |
... |
Implemented to collect unused arguments forwarded by the dots of the caller environment. |
pipe |
A string. The pipe to use, |
one_liner |
A boolean. Whether to paste |
indent |
A boolean. Whether to indent |
A character vector
.cstr_pipe("iris", "head(2)", pipe = "magrittr", one_liner = FALSE) .cstr_pipe("iris", "head(2)", pipe = "magrittr", one_liner = TRUE).cstr_pipe("iris", "head(2)", pipe = "magrittr", one_liner = FALSE) .cstr_pipe("iris", "head(2)", pipe = "magrittr", one_liner = TRUE)
Exported for custom constructor design. In the general case an object might have more attributes than given by the idiomatic
construction. .cstr_repair_attributes() sets some of those attributes and ignores
others.
.cstr_repair_attributes( x, code, ..., ignore = NULL, idiomatic_class = NULL, remove = NULL, flag_s4 = TRUE, repair_names = FALSE ).cstr_repair_attributes( x, code, ..., ignore = NULL, idiomatic_class = NULL, remove = NULL, flag_s4 = TRUE, repair_names = FALSE )
x |
The object to construct |
code |
The code constructing the object before attribute repair |
... |
Forwarded to |
ignore |
The attributes that shouldn't be repaired, i.e. we expect them
to be set by the constructor already in |
idiomatic_class |
The class of the objects that the constructor produces,
if |
remove |
Attributes that should be removed, should rarely be useful. |
flag_s4 |
Boolean. Whether to use |
repair_names |
Boolean. Whether to repair the |
A character vector
Exported for custom constructor design. Generally called through .cstr_apply().
.cstr_wrap(args, fun, new_line = FALSE).cstr_wrap(args, fun, new_line = FALSE)
args |
A character vector containing the code of arguments. |
fun |
A string. The name of the function to use in the function call.
Use |
new_line |
Boolean. Whether to insert a new line between |
A character vector.
This is designed to be used in constructed output. The parents and ... arguments
are not processed and only used to display additional information. If used on
an improper memory address it will either fail (most likely) or the output
will be erratic.
.env(address, parents = NULL, ...).env(address, parents = NULL, ...)
address |
Memory address of the environment |
parents, ...
|
ignored |
The environment that the memory address points to.
Base R doesn't provide utilities to build or manipulate external pointers
(objects of type "externalptr"), so we provide our own.
Objects defined with .xptr() are not stable across sessions,
.xptr(address).xptr(address)
address |
Memory address |
The external pointer (type "externalptr") that the memory address points to.
Builds options that will be passed to waldo::compare() down the line.
compare_options( ignore_srcref = TRUE, ignore_attr = FALSE, ignore_function_env = FALSE, ignore_formula_env = FALSE )compare_options( ignore_srcref = TRUE, ignore_attr = FALSE, ignore_function_env = FALSE, ignore_formula_env = FALSE )
ignore_srcref |
Ignore differences in function |
ignore_attr |
Ignore differences in specified attributes?
Supply a character vector to ignore differences in named attributes.
By default the For backward compatibility with |
ignore_function_env, ignore_formula_env
|
Ignore the environments of
functions and formulas, respectively? These are provided primarily for
backward compatibility with |
A list
construct() builds the code to reproduce one object,
construct_multi() builds the code to reproduce objects stored in a named
list or environment.
construct( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL ) construct_multi( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL, include_dotted = TRUE )construct( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL ) construct_multi( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL, include_dotted = TRUE )
x |
An object, for |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
pipe |
Which pipe to use, either |
check |
Boolean. Whether to check if the created code reproduces the object
using |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
pedantic_encoding |
Boolean. Whether to mark strings with the "unknown" encoding rather than an explicit native encoding ("UTF-8" or "latin1") when it's necessary to reproduce the binary representation exactly. This detail is normally of very little significance. The reason why we're not pedantic by default is that the constructed code might be different in the console and in snapshot tests and reprexes due to the latter rounding some angles, and it would be confusing for users. |
compare |
Parameters passed to |
one_liner |
Boolean. Whether to collapse the output to a single line of code. |
template |
A list of constructive options built with |
classes |
A character vector of classes for which to use idiomatic
constructors when available, we can provide a package instead of all its
classes, in the "{pkg}" form, and we can use a minus sign (inside the quotes)
to exclude rather than include. By default we use idiomatic constructors
whenever possible. The special values |
include_dotted |
Whether to include names starting with dots, this includes
|
construct_multi() recognizes promises (also called lazy bindings),
this means that for instance construct_multi(environment()) can be called
when debugging a function and will construct unevaluated arguments using
delayedAssign().
An object of class 'constructive'.
Constructive options provide a way to customize the output of 'construct()'. We can provide calls to 'opts_*()' functions to the '...' argument. Each of these functions targets a specific type or class and is documented on its own page.
opts_array(constructor = c("array", "next"), ...)
opts_AsIs(constructor = c("I", "next"), ...)
opts_atomic(..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE)
opts_bbox(constructor = c("st_bbox", "next"), ...)
opts_bibentry(constructor = c("bibentry", "next"), ...)
opts_blob(constructor = c("blob", "next"), ...)
opts_character(constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, multiline = FALSE)
opts_citationFooter(constructor = c("citFooter", "next"), ...)
opts_citationHeader(constructor = c("citHeader", "next"), ...)
opts_classGeneratorFunction(constructor = c("setClass"), ...)
opts_classPrototypeDef(constructor = c("prototype"), ...)
opts_classRepresentation(constructor = c("getClassDef"), ...)
opts_clock_duration(constructor = c("duration", "next", "list"), ...)
opts_clock_iso_year_week_day(constructor = c("iso_year_week_day", "next", "list"), ...)
opts_clock_naive_time(constructor = c("as_naive_time", "next", "list"), ...)
opts_clock_sys_time(constructor = c("as_sys_time", "next", "list"), ...)
opts_clock_weekday(constructor = c("weekday", "next", "integer"), ...)
opts_clock_year_day(constructor = c("year_day", "next", "list"), ...)
opts_clock_year_month_day(constructor = c("year_month_day", "next", "list"), ...)
opts_clock_year_month_weekday(constructor = c("year_month_weekday", "next", "list"), ...)
opts_clock_year_quarter_day(constructor = c("year_quarter_day", "next", "list"), ...)
opts_clock_year_week_day(constructor = c("year_week_day", "next", "list"), ...)
opts_clock_zoned_time(constructor = c("as_zoned_time", "next", "list"), ...)
opts_col_spec(constructor = c("cols", "next", "list"), ...)
opts_collector(constructor = c("col", "next", "list"), ...)
opts_complex(constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE)
opts_constructive_options(constructor = c("opts", "next"), ...)
opts_CoordCartesian(constructor = c("default", "coord_cartesian", "next", "environment"), ...)
opts_CoordFixed(constructor = c("coord_fixed", "next", "environment"), ...)
opts_CoordFlip(constructor = c("coord_flip", "next", "environment"), ...)
opts_CoordMap(constructor = c("coord_map", "next", "environment"), ...)
opts_CoordMunch(constructor = c("coord_munch", "next", "environment"), ...)
opts_CoordPolar(constructor = c("coord_polar", "next", "environment"), ...)
opts_CoordQuickmap(constructor = c("coord_quickmap", "next", "environment"), ...)
opts_CoordRadial(constructor = c("coord_radial", "next"), ...)
opts_CoordSf(constructor = c("coord_sf", "next", "environment"), ...)
opts_CoordTrans(constructor = c("coord_trans", "next", "environment"), ...)
opts_CoordTransform(constructor = c("coord_transform", "next"), ...)
opts_crs(constructor = c("st_crs", "next"), ...)
opts_data.frame(constructor = c("data.frame", "read.table", "next", "list"), ..., recycle = TRUE)
opts_data.table(constructor = c("data.table", "next", "list"), ..., selfref = FALSE, recycle = TRUE)
opts_Date(constructor = c("as.Date", "as_date", "date", "new_date", "as.Date.numeric", "as_date.numeric", "next", "double"), ..., origin = "1970-01-01")
opts_date_names(constructor = c("date_names_lang", "date_names", "next", "list"), ...)
opts_denseMatrix(constructor = c("Matrix", "next"), ...)
opts_diagonalMatrix(constructor = c("Diagonal", "next"), ...)
opts_difftime(constructor = c("as.difftime", "next"), ...)
opts_dist(constructor = c("as.dist", "next"), ...)
opts_dm(constructor = c("dm", "next", "list"), ...)
opts_dots(constructor = c("default"), ...)
opts_double(constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE)
opts_Duration(constructor = c("default", "dseconds", "duration", "next"), ...)
opts_ecdf(constructor = c("ecdf", "next"), ...)
opts_element_blank(constructor = c("element_blank", "next", "list"), ...)
opts_element_grob(constructor = c("element_grob", "next", "list"), ...)
opts_element_line(constructor = c("element_line", "next", "list"), ...)
opts_element_rect(constructor = c("element_rect", "next", "list"), ...)
opts_element_render(constructor = c("element_render", "next", "list"), ...)
opts_element_text(constructor = c("element_text", "next", "list"), ...)
opts_ellmer_TypeArray(constructor = c("type_array", "TypeArray", "next"), ...)
opts_ellmer_TypeBasic(constructor = c("default", "TypeBasic", "next"), ...)
opts_ellmer_TypeEnum(constructor = c("type_enum", "TypeEnum", "next"), ...)
opts_ellmer_TypeJsonSchema(constructor = c("type_from_schema", "TypeJsonSchema", "next"), ...)
opts_ellmer_TypeObject(constructor = c("type_object", "TypeObject", "next"), ...)
opts_environment(constructor = c(".env", "list2env", "as.environment", "new.env", "topenv", "new_environment", "predefine", "unserialize"), ..., recurse = FALSE, context = c("parents", "attributes", "locked"))
opts_error(constructor = c("errorCondition", "next"), ...)
opts_expression(constructor = c("default"), ...)
opts_externalptr(constructor = c("default"), ...)
opts_FacetGrid(constructor = c("facet_grid", "ggproto", "next", "environment"), ...)
opts_FacetNull(constructor = c("facet_null", "next"), ...)
opts_FacetWrap(constructor = c("facet_wrap", "ggproto", "next", "environment"), ...)
opts_factor(constructor = c("factor", "as_factor", "new_factor", "next", "integer"), ...)
opts_formula(constructor = c("default", "formula", "as.formula", "new_formula", "next"), ..., environment = TRUE)
opts_fs_bytes(constructor = c("as_fs_bytes", "next"), ...)
opts_fs_path(constructor = c("path", "as_fs_path", "next"), ...)
opts_fs_perms(constructor = c("as_fs_perms", "next"), ...)
opts_ftable(constructor = c("ftable", "next"), ...)
opts_function(constructor = c("function", "as.function", "new_function"), ..., environment = TRUE, srcref = FALSE, trim = NULL)
opts_ggplot(constructor = c("ggplot", "next", "list"), ...)
opts_ggplot2_element_blank(constructor = c("element_blank", "next"), ...)
opts_ggplot2_element_geom(constructor = c("element_geom", "next"), ...)
opts_ggplot2_element_line(constructor = c("element_line", "next"), ...)
opts_ggplot2_element_point(constructor = c("element_point", "next"), ...)
opts_ggplot2_element_polygon(constructor = c("element_polygon", "next"), ...)
opts_ggplot2_element_rect(constructor = c("element_rect", "next"), ...)
opts_ggplot2_element_text(constructor = c("element_text", "next"), ...)
opts_ggplot2_ggplot(constructor = c("ggplot", "next", "list"), ...)
opts_ggplot2_labels(constructor = c("labs", "next"), ...)
opts_ggplot2_mapping(constructor = c("aes", "next", "list"), ...)
opts_ggplot2_margin(constructor = c("margin", "next", "double"), ...)
opts_ggplot2_theme(constructor = c("default", "theme", "next", "list"), ...)
opts_ggproto(constructor = c("default", "ggproto", "next", "environment"), ...)
opts_glue(constructor = c("as_glue", "next"), ...)
opts_grouped_df(constructor = c("default", "next", "list"), ...)
opts_grouped_ts(constructor = c("group_by", "next"), ...)
opts_Guide(constructor = c("default", "next", "environment"), ...)
opts_GuideAxis(constructor = c("guide_axis", "next"), ...)
opts_GuideAxisLogticks(constructor = c("guide_axis_logticks", "next"), ...)
opts_GuideAxisStack(constructor = c("guide_axis_stack", "next"), ...)
opts_GuideAxisTheta(constructor = c("guide_axis_theta", "next"), ...)
opts_GuideBins(constructor = c("guide_bins", "next"), ...)
opts_GuideColourbar(constructor = c("guide_colorbar", "next"), ...)
opts_GuideColoursteps(constructor = c("guide_colorsteps", "next"), ...)
opts_GuideCustom(constructor = c("guide_custom", "next"), ...)
opts_GuideLegend(constructor = c("guide_legend", "next"), ...)
opts_GuideNone(constructor = c("guide_none", "next"), ...)
opts_Guides(constructor = c("guides", "next"), ...)
opts_haven_labelled(constructor = c("labelled", "next"), ...)
opts_haven_labelled_spss(constructor = c("labelled_spss", "next"), ...)
opts_hexmode(constructor = c("as.hexmode", "next"), ..., integer = FALSE)
opts_hms(constructor = c("as_hms", "hms", "new_hms", "next", "double"), ...)
opts_html(constructor = c("HTML", "next"), ...)
opts_html_dependency(constructor = c("htmlDependency", "next"), ...)
opts_IDate(constructor = c("as.IDate", "next", "integer"), ...)
opts_indMatrix(constructor = c("as", "next"), ...)
opts_integer(constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE)
opts_integer64(constructor = c("as.integer64", "next", "double"), ...)
opts_Interval(constructor = c("interval", "next"), ...)
opts_ITime(constructor = c("as.ITime", "next", "integer"), ...)
opts_labels(constructor = c("labs", "next", "list"), ...)
opts_language(constructor = c("default"), ...)
opts_Layer(constructor = c("default", "layer", "next", "environment"), ...)
opts_list(constructor = c("list", "list2"), ..., trim = NULL, fill = c("vector", "new_list", "+", "...", "none"))
opts_locale(constructor = c("locale", "next", "list"), ...)
opts_logical(constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE)
opts_margin(constructor = c("margin", "next", "double"), ...)
opts_matrix(constructor = c("matrix", "array", "cbind", "rbind", "next"), ..., byrow = FALSE)
opts_mixed_units(constructor = c("mixed_units", "next"), ...)
opts_mts(constructor = c("ts", "next", "atomic"), ...)
opts_noquote(constructor = c("noquote", "next"), ...)
opts_NULL(constructor = "NULL", ...)
opts_numeric_version(constructor = c("numeric_version", "next", "list"), ...)
opts_object(constructor = c("prototype", "S7_object"), ...)
opts_octmode(constructor = c("as.octmode", "next"), ..., integer = FALSE)
opts_ordered(constructor = c("ordered", "factor", "new_ordered", "next", "integer"), ...)
opts_package_version(constructor = c("package_version", "next", "list"), ...)
opts_pairlist(constructor = c("pairlist", "pairlist2"), ...)
opts_Period(constructor = c("period", "next"), ...)
opts_person(constructor = c("person", "next"), ...)
opts_POSIXct(constructor = c("as.POSIXct", ".POSIXct", "as_datetime", "as.POSIXct.numeric", "as_datetime.numeric", "next", "atomic"), ..., origin = "1970-01-01")
opts_POSIXlt(constructor = c("as.POSIXlt", "next", "list"), ...)
opts_quosure(constructor = c("new_quosure", "next", "language"), ...)
opts_quosures(constructor = c("new_quosures", "next", "list"), ...)
opts_R_system_version(constructor = c("R_system_version", "next", "list"), ...)
opts_R6(constructor = c("R6Class", "next"), ...)
opts_R6ClassGenerator(constructor = c("R6Class", "next"), ...)
opts_raster(constructor = c("as.raster", "next"), ...)
opts_raw(constructor = c("as.raw", "charToRaw"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, representation = c("hexadecimal", "decimal"))
opts_rel(constructor = c("rel", "next", "double"), ...)
opts_roman(constructor = c("as.roman", "next"), ...)
opts_rowwise_df(constructor = c("default", "next", "list"), ...)
opts_S4(constructor = c("new", "prototype"), ...)
opts_S7_any(constructor = c("class_any", "next"), ...)
opts_S7_base_class(constructor = c("S7", "next"), ...)
opts_S7_class(constructor = c("new_class", "next"), ...)
opts_S7_external_generic(constructor = c("new_external_generic", "next"), ...)
opts_S7_generic(constructor = c("new_generic", "next"), ...)
opts_S7_object(constructor = c("S7_object", "next"), ...)
opts_S7_property(constructor = c("new_property", "next"), ...)
opts_S7_S3_class(constructor = c("new_S3_class", "next"), ...)
opts_S7_union(constructor = c("default", "|", "new_union", "next"), ...)
opts_Scale(constructor = c("default", "next", "environment"), ...)
opts_ScalesList(constructor = c("ScalesList", "next", "list"), ...)
opts_sf(constructor = c("st_sf", "next"), ...)
opts_sfc(constructor = c("st_sfc", "next"), ...)
opts_sfg(constructor = c("st_sfg", "next"), ...)
opts_shiny.tag(constructor = c("tags", "tag", "next"), ...)
opts_shiny.tag.function(constructor = c("tagFunction", "next"), ...)
opts_shiny.tag.list(constructor = c("tagList", "next"), ...)
opts_simpleCondition(constructor = c("simpleCondition", "next"), ...)
opts_simpleError(constructor = c("simpleError", "next"), ...)
opts_simpleMessage(constructor = c("simpleMessage", "next"), ...)
opts_simpleUnit(constructor = c("unit", "next", "double"), ...)
opts_simpleWarning(constructor = c("simpleWarning", "next"), ...)
opts_sparseMatrix(constructor = c("sparseMatrix", "next"), ...)
opts_sparseVector(constructor = c("sparseVector", "next"), ...)
opts_stepfun(constructor = c("stepfun", "next"), ...)
opts_Surv(constructor = c("Surv", "next"), ...)
opts_table(constructor = c("as.table", "next"), ...)
opts_tbl_df(constructor = c("tibble", "tribble", "next", "list"), ..., trailing_comma = TRUE, justify = c("left", "right", "centre", "none"), recycle = TRUE)
opts_tbl_ts(constructor = c("tsibble", "as_tsibble", "next"), ...)
opts_theme(constructor = c("default", "theme", "next", "list"), ...)
opts_ts(constructor = c("ts", "next", "atomic"), ...)
opts_uneval(constructor = c("aes", "next", "list"), ...)
opts_units(constructor = c("set_units", "as_units", "next"), ...)
opts_vctrs_list_of(constructor = c("list_of", "next", "list"), ...)
opts_vctrs_rcrd(constructor = c("new_rcrd", "next", "list"), ...)
opts_vctrs_unspecified(constructor = c("unspecified", "next"), ...)
opts_vctrs_vctr(constructor = c("new_vctr", "next"), ...)
opts_waiver(constructor = c("waiver", "next", "list"), ...)
opts_warning(constructor = c("warningCondition", "next"), ...)
opts_weakref(constructor = c("new_weakref"), ...)
opts_xml_document(constructor = c("default", "next"), ..., simplify = TRUE)
opts_xts(constructor = c("xts", "as.xts.matrix", "as.xts.data.frame", ".xts", "next"), ...)
opts_yearmon(constructor = c("as.yearmon", "yearmon", "next"), ...)
opts_yearmonth(constructor = c("yearmonth", "next"), ...)
opts_yearqtr(constructor = c("as.yearqtr", "yearqtr", "next"), ...)
opts_yearquarter(constructor = c("yearquarter", "next"), ...)
opts_yearweek(constructor = c("yearweek", "next"), ...)
opts_zoo(constructor = c("zoo", "next"), ...)
opts_zooreg(constructor = c("zooreg", "next"), ...)
construct_dput() construct_base() construct_clip()
construct_dump() construct_reprex() construct_diff()
construct(head(cars)) construct(head(cars), opts_data.frame("read.table")) construct(head(cars), opts_data.frame("next")) construct(iris$Species) construct(iris$Species, opts_atomic(compress = FALSE), opts_factor("new_factor")) construct_multi(list(a = head(cars), b = iris$Species))construct(head(cars)) construct(head(cars), opts_data.frame("read.table")) construct(head(cars), opts_data.frame("next")) construct(iris$Species) construct(iris$Species, opts_atomic(compress = FALSE), opts_factor("new_factor")) construct_multi(list(a = head(cars), b = iris$Species))
This is a simple wrapper for convenience, construct_clip(x, ...) is equivalent to
print(construct(x, ...), print_mode = "clipboard") (an idiom that you might
use to use the clipboard with other functions). For more flexible printing
options see ?constructive_print_mode.
construct_clip( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL )construct_clip( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL )
x |
An object, for |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
pipe |
Which pipe to use, either |
check |
Boolean. Whether to check if the created code reproduces the object
using |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
pedantic_encoding |
Boolean. Whether to mark strings with the "unknown" encoding rather than an explicit native encoding ("UTF-8" or "latin1") when it's necessary to reproduce the binary representation exactly. This detail is normally of very little significance. The reason why we're not pedantic by default is that the constructed code might be different in the console and in snapshot tests and reprexes due to the latter rounding some angles, and it would be confusing for users. |
compare |
Parameters passed to |
one_liner |
Boolean. Whether to collapse the output to a single line of code. |
template |
A list of constructive options built with |
classes |
A character vector of classes for which to use idiomatic
constructors when available, we can provide a package instead of all its
classes, in the "{pkg}" form, and we can use a minus sign (inside the quotes)
to exclude rather than include. By default we use idiomatic constructors
whenever possible. The special values |
An object of class 'constructive', invisibly. Called for side effects.
## Not run: construct_clip(head(cars)) ## End(Not run)## Not run: construct_clip(head(cars)) ## End(Not run)
This calls construct() on two objects and compares the output using
diffobj::diffChr().
construct_diff( target, current, ..., data = NULL, pipe = NULL, check = TRUE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL, mode = c("sidebyside", "auto", "unified", "context"), interactive = TRUE )construct_diff( target, current, ..., data = NULL, pipe = NULL, check = TRUE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template"), classes = NULL, mode = c("sidebyside", "auto", "unified", "context"), interactive = TRUE )
target |
the reference object |
current |
the object being compared to |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
pipe |
Which pipe to use, either |
check |
Boolean. Whether to check if the created code reproduces the object
using |
compare |
Parameters passed to |
one_liner |
Boolean. Whether to collapse the output to a single line of code. |
template |
A list of constructive options built with |
classes |
A character vector of classes for which to use idiomatic
constructors when available, we can provide a package instead of all its
classes, in the "{pkg}" form, and we can use a minus sign (inside the quotes)
to exclude rather than include. By default we use idiomatic constructors
whenever possible. The special values |
mode, interactive
|
passed to |
Returns NULL invisibly, called for side effects
## Not run: # some object print the same though they're different # `construct_diff()` shows how they differ : df1 <- data.frame(a=1, b = "x") df2 <- data.frame(a=1L, b = "x", stringsAsFactors = TRUE) attr(df2, "some_attribute") <- "a value" df1 df2 construct_diff(df1, df2) # Those are made easy to compare construct_diff(substr, substring) construct_diff(month.abb, month.name) # more examples borrowed from {waldo} package construct_diff(c("a", "b", "c"), c("a", "B", "c")) construct_diff(c("X", letters), c(letters, "X")) construct_diff(list(factor("x")), list(1L)) construct_diff(df1, df2) x <- list(a = list(b = list(c = list(structure(1, e = 1))))) y <- list(a = list(b = list(c = list(structure(1, e = "a"))))) construct_diff(x, y) ## End(Not run)## Not run: # some object print the same though they're different # `construct_diff()` shows how they differ : df1 <- data.frame(a=1, b = "x") df2 <- data.frame(a=1L, b = "x", stringsAsFactors = TRUE) attr(df2, "some_attribute") <- "a value" df1 df2 construct_diff(df1, df2) # Those are made easy to compare construct_diff(substr, substring) construct_diff(month.abb, month.name) # more examples borrowed from {waldo} package construct_diff(c("a", "b", "c"), c("a", "B", "c")) construct_diff(c("X", letters), c(letters, "X")) construct_diff(list(factor("x")), list(1L)) construct_diff(df1, df2) x <- list(a = list(b = list(c = list(structure(1, e = 1))))) y <- list(a = list(b = list(c = list(structure(1, e = "a"))))) construct_diff(x, y) ## End(Not run)
construct_dput() is a closer counterpart to base::dput() that doesn't
use higher level constructors such as data.frame() and factor().
construct_base() uses higher constructors, but only for the classes
maintained in the default base R packages. This includes data.frame()
and factor(), the S4 constructors from the 'method' package etc,
but not data.table() and other constructors for classes from other
packages.
construct_dput( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template") ) construct_base( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template") )construct_dput( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template") ) construct_base( x, ..., data = NULL, pipe = NULL, check = NULL, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE, compare = compare_options(), one_liner = FALSE, template = getOption("constructive_opts_template") )
x |
An object, for |
... |
Constructive options built with the |
data |
Named list or environment of objects we want to detect and mention by name (as opposed to deparsing them further). Can also contain unnamed nested lists, environments, or package names, in the latter case package exports and datasets will be considered. In case of conflict, the last provided name is considered. |
pipe |
Which pipe to use, either |
check |
Boolean. Whether to check if the created code reproduces the object
using |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
pedantic_encoding |
Boolean. Whether to mark strings with the "unknown" encoding rather than an explicit native encoding ("UTF-8" or "latin1") when it's necessary to reproduce the binary representation exactly. This detail is normally of very little significance. The reason why we're not pedantic by default is that the constructed code might be different in the console and in snapshot tests and reprexes due to the latter rounding some angles, and it would be confusing for users. |
compare |
Parameters passed to |
one_liner |
Boolean. Whether to collapse the output to a single line of code. |
template |
A list of constructive options built with |
Both functions are valuable for object inspection, and might provide more
stable snapshots, since supporting more classes in the package means
the default output of construct() might change over time for some objects.
To use higher level constructor from the base package itself, excluding
for instance stats::ts(), utils::person() or
methods::classGeneratorFunction()), we can call construct(x, classes = "{base}"
An object of class 'constructive'.
construct_dput(head(iris, 2)) construct_base(head(iris, 2))construct_dput(head(iris, 2)) construct_base(head(iris, 2))
An alternative to base::dump() using code built with constructive.
construct_dump(x, path, append = FALSE, ...)construct_dump(x, path, append = FALSE, ...)
x |
A named list or an environment. |
path |
File or connection to write to. |
append |
If FALSE, will overwrite existing file. If TRUE, will append to existing file. In both cases, if the file does not exist a new file is created. |
... |
Forwarded to |
Returns NULL invisibly, called for side effects.
Usually called without arguments right after an imperfect code generation, but can also be called on the 'constructive' object itself.
construct_issues(x = NULL)construct_issues(x = NULL)
x |
An object built by |
A character vector with class "waldo_compare"
construct_reprex() constructs all objects of the local environment,
or a caller environment n steps above. If n > 0 the function call
is also included in a comment.
construct_reprex(..., n = 0, include_dotted = TRUE)construct_reprex(..., n = 0, include_dotted = TRUE)
... |
Forwarded to |
n |
The number of steps to go up on the call stack |
include_dotted |
Whether to include names starting with dots, this includes
|
construct_reprex() doesn't call the {reprex} package. construct_reprex()
builds reproducible data while the reprex package build reproducible output
once you have the data.
construct_reprex() wraps construct_multi() and is thus able to construct
unevaluated arguments using delayedAssign(). This means we can construct
reprexes for functions that use Non Standard Evaluation.
A useful trick is to use options(error = recover) to be able to inspect
frames on error, and use construct_reprex() from there to reproduce the
data state.
construct_reprex() might fail to reproduce the output of functions that refer
to environments other than their caller environment. We believe these are
very rare and that the simplicity is worth the rounded corners, but if you
encounter these limitations please do open a ticket on our issue tracker
at https://github.com/cynkra/constructive/ and we might expand the feature.
An object of class 'constructive'.
construct_serialize() creates code that reconstructs an R object by serializing
it to raw bytes and then calling unserialize(). This is a fallback method that
works for almost any R object, including those that are difficult or impossible
to construct idiomatically.
construct_serialize(x, collapse_header = FALSE)construct_serialize(x, collapse_header = FALSE)
x |
An R object to serialize and reconstruct. |
collapse_header |
Logical. If |
This function generates code in the form:
unserialize(as.raw(c( # --- HEADER --- c(0x58, 0x0a, ...), # --- DATA --- c(0x00, 0x00, ...) )))
The generated code includes detailed comments explaining the binary structure, making it useful for understanding R's serialization format.
construct_serialize() reproduces faithfully what serialize() does, so it
shares its limitations. Some objects don't survive serialization or can be
restored only in some conditions:
External pointers: The address is lost, we get a null pointer
Weak references: The key and value are lost
Connections: Only the connection number is stored, the reconstructed object is valid only in the same session, as long as the connection is open
Namespaces and package environments: They are stored by name, so the package must be available when the code is run
The function is designed for small objects, every byte is documented so the
output is long and large objects (hundreds of kilobytes once serialized) are
slow to process. Note that functions defined in a file keep a reference to
the whole file through their srcref, use utils::removeSource() to get rid of it.
An object of class "constructive_code" containing the generated code
as a character vector. Each element is one line of code.
construct() for idiomatic object construction, serialize() for
the underlying serialization mechanism.
# Simple objects construct_serialize(1:5) construct_serialize(c("hello", "world")) # Complex objects construct_serialize(data.frame(a = 1:3, b = letters[1:3])) construct_serialize(matrix(1:6, nrow = 2)) # Objects with attributes x <- c(a = 1, b = 2, c = 3) construct_serialize(x) # Expressions and calls construct_serialize(quote(mean(x))) construct_serialize(expression(x + 1, y * 2)) # Special values construct_serialize(c(NA, NaN, Inf, -Inf)) # Builtin functions construct_serialize(sum) construct_serialize(`if`) # The generated code can be evaluated to reconstruct the object code <- construct_serialize(iris) reconstructed <- eval(parse(text = paste(code, collapse = "\n"))) identical(reconstructed, iris)# Simple objects construct_serialize(1:5) construct_serialize(c("hello", "world")) # Complex objects construct_serialize(data.frame(a = 1:3, b = letters[1:3])) construct_serialize(matrix(1:6, nrow = 2)) # Objects with attributes x <- c(a = 1, b = 2, c = 3) construct_serialize(x) # Expressions and calls construct_serialize(quote(mean(x))) construct_serialize(expression(x + 1, y * 2)) # Special values construct_serialize(c(NA, NaN, Inf, -Inf)) # Builtin functions construct_serialize(sum) construct_serialize(`if`) # The generated code can be evaluated to reconstruct the object code <- construct_serialize(iris) reconstructed <- eval(parse(text = paste(code, collapse = "\n"))) identical(reconstructed, iris)
Construct a function's signature such as the one you can see right below in the 'Usage' section.
construct_signature(x, name = NULL, one_liner = FALSE, style = TRUE)construct_signature(x, name = NULL, one_liner = FALSE, style = TRUE)
x |
A function |
name |
The name of the function, by default we use the symbol provided to |
one_liner |
Boolean. Whether to collapse multi-line expressions on a single line using semicolons. |
style |
Boolean. Whether to give a class "constructive_code" on the output for pretty printing. |
a string or a character vector, with a class "constructive_code" for pretty
printing if style is TRUE
construct_signature(lm)construct_signature(lm)
Set these options to tweak {constructive}'s global behavior, to set them
permanently you can edit your .RProfile1, e.g. using usethis::edit_r_profile().
Set options(constructive_print_mode = <character>) to change the default
value of the print_mode argument, of print.constructive, where <character> is a vector
of strings among the following :
"console" : The default behavior, the code is printed in the console
"script" : The code is copied to a new R script
"reprex" : The code is shown in the viewer as a reprex,
the reprex (not only the code!) is also copied to the clipboard.
"clipboard" : The constructed code is copied to the clipboard, if combined
with "reprex" this takes precedence (the reprex is showed in the viewer,
the code without output is copied to the clipboard)
Set options(constructive_opts_template = <list>) to set default constructive options,
see documentation of the template arg in ?construct
Set options(constructive_pretty = FALSE) to disable syntax highlighting.
cli.code_theme can be used to configure the syntax highlighting theme
used by {constructive}; see cli::code_theme_list() for more information.
An alternative to base::deparse() and rlang::expr_deparse() that
handles additional corner cases and fails when encountering tokens other than
symbols and syntactic literals where cited alternatives would produce non syntactic code.
deparse_call( call, one_liner = FALSE, pipe = FALSE, style = TRUE, collapse = !style, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE )deparse_call( call, one_liner = FALSE, pipe = FALSE, style = TRUE, collapse = !style, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, pedantic_encoding = FALSE )
call |
A call. |
one_liner |
Boolean. Whether to collapse multi-line expressions on a single line using semicolons. |
pipe |
Boolean. Whether to use the base pipe to disentangle nested calls. This works best on simple calls. |
style |
Boolean. Whether to give a class "constructive_code" on the output for pretty printing. |
collapse |
Boolean. Whether to collapse the output to a single string,
won't be directly visible if |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
pedantic_encoding |
Boolean. Whether to mark strings with the "unknown" encoding rather than an explicit native encoding ("UTF-8" or "latin1") when it's necessary to reproduce the binary representation exactly. This detail is normally of very little significance. The reason why we're not pedantic by default is that the constructed code might be different in the console and in snapshot tests and reprexes due to the latter rounding some angles, and it would be confusing for users. |
a string or a character vector, with a class "constructive_code" for pretty
printing if style is TRUE.
expr <- quote(foo(bar({this; that}, 1))) deparse_call(expr) deparse_call(expr, one_liner = TRUE) deparse_call(expr, pipe = TRUE) deparse_call(expr, style = FALSE)expr <- quote(foo(bar({this; that}, 1))) deparse_call(expr) deparse_call(expr, one_liner = TRUE) deparse_call(expr, pipe = TRUE) deparse_call(expr, style = FALSE)
We export a collection of functions that can be used to design custom methods for .cstr_construct() or custom constructors for a given method.
.cstr_new_class() : Open template to support a new class
.cstr_new_constructor() : Open template to implement a new constructor
.cstr_construct() : Low level generic for object construction code generation
.cstr_repair_attributes()' : Helper to repair attributes of objects
.cstr_options() : Define and check options to pass to custom constructors
.cstr_apply() : Build recursively the arguments passed to your constructor
.cstr_wrap() : Wrap argument code in function code (rarely needed)
.cstr_pipe() : Pipe a call to another (rarely needed)
.cstr_combine_errors() : helper function report several errors at once when relevant
These options will be used on arrays. Note that arrays can be built on top of
vectors, lists or expressions. Canonical arrays have an implicit class "array"
shown by class() but "array" is not part of the class attribute.
opts_array(constructor = c("array", "next"), ...)opts_array(constructor = c("array", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"array" (default): Use the array() function
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_array>
AsIs
These options will be used on objects of class AsIs. AsIs objects are
created with I() which only prepends "AsIs" to the class attribute.
opts_AsIs(constructor = c("I", "next"), ...)opts_AsIs(constructor = c("I", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"I" (default): Use the I() function
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_AsIs>
These options will be used on atomic types ("logical", "integer", "numeric", "complex", "character" and "raw").
They can also be directly provided to atomic types through their own opts_*()
function, and in this case the latter will have precedence.
opts_atomic( ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )opts_atomic( ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. |
compress |
Boolean. If |
If trim is provided, depending on fill we will present trimmed elements as followed:
"default" : Use default atomic constructors, so for instance c("a", "b", "c") might become c("a", character(2)).
"rlang" : Use rlang atomic constructors, so for instance c("a", "b", "c") might become c("a", rlang::new_character(2)),
these rlang constructors create vectors of NAs, so it's different from the default option.
"+": Use unary +, so for instance c("a", "b", "c") might become c("a", +2).
"...": Use ..., so for instance c("a", "b", "c") might become c("a", ...)
"none": Don't represent trimmed elements.
Depending on the case some or all of the choices above might generate code that cannot be executed. The 2 former options above are the most likely to succeed and produce an output of the same type and dimensions recursively. This would at least be the case for data frame.
An object of class <constructive_options/constructive_options_atomic>
construct(iris, opts_atomic(trim = 2), check = FALSE) # fill = "default" construct(iris, opts_atomic(trim = 2, fill = "rlang"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "+"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "..."), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE) x <- c("a a", "a\U000000A0a", "a\U00002002a", "\U430 \U430")construct(iris, opts_atomic(trim = 2), check = FALSE) # fill = "default" construct(iris, opts_atomic(trim = 2, fill = "rlang"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "+"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "..."), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE) construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE) x <- c("a a", "a\U000000A0a", "a\U00002002a", "\U430 \U430")
These options will be used on objects of class 'bbox'.
opts_bbox(constructor = c("st_bbox", "next"), ...)opts_bbox(constructor = c("st_bbox", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"st_bbox" (default): We build the object using sf::st_bbox() on a
named double vector, with a crs argument if relevant.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_bbox>
These options will be used on objects of class 'blob'.
opts_blob(constructor = c("blob", "next"), ...)opts_blob(constructor = c("blob", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"blob" (default): Use blob::blob() on a raw object.
"new_blob" (default): Use blob::new_blob() on a list of raw objects.
"as.blob" : Use blob::as_blob() on a character vector
Use opts_raw() and opts_character() to tweak the construction of raw or
character objects constructed as part of the blob construction.
An object of class <constructive_options/constructive_options_blob>
These options will be used on objects of type 'character'. This type has a single native constructor, but some additional options can be set.
unicode_representation and escape are usually better set in the main
function (construct() or other) so they apply not only on strings but on
symbols and argument names as well.
To set options on all atomic types at once see opts_atomic().
opts_character( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, multiline = FALSE )opts_character( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, unicode_representation = c("ascii", "latin", "character", "unicode"), escape = FALSE, multiline = FALSE )
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Constructive options built with the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
multiline |
Boolean. Whether to construct strings containing new lines
on several lines, rather than using |
An object of class <constructive_options/constructive_options_character>
These options will be used on objects of class 'classGeneratorFunction'.
opts_classGeneratorFunction(constructor = c("setClass"), ...)opts_classGeneratorFunction(constructor = c("setClass"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_classGeneratorFunction>
These options will be used on objects of class 'classPrototypeDef'.
opts_classPrototypeDef(constructor = c("prototype"), ...)opts_classPrototypeDef(constructor = c("prototype"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_classPrototypeDef>
These options will be used on objects of class 'classRepresentation'.
opts_classRepresentation(constructor = c("getClassDef"), ...)opts_classRepresentation(constructor = c("getClassDef"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_classRepresentation>
These options will be used on objects of class 'clock_duration'.
opts_clock_duration(constructor = c("duration", "next", "list"), ...)opts_clock_duration(constructor = c("duration", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"duration" (default): We build the object using the clock::duration_*()
helper matching the precision, e.g. clock::duration_days(). Durations
that don't fit in an integer are constructed with the "list" constructor.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_duration>
These options will be used on objects of class 'clock_iso_year_week_day'.
opts_clock_iso_year_week_day( constructor = c("iso_year_week_day", "next", "list"), ... )opts_clock_iso_year_week_day( constructor = c("iso_year_week_day", "next", "list"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"iso_year_week_day" (default): We build the object using clock::iso_year_week_day(),
providing the components required by the precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_iso_year_week_day>
These options will be used on objects of class 'clock_naive_time'.
opts_clock_naive_time(constructor = c("as_naive_time", "next", "list"), ...)opts_clock_naive_time(constructor = c("as_naive_time", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_naive_time" (default): We build the object using clock::as_naive_time()
on a clock::year_month_day() call of the same precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_naive_time>
These options will be used on objects of class 'clock_sys_time'.
opts_clock_sys_time(constructor = c("as_sys_time", "next", "list"), ...)opts_clock_sys_time(constructor = c("as_sys_time", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_sys_time" (default): We build the object using clock::as_sys_time()
on a clock::year_month_day() call of the same precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_sys_time>
These options will be used on objects of class 'clock_weekday'.
opts_clock_weekday(constructor = c("weekday", "next", "integer"), ...)opts_clock_weekday(constructor = c("weekday", "next", "integer"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"weekday" (default): We build the object using clock::weekday() on
day codes, from 1 (Sunday) to 7 (Saturday).
"next" : Use the constructor for the next supported class.
"integer" : We define as an atomic vector and repair attributes.
An object of class <constructive_options/constructive_options_clock_weekday>
These options will be used on objects of class 'clock_year_day'.
opts_clock_year_day(constructor = c("year_day", "next", "list"), ...)opts_clock_year_day(constructor = c("year_day", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"year_day" (default): We build the object using clock::year_day(),
providing the components required by the precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_year_day>
These options will be used on objects of class 'clock_year_month_day'.
opts_clock_year_month_day( constructor = c("year_month_day", "next", "list"), ... )opts_clock_year_month_day( constructor = c("year_month_day", "next", "list"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"year_month_day" (default): We build the object using clock::year_month_day(),
providing the components required by the precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_year_month_day>
These options will be used on objects of class 'clock_year_month_weekday'.
opts_clock_year_month_weekday( constructor = c("year_month_weekday", "next", "list"), ... )opts_clock_year_month_weekday( constructor = c("year_month_weekday", "next", "list"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"year_month_weekday" (default): We build the object using clock::year_month_weekday(),
providing the components required by the precision.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_year_month_weekday>
These options will be used on objects of class 'clock_year_quarter_day'.
opts_clock_year_quarter_day( constructor = c("year_quarter_day", "next", "list"), ... )opts_clock_year_quarter_day( constructor = c("year_quarter_day", "next", "list"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"year_quarter_day" (default): We build the object using clock::year_quarter_day(),
providing the components required by the precision, and start if it is not the default.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_year_quarter_day>
These options will be used on objects of class 'clock_year_week_day'.
opts_clock_year_week_day(constructor = c("year_week_day", "next", "list"), ...)opts_clock_year_week_day(constructor = c("year_week_day", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"year_week_day" (default): We build the object using clock::year_week_day(),
providing the components required by the precision, and start if it is not the default.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_year_week_day>
These options will be used on objects of class 'clock_zoned_time'.
opts_clock_zoned_time(constructor = c("as_zoned_time", "next", "list"), ...)opts_clock_zoned_time(constructor = c("as_zoned_time", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_zoned_time" (default): We build the object using clock::as_zoned_time()
on the local naive time, providing the zone and, when some local times are
ambiguous, the ambiguous argument.
"next" : Use the constructor for the next supported class.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_clock_zoned_time>
These options will be used on objects of class 'col_spec'.
opts_col_spec(constructor = c("cols", "next", "list"), ...)opts_col_spec(constructor = c("cols", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"cols" (default): We build the object using readr::cols(), or
readr::cols_only() when the default collector is readr::col_skip().
The .default argument is omitted when it's readr::col_guess().
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
Use opts_collector() to tweak the construction of the column specifications.
An object of class <constructive_options/constructive_options_col_spec>
These options will be used on objects of class 'collector', i.e. column
specifications as created by readr::col_double(), readr::col_date(),
readr::col_factor() etc. They all share the class 'collector' and a subclass
'collector_readr::col_<type>().
opts_collector(constructor = c("col", "next", "list"), ...)opts_collector(constructor = c("col", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"col" (default): We build the object using the relevant readr::col_*()
function, e.g. readr::col_double() or readr::col_date(format = "%Y"),
providing only non default arguments.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
An object of class <constructive_options/constructive_options_collector>
These options will be used on objects of type 'complex'. This type has a single native constructor, but some additional options can be set.
To set options on all atomic types at once see opts_atomic().
opts_complex( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )opts_complex( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
An object of class <constructive_options/constructive_options_complex>
constructive_options
These options will be used on objects of class constructive_options.
opts_constructive_options(constructor = c("opts", "next"), ...)opts_constructive_options(constructor = c("opts", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"opts" : Use the relevant constructive::opts_?() function.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_constructive_options>
These options will be used on objects of class 'CoordRadial'.
opts_CoordRadial(constructor = c("coord_radial", "next"), ...)opts_CoordRadial(constructor = c("coord_radial", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"coord_radial" (default): We build the object using ggplot2::coord_radial().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_CoordRadial>
These options will be used on objects of class 'CoordTransform'.
opts_CoordTransform(constructor = c("coord_transform", "next"), ...)opts_CoordTransform(constructor = c("coord_transform", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"coord_transform" (default): We build the object using ggplot2::coord_transform().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_CoordTransform>
These options will be used on objects of class 'crs'.
opts_crs(constructor = c("st_crs", "next"), ...)opts_crs(constructor = c("st_crs", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"st_crs" (default): We build the object using sf::st_crs() on an EPSG
code if possible (e.g. sf::st_crs(4326)), or else on the user input
(e.g. sf::st_crs("OGC:CRS84")) or on the wkt definition, the first that
reproduces the object exactly.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
The wkt definition of a crs depends on the installed PROJ version, so a crs
object created on a different setup might not be reproducible with
sf::st_crs(), in this case we fall back to the next constructor.
An object of class <constructive_options/constructive_options_crs>
These options will be used on objects of class 'data.frame'.
opts_data.frame( constructor = c("data.frame", "read.table", "next", "list"), ..., recycle = TRUE )opts_data.frame( constructor = c("data.frame", "read.table", "next", "list"), ..., recycle = TRUE )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
recycle |
Boolean. For the |
Depending on constructor, we construct the object as follows:
"data.frame" (default): Wrap the column definitions in a data.frame() call. If some
columns are lists or data frames, we wrap the column definitions in tibble::tibble().
then use as.data.frame().
"read.table" : We build the object using read.table() if possible, or fall
back to data.frame().
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_data.frame>
These options will be used on objects of class 'data.table'.
opts_data.table( constructor = c("data.table", "next", "list"), ..., selfref = FALSE, recycle = TRUE )opts_data.table( constructor = c("data.table", "next", "list"), ..., selfref = FALSE, recycle = TRUE )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
selfref |
Boolean. Whether to include the |
recycle |
Boolean. Whether to recycle scalars to compress the output. |
Depending on constructor, we construct the object as follows:
"data.table" (default): Wrap the column definitions in a data.table() call.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_data.table>
These options will be used on objects of class 'date'.
opts_Date( constructor = c("as.Date", "as_date", "date", "new_date", "as.Date.numeric", "as_date.numeric", "next", "double"), ..., origin = "1970-01-01" )opts_Date( constructor = c("as.Date", "as_date", "date", "new_date", "as.Date.numeric", "as_date.numeric", "next", "double"), ..., origin = "1970-01-01" )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
origin |
Origin to be used, ignored when irrelevant. |
Depending on constructor, we construct the object as follows:
"as.Date" (default): We wrap a character vector with as.Date(), if the date
is infinite it cannot be converted to character and we wrap a numeric vector and
provide an origin argument.
"as_date" : Similar as above but using lubridate::as_date(), the only difference is
that we never need to supply origin.
"date" : Similar as above but using lubridate::date(), it doesn't support
infinite dates so we fall back on lubridate::as_date() when we encounter them.
"new_date" : We wrap a numeric vector with vctrs::new_date()
"as.Date.numeric" : We wrap a numeric vector with as.Date() and use the
provided origin
"as_date.numeric" : Same as above but using lubridate::as_date() and use the
provided origin
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"double" : We define as an double vector and repair attributes
If the data is not appropriate for a constructor we fall back to another one appropriately.
An object of class <constructive_options/constructive_options_Date>
These options will be used on objects of class 'date_names'.
opts_date_names( constructor = c("date_names_lang", "date_names", "next", "list"), ... )opts_date_names( constructor = c("date_names_lang", "date_names", "next", "list"), ... )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"date_names_lang" (default): We build the object using
readr::date_names_lang() if the object matches one of the languages
listed by readr::date_names_langs(), and fall back to the "date_names"
constructor otherwise.
"date_names" : We build the object using readr::date_names(), providing
only non default arguments.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
An object of class <constructive_options/constructive_options_date_names>
These options will be used on objects of class 'denseMatrix' from the 'Matrix' package, i.e. objects of classes such as 'dgeMatrix', 'lgeMatrix', 'dsyMatrix' or 'dtrMatrix'.
opts_denseMatrix(constructor = c("Matrix", "next"), ...)opts_denseMatrix(constructor = c("Matrix", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"Matrix" (default): We build the object using Matrix::Matrix() on a
base matrix, with sparse = FALSE. Matrix::Matrix() detects symmetric
and triangular matrices so if this cannot reproduce the object exactly
(e.g. a general matrix with symmetric content, packed storage, cached
factorizations) we fall back to the next constructor.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_denseMatrix>
These options will be used on objects of class 'diagonalMatrix' from the 'Matrix' package, i.e. objects of classes 'ddiMatrix' or 'ldiMatrix'.
opts_diagonalMatrix(constructor = c("Diagonal", "next"), ...)opts_diagonalMatrix(constructor = c("Diagonal", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"Diagonal" (default): We build the object using Matrix::Diagonal().
If this cannot reproduce the object exactly (e.g. different row and column
names) we fall back to the next constructor.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_diagonalMatrix>
These options will be used on objects of class 'dist'.
opts_dist(constructor = c("as.dist", "next"), ...)opts_dist(constructor = c("as.dist", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.dist" (default): We build the object using as.dist() on a symmetric
matrix. The "call" attribute, and the "method" attribute set by dist(),
are then repaired.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_atomic().
An object of class <constructive_options/constructive_options_dist>
These options will be used on objects of class 'dm'.
opts_dm(constructor = c("dm", "next", "list"), ...)opts_dm(constructor = c("dm", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"dm" (default): We use dm::dm() and other functions from dm to adjust the content.
This does not strictly reproduce the object because each dm calls creates different
uuid values for its tables, but the recreated object is functionally equivalent.
Use the "list" constructor for fully accurate reconstruction.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_dm>
These options will be used on objects of type '...'. These are rarely encountered in practice. By default this function is useless as nothing can be set, this is provided in case users want to extend the method with other constructors.
opts_dots(constructor = c("default"), ...)opts_dots(constructor = c("default"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" : We use the construct (function(...) get(\"...\"))(a = x, y)
which we evaluate in the correct environment.
An object of class <constructive_options/constructive_options_dots>
These options will be used on objects of type 'double'. This type has a single native constructor, but some additional options can be set.
To set options on all atomic types at once see opts_atomic().
opts_double( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )opts_double( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
An object of class <constructive_options/constructive_options_double>
These options will be used on objects of class 'Duration'.
opts_Duration(constructor = c("default", "dseconds", "duration", "next"), ...)opts_Duration(constructor = c("default", "dseconds", "duration", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" (default): We build the object using the largest of
lubridate::dyears(), lubridate::dmonths(), lubridate::dweeks(),
lubridate::ddays(), lubridate::dhours(), lubridate::dminutes() and
lubridate::dseconds() for which all the elements are whole numbers and
the object is reproduced exactly, so an hour is built with
lubridate::dhours(1) rather than lubridate::dseconds(3600). Note that
the years and months of 'lubridate' durations are fixed approximations,
of 365.25 and 30.4375 days respectively, so 31557600 seconds come out as
lubridate::dyears(1). NA elements don't constrain the choice, and
we use lubridate::dseconds() if all elements are NA or zero, or if the
object is empty.
"dseconds" : We build the object using lubridate::dseconds()
on a number of seconds.
"duration" : We build the object using lubridate::duration()
on a number of seconds.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_Duration>
These options will be used on objects of class 'ecdf'.
opts_ecdf(constructor = c("ecdf", "next"), ...)opts_ecdf(constructor = c("ecdf", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"ecdf" (default): We build the object using ecdf(), the sorted
non-missing data is retrieved from the function's enclosure. The "call"
attribute is repaired if it differs from the constructed call.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_stepfun().
An object of class <constructive_options/constructive_options_ecdf>
These options will be used on objects of class 'ellmer::TypeArray''.
opts_ellmer_TypeArray(constructor = c("type_array", "TypeArray", "next"), ...)opts_ellmer_TypeArray(constructor = c("type_array", "TypeArray", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"TypeArray" (default): We build the object using ellmer::TypeArray().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ellmer::TypeArray'>
These options will be used on objects of class 'ellmer::TypeBasic''.
opts_ellmer_TypeBasic(constructor = c("default", "TypeBasic", "next"), ...)opts_ellmer_TypeBasic(constructor = c("default", "TypeBasic", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"TypeBasic" (default): We build the object using ellmer::TypeBasic().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ellmer::TypeBasic'>
These options will be used on objects of class 'ellmer::TypeEnum''.
opts_ellmer_TypeEnum(constructor = c("type_enum", "TypeEnum", "next"), ...)opts_ellmer_TypeEnum(constructor = c("type_enum", "TypeEnum", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"TypeEnum" (default): We build the object using ellmer::TypeEnum().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ellmer::TypeEnum'>
These options will be used on objects of class 'ellmer::TypeJsonSchema''.
opts_ellmer_TypeJsonSchema( constructor = c("type_from_schema", "TypeJsonSchema", "next"), ... )opts_ellmer_TypeJsonSchema( constructor = c("type_from_schema", "TypeJsonSchema", "next"), ... )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"TypeJsonSchema" (default): We build the object using ellmer::TypeJsonSchema().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ellmer::TypeJsonSchema'>
These options will be used on objects of class 'ellmer::TypeObject''.
opts_ellmer_TypeObject( constructor = c("type_object", "TypeObject", "next"), ... )opts_ellmer_TypeObject( constructor = c("type_object", "TypeObject", "next"), ... )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"TypeObject" (default): We build the object using ellmer::TypeObject().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ellmer::TypeObject'>
Environments use reference semantics, they cannot be copied.
An attempt to copy an environment would indeed yield a different environment and identical(env, copy) would be FALSE.
Moreover most environments have a parent (exceptions are emptyenv() and some
rare cases where the parent is NULL) and thus to copy the environment we'd
have to have a way to point to the parent, or copy it too.
For this reason environments are constructive's cryptonite. They make some objects
impossible to reproduce exactly. And since every function or formula has one they're hard to
avoid.
opts_environment( constructor = c(".env", "list2env", "as.environment", "new.env", "topenv", "new_environment", "predefine", "unserialize"), ..., recurse = FALSE, context = c("parents", "attributes", "locked") )opts_environment( constructor = c(".env", "list2env", "as.environment", "new.env", "topenv", "new_environment", "predefine", "unserialize"), ..., recurse = FALSE, context = c("parents", "attributes", "locked") )
constructor |
String. Name of the function used to construct the environment, see Constructors section. |
... |
Additional options used by user defined constructors through the |
recurse |
Boolean. Only considered if |
context |
Character vector. Only considered if
Environments found in |
In some case we can build code that points to a specific environment, namely:
.GlobalEnv, .BaseNamespaceEnv, baseenv() and emptyenv() are used to construct
the global environment, the base namespace, the base package environment and the empty
environment
Namespaces are constructed using asNamespace("pkg")
Package environments are constructed using as.environment("package:pkg")
"imports" environments are constructed with parent.env(asNamespace("pkg"))
"lazydata" environments are constructed with getNamespaceInfo("pkg", "lazydata")
By default For other environments we use constructive's function constructive::.env(), it fetches
the environment from its memory address and provides as additional information
the sequence of parents until we reach a special environment (those enumerated above).
The advantage of this approach is that it's readable and that the object is accurately reproduced.
The inconvenient is that it's not stable between sessions. If an environment has a NULL parent it's always constructed
with constructive::.env(), whatever the choice of the constructor.
Often however we wish to be able to reproduce from scratch a similar environment, so that we might run the constructed code later in a new session. We offer different different options to do this, with different trade-offs regarding accuracy and verbosity.
{constructive} will not signal any difference if it can reproduce an equivalent environment,
defined as containing the same values and having a same or equivalent parent.
See also the ignore_function_env argument in ?compare_options, which disables the check
of environments of function.
An object of class <constructive_options/constructive_options_environment>
We might set the constructor argument to:
".env" (default): use constructive::.env() to construct the environment from
its memory address. Additional information is displayed through its
non-functional arguments, see the context argument.
"list2env": We construct the environment as a list then
use base::list2env() to convert it to an environment and assign it a parent. By
default we use as a parent the first special environment we find when going
through ancestors, so we can print code that doesn't use .env().
If recurse is TRUE
the parent will be built recursively so all ancestors will be created until
we meet a known environment, this might be verbose and will fail if environments
are nested too deep or have a circular relationship. If the environment is empty we use new.env(parent=)
for a more economic syntax.
"new_environment" : Similar to the above, but using rlang::new_environment().
"new.env" : All environments will be recreated with the code "base::new.env()",
without argument, effectively creating an empty environment child of
the local (often global) environment. This is enough in cases where the environment
doesn't matter (or matters as long as it inherits from the local environment),
as is often the case with formulas. recurse is ignored.
"as.environment" : we attempt to construct the environment as a list and use
base::as.environment() on top of it, as in as.environment(list(a=1, b=2)), it will
contain the same variables as the original environment but the parent will be the
emptyenv(). recurse is ignored.
"topenv" : we construct base::topenv(x), see ?topenv. recurse is ignored.
This is the most accurate we can be when constructing only special environments.
"predefine" : Building environments from scratch using the above methods
can be verbose, sometimes redundant and sometimes even impossible due to
circularity (e.g. an environment referencing itself). With "predefine"
we define the environments and their content above the object returning
call, using placeholder names ..env.1.., ..env.2.. etc.
The caveat is that the created code won't be a single call
and will create objects in the workspace. recurse is ignored.
"unserialize" : We serialize the environment and construct it with
unserialize() on the raw vector. The code is not readable but it
reproduces the environment exactly in a new session: its parents up to a
special environment, its bindings including active bindings and promises,
its attributes and whether it is locked. Special environments met on the
way, like namespaces, are serialized by name. recurse is ignored.
These options will be used on objects of type 'externalptr'. By default this function is useless as nothing can be set, this is provided in case users wan to extend the method with other constructors.
opts_externalptr(constructor = c("default"), ...)opts_externalptr(constructor = c("default"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" : We use a special function from the constructive
An object of class <constructive_options/constructive_options_externalptr>
These options will be used on objects of class 'FacetNull'.
opts_FacetNull(constructor = c("facet_null", "next"), ...)opts_FacetNull(constructor = c("facet_null", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"facet_null" (default): We build the object using ggplot2::facet_null().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_FacetNull>
These options will be used on objects of class 'factor'.
opts_factor( constructor = c("factor", "as_factor", "new_factor", "next", "integer"), ... )opts_factor( constructor = c("factor", "as_factor", "new_factor", "next", "integer"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"factor" (default): Build the object using factor(), levels won't
be defined explicitly if they are in alphabetical order (locale dependent!)
"as_factor" : Build the object using forcats::as_factor() whenever
possible, i.e. when levels are defined in order of appearance in the vector. Otherwise falls back to "factor" constructor.
"new_factor" : Build the object using vctrs::new_factor(). Levels are
always defined explicitly.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"integer" : We define as an integer vector and repair attributes.
An object of class <constructive_options/constructive_options_factor>
These options will be used on formulas, defined as calls to ~, regardless
of their "class" attribute.
opts_formula( constructor = c("default", "formula", "as.formula", "new_formula", "next"), ..., environment = TRUE )opts_formula( constructor = c("default", "formula", "as.formula", "new_formula", "next"), ..., environment = TRUE )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
environment |
Boolean. Whether to attempt to construct the environment, if it makes a difference to construct it. Depending on
|
An object of class <constructive_options/constructive_options_formula>
These options will be used on objects of class 'fs_bytes'.
opts_fs_bytes(constructor = c("as_fs_bytes", "next"), ...)opts_fs_bytes(constructor = c("as_fs_bytes", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_fs_bytes" (default): Build the object using fs::as_fs_bytes() on a
numeric vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_fs_bytes>
These options will be used on objects of class 'fs_path'.
opts_fs_path(constructor = c("path", "as_fs_path", "next"), ...)opts_fs_path(constructor = c("path", "as_fs_path", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"path" (default): Build the object using fs::path() on a character
vector.
"as_fs_path" : Build the object using fs::as_fs_path() on a character
vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
Both fs::path() and fs::as_fs_path() tidy their input, so paths that are
not tidy (e.g. "a//b/") are always constructed with the "next" constructor.
An object of class <constructive_options/constructive_options_fs_path>
These options will be used on objects of class 'fs_perms'.
opts_fs_perms(constructor = c("as_fs_perms", "next"), ...)opts_fs_perms(constructor = c("as_fs_perms", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_fs_perms" (default): Build the object using fs::as_fs_perms() on
octal strings such as "644". Vectors of length other than 1 or 2 are
first converted with as.octmode(), because fs::as_fs_perms() scrambles
the order of longer character vectors.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
Objects containing NA or negative values are always constructed with the
"next" constructor.
An object of class <constructive_options/constructive_options_fs_perms>
These options will be used on objects of class 'ftable'.
opts_ftable(constructor = c("ftable", "next"), ...)opts_ftable(constructor = c("ftable", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"ftable" (default): We build the object using ftable() on a table,
providing the row.vars argument when needed.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_matrix("matrix").
An object of class <constructive_options/constructive_options_ftable>
These options will be used on functions, i.e. objects of type "closure", "special" and "builtin".
opts_function( constructor = c("function", "as.function", "new_function"), ..., environment = TRUE, srcref = FALSE, trim = NULL )opts_function( constructor = c("function", "as.function", "new_function"), ..., environment = TRUE, srcref = FALSE, trim = NULL )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
environment |
Boolean. Whether to reconstruct the function's environment. |
srcref |
Boolean. Whether to attempt to reconstruct the function's srcref. |
trim |
|
Depending on constructor, we construct the object as follows:
"function" (default): Build the object using a standard function() {}
definition. This won't set the environment by default, unless environment
is set to TRUE. If a srcref is available, if this srcref matches the function's
definition, and if trim is left NULL, the code is returned from using the srcref,
so comments will be shown in the output of construct(). In the rare case
where the ast body of the function contains non syntactic nodes this constructor
cannot be used and falls back to the "as.function" constructor.
"as.function" : Build the object using a as.function() call.
back to data.frame().
"new_function" : Build the object using a rlang::new_function() call.
An object of class <constructive_options/constructive_options_function>
These options will be used on objects of class 'ggplot'.
opts_ggplot(constructor = c("ggplot", "next", "list"), ...)opts_ggplot(constructor = c("ggplot", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"ggplot" (default): Use ggplot2::ggplot()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_ggplot>
These options will be used on objects of class 'ggplot2::ggplot'.
opts_ggplot2_ggplot(constructor = c("ggplot", "next", "list"), ...)opts_ggplot2_ggplot(constructor = c("ggplot", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"ggplot" (default): Use ggplot2::ggplot()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_ggplot2::ggplot>
These options will be used on objects of class 'ggplot2::labels'.
opts_ggplot2_labels(constructor = c("labs", "next"), ...)opts_ggplot2_labels(constructor = c("labs", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"labs" (default): We build the object using ggplot2::labs().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_ggplot2::labels>
These options will be used on objects of class 'glue'.
opts_glue(constructor = c("as_glue", "next"), ...)opts_glue(constructor = c("as_glue", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_glue" (default): Use glue::as_glue() on a character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
Use opts_character() to tweak the construction of the character vector
constructed as part of the glue construction.
An object of class <constructive_options/constructive_options_glue>
These options will be used on objects of class 'grouped_df'.
opts_grouped_df(constructor = c("default", "next", "list"), ...)opts_grouped_df(constructor = c("default", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : We define as an list object and repair attributes.
An object of class <constructive_options/constructive_options_factor>
These options will be used on objects of class 'grouped_ts'.
opts_grouped_ts(constructor = c("group_by", "next"), ...)opts_grouped_ts(constructor = c("group_by", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"group_by" (default): Construct the ungrouped tsibble and pipe it into
dplyr::group_by(), and into tsibble::index_by() if the object is grouped
by an index. Use opts_tbl_ts() to tweak the construction of the tsibble.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_grouped_ts>
These options will be used on objects of class 'GuideAxis'.
opts_GuideAxis(constructor = c("guide_axis", "next"), ...)opts_GuideAxis(constructor = c("guide_axis", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_axis" (default): We build the object using ggplot2::guide_axis().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideAxis>
These options will be used on objects of class 'GuideAxisLogticks'.
opts_GuideAxisLogticks(constructor = c("guide_axis_logticks", "next"), ...)opts_GuideAxisLogticks(constructor = c("guide_axis_logticks", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_axis_logticks" (default): We build the object using ggplot2::guide_axis_logticks().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideAxisLogticks>
These options will be used on objects of class 'GuideAxisStack'.
opts_GuideAxisStack(constructor = c("guide_axis_stack", "next"), ...)opts_GuideAxisStack(constructor = c("guide_axis_stack", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_axis_stack" (default): We build the object using ggplot2::guide_axis_stack().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideAxisStack>
These options will be used on objects of class 'GuideAxisTheta'.
opts_GuideAxisTheta(constructor = c("guide_axis_theta", "next"), ...)opts_GuideAxisTheta(constructor = c("guide_axis_theta", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_axis_theta" (default): We build the object using ggplot2::guide_axis_theta().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideAxisTheta>
These options will be used on objects of class 'GuideBins'.
opts_GuideBins(constructor = c("guide_bins", "next"), ...)opts_GuideBins(constructor = c("guide_bins", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_bins" (default): We build the object using ggplot2::guide_bins().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideBins>
These options will be used on objects of class 'GuideColourbar'.
opts_GuideColourbar(constructor = c("guide_colorbar", "next"), ...)opts_GuideColourbar(constructor = c("guide_colorbar", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_colorbar" (default): We build the object using ggplot2::guide_colorbar().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideColourbar>
These options will be used on objects of class 'GuideColoursteps'.
opts_GuideColoursteps(constructor = c("guide_colorsteps", "next"), ...)opts_GuideColoursteps(constructor = c("guide_colorsteps", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_colorsteps" (default): We build the object using ggplot2::guide_colorsteps().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideColoursteps>
These options will be used on objects of class 'GuideCustom'.
opts_GuideCustom(constructor = c("guide_custom", "next"), ...)opts_GuideCustom(constructor = c("guide_custom", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_custom" (default): We build the object using ggplot2::guide_custom().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideCustom>
These options will be used on objects of class 'GuideLegend'.
opts_GuideLegend(constructor = c("guide_legend", "next"), ...)opts_GuideLegend(constructor = c("guide_legend", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_legend" (default): We build the object using ggplot2::guide_legend().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideLegend>
These options will be used on objects of class 'GuideNone'.
opts_GuideNone(constructor = c("guide_none", "next"), ...)opts_GuideNone(constructor = c("guide_none", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guide_none" (default): We build the object using ggplot2::guide_none().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_GuideNone>
These options will be used on objects of class 'Guides'.
opts_Guides(constructor = c("guides", "next"), ...)opts_Guides(constructor = c("guides", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"guides" (default): We build the object using ggplot2::guides().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_Guides>
These options will be used on objects of class 'haven_labelled'.
opts_haven_labelled(constructor = c("labelled", "next"), ...)opts_haven_labelled(constructor = c("labelled", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"labelled" (default): We build the object using haven::labelled(),
the labels and label arguments are omitted when NULL.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_haven_labelled>
These options will be used on objects of class 'haven_labelled_spss'.
opts_haven_labelled_spss(constructor = c("labelled_spss", "next"), ...)opts_haven_labelled_spss(constructor = c("labelled_spss", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"labelled_spss" (default): We build the object using
haven::labelled_spss(), the labels, na_values, na_range and label
arguments are omitted when NULL.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_haven_labelled_spss>
These options will be used on objects of class 'hexmode'.
opts_hexmode(constructor = c("as.hexmode", "next"), ..., integer = FALSE)opts_hexmode(constructor = c("as.hexmode", "next"), ..., integer = FALSE)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
integer |
Whether to use |
Depending on constructor, we construct the object as follows:
"as.hexmode" (default): We build the object using as.hexmode()
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_hexmode>
These options will be used on objects of class 'hms'.
opts_hms(constructor = c("as_hms", "hms", "new_hms", "next", "double"), ...)opts_hms(constructor = c("as_hms", "hms", "new_hms", "next", "double"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_hms" (default): We build the object using hms::as_hms() on a
character vector in the format "12:34:56". If some values cannot be
reproduced exactly this way (e.g. negative values, durations of more than
24 hours, or some fractional seconds) we fall back to the "hms" constructor.
"hms" : We build the object using hms::hms() on seconds, minutes
and hours arguments. If the decomposition is not exact we provide
only the seconds argument.
"new_hms" : We build the object using hms::new_hms() on a double vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"double" : We define as an atomic vector and repair attributes.
An object of class <constructive_options/constructive_options_hms>
These options will be used on objects of class 'html'.
opts_html(constructor = c("HTML", "next"), ...)opts_html(constructor = c("HTML", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"HTML" (default): We build the object using htmltools::HTML().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_html>
These options will be used on objects of class 'html_dependency'.
opts_html_dependency(constructor = c("htmlDependency", "next"), ...)opts_html_dependency(constructor = c("htmlDependency", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"htmlDependency" (default): We build the object using
htmltools::htmlDependency(), arguments left to their default values are omitted.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_html_dependency>
These options will be used on objects of class 'IDate'.
opts_IDate(constructor = c("as.IDate", "next", "integer"), ...)opts_IDate(constructor = c("as.IDate", "next", "integer"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.IDate" (default): We build the object using data.table::as.IDate()
on a character vector, or on an integer vector if some dates cannot be
formatted as "YYYY-MM-DD" strings (years outside of 1 to 9999).
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"integer" : We define as an integer vector and repair attributes.
An object of class <constructive_options/constructive_options_IDate>
These options will be used on objects of class 'indMatrix' from the 'Matrix' package, including objects of its subclass 'pMatrix'.
opts_indMatrix(constructor = c("as", "next"), ...)opts_indMatrix(constructor = c("as", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as" (default): We build the object using as() on the perm integer
vector, or on a list of perm and the number of columns when it cannot be
inferred, and apply Matrix::t() if the object's margin is 2.
If this cannot reproduce the object exactly (e.g. dimnames) we fall back
to the next constructor.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_indMatrix>
These options will be used on objects of type 'integer'. This type has a single native constructor, but some additional options can be set.
To set options on all atomic types at once see opts_atomic().
opts_integer( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )opts_integer( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
An object of class <constructive_options/constructive_options_integer>
These options will be used on objects of class 'integer64'.
opts_integer64(constructor = c("as.integer64", "next", "double"), ...)opts_integer64(constructor = c("as.integer64", "next", "double"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.integer64" (default): Build the object using as.integer64() on a
character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"double" : We define as an atomic vector and repair attributes.
We don't recommend the "next" and "double" constructors for this class as
they give incorrect results on negative or NA "integer64" objects
due to some quirks in the implementation of the 'bit64' package.
An object of class <constructive_options/constructive_options_integer64>
These options will be used on objects of class 'Interval'.
opts_Interval(constructor = c("interval", "next"), ...)opts_Interval(constructor = c("interval", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"interval" (default): We build the object using lubridate::interval()
on "POSIXct" start and end vectors. If the end dates can't be computed
in a way that reproduces the object exactly (floating point issues), or if
the time zone of the start dates differs from the tzone slot, we fall
back to the next constructor.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_Interval>
These options will be used on objects of class 'ITime'.
opts_ITime(constructor = c("as.ITime", "next", "integer"), ...)opts_ITime(constructor = c("as.ITime", "next", "integer"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.ITime" (default): We build the object using data.table::as.ITime()
on a character vector in the format "HH:MM:SS". Negative times and times
of 24 hours or more cannot be built this way so we fall back to the
"integer" constructor.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"integer" : We define as an integer vector and repair attributes.
An object of class <constructive_options/constructive_options_ITime>
These options will be used on objects of type 'language'. By default this function is useless as nothing can be set, this is provided in case users want to extend the method with other constructors.
opts_language(constructor = c("default"), ...)opts_language(constructor = c("default"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" : We use constructive's deparsing algorithm on attributeless calls,
and use as.call() on other language elements when attributes need to be constructed.
An object of class <constructive_options/constructive_options_language>
These options will be used on objects of class 'Layer'.
opts_Layer(constructor = c("default", "layer", "next", "environment"), ...)opts_Layer(constructor = c("default", "layer", "next", "environment"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" : We attempt to use the function originally used to create the
plot.
"layer" : We use the ggplot2::layer() function
"environment" : Reconstruct the object using the general environment method
(which can be itself tweaked using opts_environment())
The latter constructor is the only one that reproduces the object exactly
since Layers are environments and environments can't be exactly copied (see ?opts_environment)
An object of class <constructive_options/constructive_options_Layer>
These options will be used on objects of type 'list'.
opts_list( constructor = c("list", "list2"), ..., trim = NULL, fill = c("vector", "new_list", "+", "...", "none") )opts_list( constructor = c("list", "list2"), ..., trim = NULL, fill = c("vector", "new_list", "+", "...", "none") )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. |
Depending on constructor, we construct the object as follows:
"list" (default): Build the object by calling list().
"list2": Build the object by calling rlang::list2(), the only difference with
the above is that we keep a trailing comma when the list is not trimmed and the call
spans several lines.
If trim is provided, depending on fill we will present trimmed elements as followed:
"vector" (default): Use vector(), so for instance list("a", "b", "c") might become c(list("a"), vector("list", 2)).
"new_list": Use rlang::new_list(), so for instance list("a", "b", "c") might become c(list("a"), rlang::new_list(2)).
"+": Use unary +, so for instance list("a", "b", "c") might become list("a", +2).
"...": Use ..., so for instance list("a", "b", "c") might become list("a", ...)
"none": Don't represent trimmed elements.
When trim is used the output is parsable but might not be possible to evaluate,
especially with fill = "...". In that case you might want to set check = FALSE
An object of class <constructive_options/constructive_options_list>
These options will be used on objects of class 'locale'.
opts_locale(constructor = c("locale", "next", "list"), ...)opts_locale(constructor = c("locale", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"locale" (default): We build the object using readr::locale(),
providing only non default arguments. date_names is provided as a language
code when possible.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
Use opts_date_names() to tweak the construction of the date_names element,
opts_date_names("date_names") will prevent the use of a language code.
An object of class <constructive_options/constructive_options_locale>
These options will be used on objects of type 'logical'. This type has a single native constructor, but some additional options can be set.
To set options on all atomic types at once see opts_atomic().
opts_logical( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )opts_logical( constructor = c("default"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE )
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
An object of class <constructive_options/constructive_options_logical>
Matrices are atomic vectors, lists, or objects of type "expression" with a "dim"
attributes of length 2.
opts_matrix( constructor = c("matrix", "array", "cbind", "rbind", "next"), ..., byrow = FALSE )opts_matrix( constructor = c("matrix", "array", "cbind", "rbind", "next"), ..., byrow = FALSE )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
byrow |
Boolean. Only considered if |
Depending on constructor, we construct the object as follows:
"matrix" : We use matrix()
"array" : We use array()
"cbind","rbind" : We use cbind() or "rbind()", this makes named
columns and rows easier to read.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "array"
"atomic" : We define as an atomic vector and repair attributes
An object of class <constructive_options/constructive_options_matrix>
These options will be used on objects of class 'mixed_units'.
opts_mixed_units(constructor = c("mixed_units", "next"), ...)opts_mixed_units(constructor = c("mixed_units", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"mixed_units" (default): We build the object using
units::mixed_units() on a double vector and a character vector of unit
strings as given by units::deparse_unit().
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_mixed_units>
Depending on constructor, we construct the object as follows:
"ts" : We use ts()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "atomic"
"atomic" : We define as an atomic vector and repair attributes
opts_mts(constructor = c("ts", "next", "atomic"), ...)opts_mts(constructor = c("ts", "next", "atomic"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_mts>
Depending on constructor, we construct the object as follows:
"numeric_version" : We use numeric_version()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
opts_numeric_version(constructor = c("numeric_version", "next", "list"), ...)opts_numeric_version(constructor = c("numeric_version", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_numeric_version>
These options will be used on objects of class 'object'. The 'object' type
is particular in that it is an internal type in base R, but can only be
produced at time of writing through the 'S7' package. Well this is not
completely true since those can be built from S4 objects that we remove
the S4 flag from by using asS3(x, complete = FALSE) but we don't propose
this for now.
opts_object(constructor = c("prototype", "S7_object"), ...)opts_object(constructor = c("prototype", "S7_object"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"S7_object" (default): We build the object using S7::S7_object().
At the time of writing, this is currently the only way to create these objects.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_object>
These options will be used on objects of class 'octmode'.
opts_octmode(constructor = c("as.octmode", "next"), ..., integer = FALSE)opts_octmode(constructor = c("as.octmode", "next"), ..., integer = FALSE)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
integer |
Whether to use |
Depending on constructor, we construct the object as follows:
"as.octmode" (default): We build the object using as.octmode()
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_octmode>
These options will be used on objects of class 'ordered'.
opts_ordered( constructor = c("ordered", "factor", "new_ordered", "next", "integer"), ... )opts_ordered( constructor = c("ordered", "factor", "new_ordered", "next", "integer"), ... )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"ordered" (default): Build the object using ordered(), levels won't
be defined explicitly if they are in alphabetical order (locale dependent!)
"factor" : Same as above but build the object using factor() and ordered = TRUE.
"new_ordered" : Build the object using vctrs::new_ordered(). Levels are
always defined explicitly.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"integer" : We define as an integer vector and repair attributes
An object of class <constructive_options/constructive_options_ordered>
Depending on constructor, we construct the object as follows:
"package_version" : We use package_version()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "array"
"list" : We define as a list and repair attributes
opts_package_version(constructor = c("package_version", "next", "list"), ...)opts_package_version(constructor = c("package_version", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_package_version>
Depending on constructor, we construct the object as follows:
"pairlist" (default): Build the object using a pairlist() call.
"pairlist2" : Build the object using a rlang::pairlist2() call.
opts_pairlist(constructor = c("pairlist", "pairlist2"), ...)opts_pairlist(constructor = c("pairlist", "pairlist2"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_pairlist>
These options will be used on objects of class 'Period'.
opts_Period(constructor = c("period", "next"), ...)opts_Period(constructor = c("period", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"period" (default): We build the object using lubridate::period(),
providing the years, months, days, hours, minutes and seconds
arguments, omitting the components that are zero for all elements.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_Period>
These options will be used on objects of class 'POSIXct'.
opts_POSIXct( constructor = c("as.POSIXct", ".POSIXct", "as_datetime", "as.POSIXct.numeric", "as_datetime.numeric", "next", "atomic"), ..., origin = "1970-01-01" )opts_POSIXct( constructor = c("as.POSIXct", ".POSIXct", "as_datetime", "as.POSIXct.numeric", "as_datetime.numeric", "next", "atomic"), ..., origin = "1970-01-01" )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
origin |
Origin to be used, ignored when irrelevant. |
Depending on constructor, we construct the object as follows:
"as.POSIXct" (default): Build the object using a as.POSIXct() call on a
character vector.
".POSIXct" : Build the object using a .POSIXct() call on a numeric vector.
"as_datetime" : Build the object using a lubridate::as_datetime() call on
a character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"atomic" : We define as an atomic vector and repair attributes.
If the data is not appropriate for a constructor we fall back to another one
appropriately. In particular corrupted POSIXct objects such as those defined
on top of integers (or worse) are all constructed with the ".POSIXct" constructor.
An object of class <constructive_options/constructive_options_POSIXct>
These options will be used on objects of class 'POSIXlt'.
opts_POSIXlt(constructor = c("as.POSIXlt", "next", "list"), ...)opts_POSIXlt(constructor = c("as.POSIXlt", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.POSIXlt" (default): Build the object using a as.POSIXlt() call on a
character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : We define as a list and repair attributes.
An object of class <constructive_options/constructive_options_POSIXlt>
These options will be used on objects of class 'quosure'.
opts_quosure(constructor = c("new_quosure", "next", "language"), ...)opts_quosure(constructor = c("new_quosure", "next", "language"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_quosure" (default): Build the object using a new_quosure() call on a
character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"language" : We define as an language object and repair attributes.
An object of class <constructive_options/constructive_options_quosure>
These options will be used on objects of class 'quosures'.
opts_quosures(constructor = c("new_quosures", "next", "list"), ...)opts_quosures(constructor = c("new_quosures", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as_quosures" (default): Build the object using a as_quosures() call on a
character vector.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : We define as an list object and repair attributes.
An object of class <constructive_options/constructive_options_quosures>
Depending on constructor, we construct the object as follows:
"R_system_version" : We use R_system_version()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "list"
"list" : We define as a list and repair attributes
opts_R_system_version(constructor = c("R_system_version", "next", "list"), ...)opts_R_system_version(constructor = c("R_system_version", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_R_system_version>
These options will be used on objects of class 'R6'.
opts_R6(constructor = c("R6Class", "next"), ...)opts_R6(constructor = c("R6Class", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"R6Class" (default): We build the object using R6Class()$new(), see details.
"next" : Use the constructor for the next supported class.
Objects of class "R6" are harder to construct than "R6ClassGenerator" objects,
because 'constructive' doesn't know by default the constructor (i.e. class
generator) that was used to build them. So what we do is we build a class
generator that generates this object by default. This is why the generated code
is in the form R6Class()$new().
Another layer of complexity is added when the object features an
initialize() method, we cannot implement it in the class generator because
it might change the behavior of $new() and return a wrong result (or fail).
For this reason the initialize() method when it exists is repaired as an
extra step.
construct_diff() works well to inspect the differences between two R6
objects where alternatives like waldo::compare() or base::all.equal()
don't return anything informative.
An object of class <constructive_options/constructive_options_R6>
These options will be used on objects of class 'R6ClassGenerator'.
opts_R6ClassGenerator(constructor = c("R6Class", "next"), ...)opts_R6ClassGenerator(constructor = c("R6Class", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"R6Class" (default): We build the object using R6Class().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_R6ClassGenerator>
These options will be used on objects of class 'raster'.
opts_raster(constructor = c("as.raster", "next"), ...)opts_raster(constructor = c("as.raster", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.raster" (default): We build the object using as.raster() on a
character matrix of colors.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_matrix("matrix"), note that the colors of a raster
are stored row by row.
An object of class <constructive_options/constructive_options_raster>
These options will be used on objects of type 'raw'.
Depending on constructor, we construct the object as follows:
"as.raw" (default): Use as.raw(), or raw() when relevant
"charToRaw" : Use charToRaw() on a string, if the a raw vector contains
a zero we fall back to the "as.raw" constructor.
To set options on all atomic types at once see opts_atomic().
opts_raw( constructor = c("as.raw", "charToRaw"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, representation = c("hexadecimal", "decimal") )opts_raw( constructor = c("as.raw", "charToRaw"), ..., trim = NULL, fill = c("default", "rlang", "+", "...", "none"), compress = TRUE, representation = c("hexadecimal", "decimal") )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. See |
compress |
Boolean. If |
representation |
For "as.raw" constructor. Respectively generate output
in the formats |
An object of class <constructive_options/constructive_options_raw>
These options will be used on objects of class 'roman'.
opts_roman(constructor = c("as.roman", "next"), ...)opts_roman(constructor = c("as.roman", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.roman" (default): We build the object using as.roman() on a
character vector of roman numerals.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_integer().
An object of class <constructive_options/constructive_options_roman>
These options will be used on objects of class 'rowwise_df'.
opts_rowwise_df(constructor = c("default", "next", "list"), ...)opts_rowwise_df(constructor = c("default", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : We define as an list object and repair attributes.
An object of class <constructive_options/constructive_options_rowwise_df>
These options will be used on objects of class 'S4'.
opts_S4(constructor = c("new", "prototype"), ...)opts_S4(constructor = c("new", "prototype"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new" (default): We build the function using new() if possible.
If the class has a "initialize" method we have no practical way to
reverse-engineer the inputs so we fall back to the "prototype" constructor
"prototype" : We start from getClass("S4")@prototype and add attributes.
An object of class <constructive_options/constructive_options_S4>
These options will be used on objects of class 'S7_any'.
opts_S7_any(constructor = c("class_any", "next"), ...)opts_S7_any(constructor = c("class_any", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"class_any" (default): We build the object using S7::class_any().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_any>
These options will be used on objects of class 'S7_base_class'.
opts_S7_base_class(constructor = c("S7", "next"), ...)opts_S7_base_class(constructor = c("S7", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"S7" (default): We build the object using S7().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_base_class>
These options will be used on objects of class 'S7_class'.
opts_S7_class(constructor = c("new_class", "next"), ...)opts_S7_class(constructor = c("new_class", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_class" (default): We build the object using S7::new_class().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_class>
These options will be used on objects of class 'S7_external_generic'.
opts_S7_external_generic(constructor = c("new_external_generic", "next"), ...)opts_S7_external_generic(constructor = c("new_external_generic", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_external_generic" (default): We build the object using S7::new_external_generic().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_external_generic>
These options will be used on objects of class 'S7_generic'.
opts_S7_generic(constructor = c("new_generic", "next"), ...)opts_S7_generic(constructor = c("new_generic", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_generic" (default): We build the object using S7::new_generic().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_generic>
These options will be used on objects of class 'S7_object'. This class is
unusual in that it can be applied on objects of different internal types,
objects of length 1 class "S7_object" are of type "object" while
for instance objects of class c("S7_class", "S7_object") are closures.
For closures we fall back to the next method.
opts_S7_object(constructor = c("S7_object", "next"), ...)opts_S7_object(constructor = c("S7_object", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"S7_object" (default): We build the object using S7::S7_object().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_object>
The information above is correct only starting from R 4.4. The "object" type was introduced in R 4.4 and the S7 package uses the "S4" type instead for previous versions.
These options will be used on objects of class 'S7_property'.
opts_S7_property(constructor = c("new_property", "next"), ...)opts_S7_property(constructor = c("new_property", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_property" (default): We build the object using S7::new_property().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_property>
These options will be used on objects of class 'S7_S3_class'.
opts_S7_S3_class(constructor = c("new_S3_class", "next"), ...)opts_S7_S3_class(constructor = c("new_S3_class", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_S3_class" (default): We build the object using S7::new_S3_class().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_S3_class>
These options will be used on objects of class 'S7_union'.
opts_S7_union(constructor = c("default", "|", "new_union", "next"), ...)opts_S7_union(constructor = c("default", "|", "new_union", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"default" : We build the object using its name if it's a "class_union"
object provided by the 'S7' package, or fall back to the "|" constructor.
"|" : We build the object using the | operator.
"new_union" (default): We build the object using S7::new_union().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_S7_union>
These options will be used on objects of class 'sf', simple feature data frames from the 'sf' package.
opts_sf(constructor = c("st_sf", "next"), ...)opts_sf(constructor = c("st_sf", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"st_sf" (default): We build the object using sf::st_sf() on the columns,
or on a tibble if the object is also a tibble, with sf_column_name and
agr arguments if relevant.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
sf::st_sf() places the geometry columns last and doesn't support list
columns or names that clash with its arguments unless the input is a tibble,
in these cases we use the next constructor.
An object of class <constructive_options/constructive_options_sf>
These options will be used on objects of class 'sfc', simple feature geometry list-columns from the 'sf' package.
opts_sfc(constructor = c("st_sfc", "next"), ...)opts_sfc(constructor = c("st_sfc", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"st_sfc" (default): We build the object using sf::st_sfc() on the
geometries, with crs and precision arguments if relevant. The other
attributes ("bbox", "n_empty", "classes"...) are computed by sf::st_sfc()
and are repaired only if they don't match.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_sfc>
These options will be used on objects of class 'sfg', simple feature geometries from the 'sf' package.
opts_sfg(constructor = c("st_sfg", "next"), ...)opts_sfg(constructor = c("st_sfg", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"st_sfg" (default): We build the object using the sf constructor
matching the geometry type, i.e. sf::st_point(), sf::st_multipoint(),
sf::st_linestring(), sf::st_multilinestring(), sf::st_polygon(),
sf::st_multipolygon() or sf::st_geometrycollection(), with a dim
argument when the dimension can't be inferred from the coordinates.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
Other geometry types, such as "CIRCULARSTRING", don't have a dedicated constructor and are built with the next constructor.
An object of class <constructive_options/constructive_options_sfg>
These options will be used on objects of class 'shiny.tag'.
opts_shiny.tag(constructor = c("tags", "tag", "next"), ...)opts_shiny.tag(constructor = c("tags", "tag", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"tags" (default): We build the object using htmltools::tags$<name>(),
e.g. htmltools::tags$div(), with attributes as named arguments and children as
unnamed arguments. If the tag name is not a known tag or if some attributes
would clash with the formal arguments of the tag function, we fall back to
the "tag" constructor.
"tag" : We build the object using htmltools::tag(). htmltools::tag()
can't create an empty named list of attributes (as htmltools::tags$div()
does), in this case we fall back to the "tags" constructor for known tag
names, and to the list constructor otherwise.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_shiny.tag>
These options will be used on objects of class 'shiny.tag.function'.
opts_shiny.tag.function(constructor = c("tagFunction", "next"), ...)opts_shiny.tag.function(constructor = c("tagFunction", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"tagFunction" (default): We build the object using htmltools::tagFunction().
"next" : Use the constructor for the next supported class.
Use opts_function() to tweak the construction of the function.
An object of class <constructive_options/constructive_options_shiny.tag.function>
These options will be used on objects of class 'shiny.tag.list'.
opts_shiny.tag.list(constructor = c("tagList", "next"), ...)opts_shiny.tag.list(constructor = c("tagList", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"tagList" (default): We build the object using htmltools::tagList().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_shiny.tag.list>
These options will be used on objects of class 'sparseMatrix' from the 'Matrix' package in compressed column, compressed row or triplet form, i.e. objects of classes such as 'dgCMatrix', 'dgRMatrix', 'dgTMatrix', 'lgCMatrix', 'ngCMatrix', 'dsCMatrix' or 'dtCMatrix'.
opts_sparseMatrix(constructor = c("sparseMatrix", "next"), ...)opts_sparseMatrix(constructor = c("sparseMatrix", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"sparseMatrix" (default): We build the object using
Matrix::sparseMatrix() on the (1-based) row and column indices of the
stored entries. If this cannot reproduce the object exactly (e.g. cached
factorizations, unit triangular matrices) we fall back to the next
constructor.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_sparseMatrix>
These options will be used on objects of class 'sparseVector' from the 'Matrix' package, i.e. objects of classes such as 'dsparseVector', 'isparseVector', 'lsparseVector', 'nsparseVector' or 'zsparseVector'.
opts_sparseVector(constructor = c("sparseVector", "next"), ...)opts_sparseVector(constructor = c("sparseVector", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"sparseVector" (default): We build the object using
Matrix::sparseVector().
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_sparseVector>
These options will be used on objects of class 'stepfun'.
opts_stepfun(constructor = c("stepfun", "next"), ...)opts_stepfun(constructor = c("stepfun", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"stepfun" (default): We build the object using stepfun(), the arguments
are retrieved from the function's enclosure. The "call" attribute is
repaired if it differs from the constructed call.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_function().
An object of class <constructive_options/constructive_options_stepfun>
These options will be used on objects of class 'Surv'.
opts_Surv(constructor = c("Surv", "next"), ...)opts_Surv(constructor = c("Surv", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"Surv" (default): We build the object using survival::Surv() on the
columns of the object. Interval censored data is built using
type = "interval2" whenever possible, type = "interval" otherwise.
Multi-state data is built by providing a factor to the event argument.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_Surv>
These options will be used on objects of class 'table'.
opts_table(constructor = c("as.table", "next"), ...)opts_table(constructor = c("as.table", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.table" (default): We build the object using as.table() on an array
or a matrix. Objects of class "xtabs" are built this way too, their class
and "call" attribute are then repaired.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to opts_matrix("matrix") or opts_array("array").
An object of class <constructive_options/constructive_options_table>
These options will be used on objects of class 'tbl_df', also known as tibbles.
opts_tbl_df( constructor = c("tibble", "tribble", "next", "list"), ..., trailing_comma = TRUE, justify = c("left", "right", "centre", "none"), recycle = TRUE )opts_tbl_df( constructor = c("tibble", "tribble", "next", "list"), ..., trailing_comma = TRUE, justify = c("left", "right", "centre", "none"), recycle = TRUE )
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
trailing_comma |
Boolean. Whether to leave a trailing comma at the end of the constructor call calls |
justify |
String. Justification for columns if |
recycle |
Boolean. For the |
Depending on constructor, we construct the object as follows:
"tibble" (default): Wrap the column definitions in a tibble::tibble() call.
"tribble" : We build the object using tibble::tribble() if possible, and fall
back to tibble::tibble().
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_tbl_df>
These options will be used on objects of class 'tbl_ts', also known as tsibbles.
opts_tbl_ts(constructor = c("tsibble", "as_tsibble", "next"), ...)opts_tbl_ts(constructor = c("tsibble", "as_tsibble", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"tsibble" (default): Wrap the column definitions in a tsibble::tsibble()
call. If some column names conflict with the arguments of tsibble::tsibble()
we fall back to "as_tsibble".
"as_tsibble" : Construct the underlying tibble and pipe it into
tsibble::as_tsibble(). Use opts_tbl_df() to tweak the construction
of the tibble.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
The "interval" attribute is always recomputed by 'tsibble', we only set
regular = FALSE for irregular tsibbles.
An object of class <constructive_options/constructive_options_tbl_ts>
Depending on constructor, we construct the object as follows:
"ts" : We use ts()
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried. This will usually
be equivalent to "atomic"
"atomic" : We define as an atomic vector and repair attributes
opts_ts(constructor = c("ts", "next", "atomic"), ...)opts_ts(constructor = c("ts", "next", "atomic"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_ts>
These options will be used on objects of class 'units'.
opts_units(constructor = c("set_units", "as_units", "next"), ...)opts_units(constructor = c("set_units", "as_units", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"set_units" (default): We build the object using
units::set_units(x, value, mode = "standard") where value is the unit
string as given by units::deparse_unit().
"as_units" : We build the object using units::as_units(x, value).
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_units>
These options will be used on objects of class 'data.table'.
opts_vctrs_list_of(constructor = c("list_of", "next", "list"), ...)opts_vctrs_list_of(constructor = c("list_of", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"list_of" (default): Wrap the column definitions in a list_of() call.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_vctrs_list_of>
These options will be used on objects of class 'vctrs_rcrd'.
opts_vctrs_rcrd(constructor = c("new_rcrd", "next", "list"), ...)opts_vctrs_rcrd(constructor = c("new_rcrd", "next", "list"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_rcrd" (default): Use vctrs::new_rcrd() on the list of fields,
additional attributes are passed through ... and subclasses through the
class argument, so this constructor also works for classes built on top
of 'vctrs_rcrd'.
"next" : Use the constructor for the next supported class.
"list" : Use list() and treat the class as a regular attribute.
An object of class <constructive_options/constructive_options_vctrs_rcrd>
These options will be used on objects of class 'vctrs_unspecified'.
opts_vctrs_unspecified(constructor = c("unspecified", "next"), ...)opts_vctrs_unspecified(constructor = c("unspecified", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"unspecified" (default): Use vctrs::unspecified() on the length of the
object.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_vctrs_unspecified>
These options will be used on objects of class 'vctrs_vctr'.
opts_vctrs_vctr(constructor = c("new_vctr", "next"), ...)opts_vctrs_vctr(constructor = c("new_vctr", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"new_vctr" (default): Use vctrs::new_vctr() on the underlying vector,
additional attributes are passed through ..., subclasses through the
class argument and inherit_base_type is set when needed, so this
constructor also works for classes built on top of 'vctrs_vctr'.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_vctrs_vctr>
weakref
These options will be used on objects of type weakref. weakref objects
are rarely encountered and there is no base R function to create them. However
rlang has a new_weakref function that we can use.
opts_weakref(constructor = c("new_weakref"), ...)opts_weakref(constructor = c("new_weakref"), ...)
constructor |
String. Name of the constructor. |
... |
Additional options used by user defined constructors through the |
An object of class <constructive_options/constructive_options_array>
These options will be used on objects of class 'xml_document'.
opts_xml_document(constructor = c("default", "next"), ..., simplify = TRUE)opts_xml_document(constructor = c("default", "next"), ..., simplify = TRUE)
constructor |
String. Name of the constructor, often the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
simplify |
Whether to remove the "meta http-equiv" and "!DOCTYPE" tags from the input if they're the default ones. |
Depending on constructor, we construct the object as follows:
"default" (default): We build the object using xml2::read_xml() or xml2::read_html()
on a string.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_xml_document>
These options will be used on objects of class 'xts'.
opts_xts( constructor = c("xts", "as.xts.matrix", "as.xts.data.frame", ".xts", "next"), ... )opts_xts( constructor = c("xts", "as.xts.matrix", "as.xts.data.frame", ".xts", "next"), ... )
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"xts" (default): We build the object using xts::xts(), the index is
provided as a Date or POSIXct vector depending on its class.
"as.xts.matrix": We build the object using xts::as.xts.matrix(), the
index is provided through row names, which doesn't preserve its class and
time zone.
"as.xts.data.frame": We build the object using xts::as.xts.data.frame(),
this is probably the most readable option but couldn't be made the default
constructor because it requires the 'xts' package to be installed .
".xts": We build the object using xts::.xts().
"next": Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_xts>
These options will be used on objects of class 'yearmon'.
opts_yearmon(constructor = c("as.yearmon", "yearmon", "next"), ...)opts_yearmon(constructor = c("as.yearmon", "yearmon", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.yearmon" (default): We build the object using zoo::as.yearmon() on
a string in the format "2000 Q3".
"yearmon" : We build the object using zoo::yearmon() on a double in the
format 2000.5
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_yearmon>
These options will be used on objects of class 'yearmonth'.
opts_yearmonth(constructor = c("yearmonth", "next"), ...)opts_yearmonth(constructor = c("yearmonth", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"yearmonth" (default): We build the object using tsibble::yearmonth()
on a string in the format "2024 Jan". If the object contains NAs or
years that can't be parsed from a string, we use a Date object as an
input instead.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_yearmonth>
These options will be used on objects of class 'yearqtr'.
opts_yearqtr(constructor = c("as.yearqtr", "yearqtr", "next"), ...)opts_yearqtr(constructor = c("as.yearqtr", "yearqtr", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"as.yearqtr" (default): We build the object using zoo::as.yearqtr() on
a string in the format "2000 Q3".
"yearqtr" : We build the object using zoo::yearqtr() on a double in the
format 2000.5
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_yearqtr>
These options will be used on objects of class 'yearquarter'.
opts_yearquarter(constructor = c("yearquarter", "next"), ...)opts_yearquarter(constructor = c("yearquarter", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"yearquarter" (default): We build the object using tsibble::yearquarter()
on a string in the format "2024 Q1". If the object contains NAs or
years that can't be parsed from a string, we use a Date object as an
input instead.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_yearquarter>
These options will be used on objects of class 'yearweek'.
opts_yearweek(constructor = c("yearweek", "next"), ...)opts_yearweek(constructor = c("yearweek", "next"), ...)
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"yearweek" (default): We build the object using tsibble::yearweek()
on a string in the format "2024 W01". If the object contains NAs or
years that can't be parsed from a string, we use a Date object as an
input instead.
"next" : Use the constructor for the next supported class. Call .class2()
on the object to see in which order the methods will be tried.
An object of class <constructive_options/constructive_options_yearweek>
These options will be used on objects of class 'zoo'.
opts_zoo(constructor = c("zoo", "next"), ...)opts_zoo(constructor = c("zoo", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"zoo" (default): We build the object using zoo::zoo().
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_zoo>
These options will be used on objects of class 'zooreg'.
opts_zooreg(constructor = c("zooreg", "next"), ...)opts_zooreg(constructor = c("zooreg", "next"), ...)
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
Depending on constructor, we construct the object as follows:
"zooreg" (default): We build the object using zoo::zooreg(), using the
start and frequency arguments.
"next" : Use the constructor for the next supported class.
An object of class <constructive_options/constructive_options_zooreg>
These opts_*() functions are not extensively documented yet. Hopefully
the signature is self explanatory, if not please
raise an issue
opts_NULL(constructor = "NULL", ...) opts_bibentry(constructor = c("bibentry", "next"), ...) opts_citationFooter(constructor = c("citFooter", "next"), ...) opts_citationHeader(constructor = c("citHeader", "next"), ...) opts_difftime(constructor = c("as.difftime", "next"), ...) opts_error(constructor = c("errorCondition", "next"), ...) opts_expression(constructor = c("default"), ...) opts_CoordCartesian( constructor = c("default", "coord_cartesian", "next", "environment"), ... ) opts_CoordFixed(constructor = c("coord_fixed", "next", "environment"), ...) opts_CoordFlip(constructor = c("coord_flip", "next", "environment"), ...) opts_CoordMap(constructor = c("coord_map", "next", "environment"), ...) opts_CoordMunch(constructor = c("coord_munch", "next", "environment"), ...) opts_CoordPolar(constructor = c("coord_polar", "next", "environment"), ...) opts_CoordQuickmap( constructor = c("coord_quickmap", "next", "environment"), ... ) opts_CoordSf(constructor = c("coord_sf", "next", "environment"), ...) opts_CoordTrans(constructor = c("coord_trans", "next", "environment"), ...) opts_FacetGrid( constructor = c("facet_grid", "ggproto", "next", "environment"), ... ) opts_FacetWrap( constructor = c("facet_wrap", "ggproto", "next", "environment"), ... ) opts_Guide(constructor = c("default", "next", "environment"), ...) opts_Scale(constructor = c("default", "next", "environment"), ...) opts_ScalesList(constructor = c("ScalesList", "next", "list"), ...) opts_element_blank(constructor = c("element_blank", "next", "list"), ...) opts_element_grob(constructor = c("element_grob", "next", "list"), ...) opts_element_line(constructor = c("element_line", "next", "list"), ...) opts_element_rect(constructor = c("element_rect", "next", "list"), ...) opts_element_render(constructor = c("element_render", "next", "list"), ...) opts_element_text(constructor = c("element_text", "next", "list"), ...) opts_ggplot2_element_blank(constructor = c("element_blank", "next"), ...) opts_ggplot2_element_geom(constructor = c("element_geom", "next"), ...) opts_ggplot2_element_line(constructor = c("element_line", "next"), ...) opts_ggplot2_element_point(constructor = c("element_point", "next"), ...) opts_ggplot2_element_polygon(constructor = c("element_polygon", "next"), ...) opts_ggplot2_element_rect(constructor = c("element_rect", "next"), ...) opts_ggplot2_element_text(constructor = c("element_text", "next"), ...) opts_ggplot2_mapping(constructor = c("aes", "next", "list"), ...) opts_ggplot2_margin(constructor = c("margin", "next", "double"), ...) opts_ggplot2_theme(constructor = c("default", "theme", "next", "list"), ...) opts_ggproto(constructor = c("default", "ggproto", "next", "environment"), ...) opts_labels(constructor = c("labs", "next", "list"), ...) opts_margin(constructor = c("margin", "next", "double"), ...) opts_rel(constructor = c("rel", "next", "double"), ...) opts_theme(constructor = c("default", "theme", "next", "list"), ...) opts_uneval(constructor = c("aes", "next", "list"), ...) opts_waiver(constructor = c("waiver", "next", "list"), ...) opts_noquote(constructor = c("noquote", "next"), ...) opts_person(constructor = c("person", "next"), ...) opts_simpleCondition(constructor = c("simpleCondition", "next"), ...) opts_simpleError(constructor = c("simpleError", "next"), ...) opts_simpleMessage(constructor = c("simpleMessage", "next"), ...) opts_simpleUnit(constructor = c("unit", "next", "double"), ...) opts_simpleWarning(constructor = c("simpleWarning", "next"), ...) opts_warning(constructor = c("warningCondition", "next"), ...)opts_NULL(constructor = "NULL", ...) opts_bibentry(constructor = c("bibentry", "next"), ...) opts_citationFooter(constructor = c("citFooter", "next"), ...) opts_citationHeader(constructor = c("citHeader", "next"), ...) opts_difftime(constructor = c("as.difftime", "next"), ...) opts_error(constructor = c("errorCondition", "next"), ...) opts_expression(constructor = c("default"), ...) opts_CoordCartesian( constructor = c("default", "coord_cartesian", "next", "environment"), ... ) opts_CoordFixed(constructor = c("coord_fixed", "next", "environment"), ...) opts_CoordFlip(constructor = c("coord_flip", "next", "environment"), ...) opts_CoordMap(constructor = c("coord_map", "next", "environment"), ...) opts_CoordMunch(constructor = c("coord_munch", "next", "environment"), ...) opts_CoordPolar(constructor = c("coord_polar", "next", "environment"), ...) opts_CoordQuickmap( constructor = c("coord_quickmap", "next", "environment"), ... ) opts_CoordSf(constructor = c("coord_sf", "next", "environment"), ...) opts_CoordTrans(constructor = c("coord_trans", "next", "environment"), ...) opts_FacetGrid( constructor = c("facet_grid", "ggproto", "next", "environment"), ... ) opts_FacetWrap( constructor = c("facet_wrap", "ggproto", "next", "environment"), ... ) opts_Guide(constructor = c("default", "next", "environment"), ...) opts_Scale(constructor = c("default", "next", "environment"), ...) opts_ScalesList(constructor = c("ScalesList", "next", "list"), ...) opts_element_blank(constructor = c("element_blank", "next", "list"), ...) opts_element_grob(constructor = c("element_grob", "next", "list"), ...) opts_element_line(constructor = c("element_line", "next", "list"), ...) opts_element_rect(constructor = c("element_rect", "next", "list"), ...) opts_element_render(constructor = c("element_render", "next", "list"), ...) opts_element_text(constructor = c("element_text", "next", "list"), ...) opts_ggplot2_element_blank(constructor = c("element_blank", "next"), ...) opts_ggplot2_element_geom(constructor = c("element_geom", "next"), ...) opts_ggplot2_element_line(constructor = c("element_line", "next"), ...) opts_ggplot2_element_point(constructor = c("element_point", "next"), ...) opts_ggplot2_element_polygon(constructor = c("element_polygon", "next"), ...) opts_ggplot2_element_rect(constructor = c("element_rect", "next"), ...) opts_ggplot2_element_text(constructor = c("element_text", "next"), ...) opts_ggplot2_mapping(constructor = c("aes", "next", "list"), ...) opts_ggplot2_margin(constructor = c("margin", "next", "double"), ...) opts_ggplot2_theme(constructor = c("default", "theme", "next", "list"), ...) opts_ggproto(constructor = c("default", "ggproto", "next", "environment"), ...) opts_labels(constructor = c("labs", "next", "list"), ...) opts_margin(constructor = c("margin", "next", "double"), ...) opts_rel(constructor = c("rel", "next", "double"), ...) opts_theme(constructor = c("default", "theme", "next", "list"), ...) opts_uneval(constructor = c("aes", "next", "list"), ...) opts_waiver(constructor = c("waiver", "next", "list"), ...) opts_noquote(constructor = c("noquote", "next"), ...) opts_person(constructor = c("person", "next"), ...) opts_simpleCondition(constructor = c("simpleCondition", "next"), ...) opts_simpleError(constructor = c("simpleError", "next"), ...) opts_simpleMessage(constructor = c("simpleMessage", "next"), ...) opts_simpleUnit(constructor = c("unit", "next", "double"), ...) opts_simpleWarning(constructor = c("simpleWarning", "next"), ...) opts_warning(constructor = c("warningCondition", "next"), ...)
constructor |
String. Method used to construct the object, often the name of a function. |
... |
Additional options used by user defined constructors through the |
.cstr_new_class() and .cstr_new_constructor() open new unsaved scripts,
optionally commented, that can be used as templates to define new constructors.
If the class is already supported and you want to implement a new constructor,
use .cstr_new_constructor(), otherwise use .cstr_new_class().
.cstr_new_class( class = c("CLASS", "PARENT_CLASS"), constructor = "PKG::CONSTRUCTOR", commented = FALSE ) .cstr_new_constructor( class = c("CLASS", "PARENT_CLASS"), constructor = "PKG::CONSTRUCTOR", commented = FALSE ).cstr_new_class( class = c("CLASS", "PARENT_CLASS"), constructor = "PKG::CONSTRUCTOR", commented = FALSE ) .cstr_new_constructor( class = c("CLASS", "PARENT_CLASS"), constructor = "PKG::CONSTRUCTOR", commented = FALSE )
class |
Class to support, provide the full |
constructor |
Name of the constructor, usually the name of the function you can to use to build the object. If not you might need to adjust the script. |
commented |
Boolean. Whether to include comments in the template. |
We suggest the following workflow (summarized in a message when you call the functions):
Call usethis::use_package(\"constructive\", \"Suggests\")' one time at any
point, this will add a soft dependency on 'constructive' so it's only needed to
install it when you use it.
Call .cstr_new_class() or .cstr_new_constructor(), with commented = TRUE for more guidance.
Save the scripts unchanged in the "R" folder of your package.
devtools::document(): this will register the S3 methods.
Try construct() on your new object, it should print a call to your chosen
constructor.
Tweak the code, in particular the definition of args.
The README of the example extension package
'constructive.example'
guides you through the process. See also {constructive}'s own code
and vignette("extend-constructive") for more details.
Both function return NULL invisibly and are called for side effects