Write preferences to .soc, .soi, .toc or .toi file types, as
defined by the PrefLib specification:
{PrefLib}: A Library for Preferences.
write_preflib(
x,
file = "",
preferences_col = NULL,
frequency_col = NULL,
title = NULL,
publication_date = NULL,
modification_type = NULL,
modification_date = NULL,
description = NULL,
relates_to = NULL,
related_files = NULL
)No return value. Output will be written to file or stdout.
A preferences object or a tibble with a preferences-typed
column to write to file.
Either a character string naming the a file or a writeable,
open connection. The empty string "" will write to stdout.
<tidy-select> When x is a
tibble, the column containing the preferences to be written to file.
If not provided and x is a tibble, then
<tidy-select> When x is a
tibble, the column containing the frequency of the preferences. If not
provided, each row is considered to be observed a single time.
The title of the data file, for instance the name of the
election represented in the data file. If not provided, we check for the
presence of attr(x, "preflib"), and if it exists we check for TITLE.
The date at which the data file was published for the
first time. If not provided, we check for the presence of
attr(x, "preflib"), and if it exists we check for PUBLICATION DATE.
The modification type of the data: one of
original, induced, imbued or synthetic (see Details). If not
provided, we check for the presence of attr(x, "preflib"), and if it exists
we check for MODIFICATION TYPE.
The last time the data was modified. If not
provided, we check for the presence of attr(x, "preflib"), and if it exists
we check for MODIFICATION DATE.
A description of the data file, providing additional
information about it. If not provided, we check for the presence of
attr(x, "preflib"), and if it exists we check for DESCRIPTION.
The name of the data file that the current file relates to,
typically the source file in case the current file has been derived from
another one. If not provided, we check for the presence of
attr(x, "preflib"), and if it exists we check for RELATES TO.
The list of all the data files related to this one,
comma separated. If not provided, we check for the presence of
attr(x, "preflib"), and if it exists we check for RELATED FILES.
The file types supported are
Strict Orders - Complete List
Strict Orders - Incomplete List
Orders with Ties - Complete List
Orders with Ties - Incomplete List
The PrefLib format specification requires some additional metadata. Note
that the additional metadata required for the PrefLib specification is not
necessarily required for the write_preflib method; any missing fields
required by the PrefLib format will simply show "NA".
The title of the data file, for instance the year of the election represented in the data file.
A description of the data file, providing additional information about it.
The name of the data file that the current file relates to, typically the source file in case the current file has been derived from another one.
The list of all the data files related to this one, comma separated.
The date at which the data file was published for the first time.
The modification type of the data. One of:
Data that has only been converted into a PrefLib format.
Data that has been induced from another context. For example, computing a pairwise relation from a set of strict total orders. No assumptions have been made to create these files, just a change in the expression language.
Data that has been imbued with extra information. For example, extending an incomplete partial order by placing all unranked candidates tied at the end.
Data that has been generated artificially.
The last time the data was modified.
In addition to these fields, some required PrefLib fields will be generated
automatically depending on arguments to write_preflib() and the attributes
of the aggregated_preferences object being written to file:
The name of the output file.
The data type (one of soc, soi, toc or toi).
The number of items.
XThe name of each item, where X ranges from
0 to length(items).
The total number of orderings.
The number of distinct orderings.
Note that PrefLib refers to the items as "alternatives".
The "alternatives" in the output file will be the same as the "items" in the
aggregated_preferences object.