Reconstruct an object from a template
reconstruct(x, template, ...)# S3 method for data.frame
reconstruct(x, template, shallow_copy = TRUE, ...)
# S3 method for data.table
reconstruct(x, template, shallow_copy = TRUE, ...)
An object similar to template
.
An object in which carefully selected attributes
will be copied into from template
.
A template object used to copy attributes into x
.
Further arguments passed onto methods.
Should x
be shallow copied before reconstructing?
Default is TRUE
.
In R attributes are difficult to work with. One big reason for this is that attributes may or may not be independent of the data. Date vectors for example have attributes completely independent of the data and hence if the attributes are removed at any point, they can easily be re-added without any calculations. Factors have almost data-independent attributes with an exception being when factors are combined. In some cases it is not possible to reconstruct attributes from the data alone.
You can add your own reconstruct
method for an object not covered
by the methods here.