Skip to content

Commit

Permalink
move pivot_wider_by below
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Sep 13, 2023
1 parent e5e6bef commit 9546ce5
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions R/pivot.R
Original file line number Diff line number Diff line change
@@ -1,54 +1,4 @@

# FIXME

#' Pivot factor to a wider list
#'
#' This function makes it easier to see which units or records are associated
#' with a particular level of factor.
#' The arguments closely follow [tidyr::pivot_wider()], but the major difference
#' is that it is aware of the relationships between columns and makes use of
#' this to present to you information without unnecessary duplication.
#'
#' @param data An edibble table
#' @param id_cols Columns in the data where the levels correspond to a unique
#' level on the row.
#' @param id_expand If multiple columns are selected, whether all combinations of
#' the levels should be taken into account.
#' @param names_from An expression specifying which columns to pivot from.
#' @param names_prefix A prefix to add to the resulting column names.
#' @param names_sep A separator to use between column names in the resulting wide format.
#' @param names_glue A glue specification to control column names.
#' @param names_sort A logical indicating whether to sort the resulting column names.
#' @param names_vary A character vector of options to specify how to handle varying identifiers.
#' @param names_expand A logical indicating whether to expand identifiers in the column names.
#' @param names_repair A method to handle non-unique resulting column names.
#' @param values_from A character vector specifying columns to use as values in the wide format.
#' @param values_fill A value or function to fill missing values.
#' @param values_fn A function to aggregate values.
#' @seealso [split_by()] and [count_by()]
pivot_wider_by <- function(data,
id_cols = NULL,
id_expand = FALSE,
names_from = where(is_trt),
names_prefix = "",
names_sep = ":",
names_glue = NULL,
names_sort = FALSE,
names_vary = "fastest",
names_expand = FALSE,
names_repair = "check_unique",
values_from = NULL,
values_fill = NULL,
values_fn = NULL) {
not_edibble(data)

prov <- activate_provenance(data)
names_from <- enquo(names_from)
values_from <- enquo(values_from)



}


#' Split or count the data according to certain factors
Expand Down Expand Up @@ -200,3 +150,56 @@ pivot_trts_widetable <- function(.data, trts = NULL, fcts = NULL) {
rownames(res) <- 1:nrow(res)
res
}




# ADD?
#' Pivot factor to a wider list
#'
#' This function makes it easier to see which units or records are associated
#' with a particular level of factor.
#' The arguments closely follow [tidyr::pivot_wider()], but the major difference
#' is that it is aware of the relationships between columns and makes use of
#' this to present to you information without unnecessary duplication.
#'
#' @param data An edibble table
#' @param id_cols Columns in the data where the levels correspond to a unique
#' level on the row.
#' @param id_expand If multiple columns are selected, whether all combinations of
#' the levels should be taken into account.
#' @param names_from An expression specifying which columns to pivot from.
#' @param names_prefix A prefix to add to the resulting column names.
#' @param names_sep A separator to use between column names in the resulting wide format.
#' @param names_glue A glue specification to control column names.
#' @param names_sort A logical indicating whether to sort the resulting column names.
#' @param names_vary A character vector of options to specify how to handle varying identifiers.
#' @param names_expand A logical indicating whether to expand identifiers in the column names.
#' @param names_repair A method to handle non-unique resulting column names.
#' @param values_from A character vector specifying columns to use as values in the wide format.
#' @param values_fill A value or function to fill missing values.
#' @param values_fn A function to aggregate values.
#' @seealso [split_by()] and [count_by()]
pivot_wider_by <- function(data,
id_cols = NULL,
id_expand = FALSE,
names_from = where(is_trt),
names_prefix = "",
names_sep = ":",
names_glue = NULL,
names_sort = FALSE,
names_vary = "fastest",
names_expand = FALSE,
names_repair = "check_unique",
values_from = NULL,
values_fill = NULL,
values_fn = NULL) {
not_edibble(data)

prov <- activate_provenance(data)
names_from <- enquo(names_from)
values_from <- enquo(values_from)



}

0 comments on commit 9546ce5

Please sign in to comment.