Skip to content

Commit d8eff80

Browse files
committed
updated documentation
1 parent f5b156a commit d8eff80

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

BayesMallowsSMC2.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version: 1.0
2+
ProjectId: 05eac0c6-169d-4970-9e0b-098277092c56
23

34
RestoreWorkspace: Default
45
SaveWorkspace: Default

R/RcppExports.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,34 @@
77
#' saves them to a specified output directory. It ensures the output directory exists
88
#' and creates it if it does not.
99
#'
10-
#' @param prefs An integer matrix (`arma::umat`) representing the preference relations.
10+
#' @param prefs A matrix representing the preference relations. This matrix
11+
#' must have two columns, the first of which represents the preferred item
12+
#' and the second of which represents the disfavored item.
1113
#' @param n_items An integer specifying the number of items to sort.
1214
#' @param output_directory A string specifying the directory where the output files will be saved.
1315
#' @param save_frac Number between 0 and 1 specifying which fraction of sorts to save.
1416
#'
1517
#' @details
1618
#' The function generates all possible topological sorts for the provided preference matrix
17-
#' and saves each sort as a binary file in the specified output directory. The output files
18-
#' are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
19+
#' and saves approximately `save_frac` of the sorts as binary file in the specified output directory.
20+
#' The output files are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
1921
#'
2022
#' @return This function returns the number of topological sorts.
2123
#'
2224
#' @export
25+
#' @examples
26+
#' # Extract preferences from user 1 in the included example data.
27+
#' prefs <- pairwise_preferences[
28+
#' pairwise_preferences$user == 1, c("top_item", "bottom_item"), drop = FALSE]
29+
#'
30+
#' # Count the number of sorts without saving them.
31+
#' precompute_topological_sorts(
32+
#' prefs = as.matrix(prefs),
33+
#' n_items = 5,
34+
#' output_directory = tempdir(),
35+
#' save_frac = 0
36+
#' )
37+
#'
2338
precompute_topological_sorts <- function(prefs, n_items, output_directory, save_frac) {
2439
.Call(`_BayesMallowsSMC2_precompute_topological_sorts`, prefs, n_items, output_directory, save_frac)
2540
}

man/precompute_topological_sorts.Rd

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/all_topological_sorts.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,34 @@ void Graph::alltopologicalSort(const std::string& output_directory,
8787
//' saves them to a specified output directory. It ensures the output directory exists
8888
//' and creates it if it does not.
8989
//'
90-
//' @param prefs An integer matrix (`arma::umat`) representing the preference relations.
90+
//' @param prefs A matrix representing the preference relations. This matrix
91+
//' must have two columns, the first of which represents the preferred item
92+
//' and the second of which represents the disfavored item.
9193
//' @param n_items An integer specifying the number of items to sort.
9294
//' @param output_directory A string specifying the directory where the output files will be saved.
9395
//' @param save_frac Number between 0 and 1 specifying which fraction of sorts to save.
9496
//'
9597
//' @details
9698
//' The function generates all possible topological sorts for the provided preference matrix
97-
//' and saves each sort as a binary file in the specified output directory. The output files
98-
//' are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
99+
//' and saves approximately `save_frac` of the sorts as binary file in the specified output directory.
100+
//' The output files are named sequentially as `sort0.bin`, `sort1.bin`, and so on.
99101
//'
100102
//' @return This function returns the number of topological sorts.
101103
//'
102104
//' @export
105+
//' @examples
106+
//' # Extract preferences from user 1 in the included example data.
107+
//' prefs <- pairwise_preferences[
108+
//' pairwise_preferences$user == 1, c("top_item", "bottom_item"), drop = FALSE]
109+
//'
110+
//' # Count the number of sorts without saving them.
111+
//' precompute_topological_sorts(
112+
//' prefs = as.matrix(prefs),
113+
//' n_items = 5,
114+
//' output_directory = tempdir(),
115+
//' save_frac = 0
116+
//' )
117+
//'
103118
// [[Rcpp::export]]
104119
long long int precompute_topological_sorts(
105120
arma::umat prefs, int n_items, std::string output_directory, double save_frac) {

0 commit comments

Comments
 (0)