This is a wrapper function for applying discover_keys,
relation_schema, create, and
insert. This takes a data frame and adds its keys, resulting in
a single relation. If only the keys are required, this can be much quicker
than running autodb.
Usage
autokey(
df,
keep_rownames = FALSE,
digits = getOption("digits"),
progress = FALSE,
progress_file = "",
...
)Arguments
- df
a data.frame, containing the data to be normalised.
- keep_rownames
a logical or a string, indicating whether to include the row names as a column. If a string is given, it is used as the name for the column, otherwise the column is named "row". Like with the other column names, the function returns an error if this results in duplicate column names. Set to FALSE by default.
- digits
a positive integer, indicating how many significant digits are to be used for numeric and complex variables. This is used for both pre-formatting in
discover_keys, and for rounding the data before use ininsert, so that the data satisfies the resulting schema. A value ofNAresults in no rounding. By default, this usesgetOption("digits"), similarly toformat. See the "Floating-point variables" section fordiscoverfor why this rounding is necessary for consistent results across different machines. See the note inprint.defaultaboutdigits >= 16.- progress
a logical, for whether to display progress to the user during dependency search in
discover.- progress_file
a scalar character or a connection. If
progressis non-zero, determines where the progress is written to, in the same way as thefileargument forcat.- ...
further arguments passed on to
discover_keys.
Value
A relation of length 1, containing the data in
df and its keys.