Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

335 bring teal_slice and teal_slices to package INDEX #565

Closed
wants to merge 11 commits into from
40 changes: 32 additions & 8 deletions R/teal_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@
#'
#' Create a `teal_slice` object that holds complete information on filtering one variable.
#'
# Custom @usage section is needed to that utility functions are listed in the usage and they do not have index entries.
#' @usage
#' teal_slice(
#' dataname,
#' varname,
#' id,
#' expr,
#' choices = NULL,
#' selected = NULL,
#' keep_na = NULL,
#' keep_inf = NULL,
#' fixed = FALSE,
#' anchored = FALSE,
#' multiple = TRUE,
#' title = NULL,
#' ...
#' )
#'
#' is.teal_slice(x)
#'
#' as.teal_slice(x)
#'
#' \method{as.list}{teal_slice}(x, ...)
#'
#' \method{format}{teal_slice}(x, show_all = FALSE, trim_lines = TRUE, ...)
#'
#' \method{print}{teal_slice}(x, ...)
#'
#' @details
#' `teal_slice` object fully describes filter state and can be used to create,
#' modify, and delete a filter state. A `teal_slice` contains a number of common fields
#' (all named arguments of `teal_slice`), some of which are mandatory, but only
Expand Down Expand Up @@ -110,8 +139,10 @@
#'
#' @seealso [`teal_slices`]
#'
#' @aliases is.teal_slice as.teal_slice as.list.teal_slice format.teal_slice print.teal_slice
#'
#' @export
teal_slice <- function(dataname,
teal_slice <- function(dataname, # When editing function parameters, please remember to update @usage section.
varname,
id,
expr,
Expand Down Expand Up @@ -172,15 +203,13 @@ teal_slice <- function(dataname,
ans
}

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
is.teal_slice <- function(x) { # nolint
inherits(x, "teal_slice")
}

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
Expand All @@ -189,7 +218,6 @@ as.teal_slice <- function(x) { # nolint
do.call(teal_slice, x)
}

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
Expand All @@ -208,8 +236,6 @@ as.list.teal_slice <- function(x, ...) {
x[c(formal_args, extra_args)]
}


#' @rdname teal_slice
#' @export
#' @keywords internal
#'
Expand All @@ -223,15 +249,13 @@ format.teal_slice <- function(x, show_all = FALSE, trim_lines = TRUE, ...) {
jsonify(x_list, trim_lines)
}

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
print.teal_slice <- function(x, ...) {
cat(format(x, ...))
}


# format utils -----

#' Convert a list to a justified `JSON` string
Expand Down
55 changes: 35 additions & 20 deletions R/teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@
#'
#' Create `teal_slices` object to package multiple filters and additional settings.
#'
# Custom @usage section is needed to that utility functions are listed in the usage and they do not have index entries.
#' @usage
#' teal_slices(
#' ...,
#' exclude_varnames = NULL,
#' include_varnames = NULL,
#' count_type = NULL,
#' allow_add = TRUE
#' )
#'
#' is.teal_slices(x)
#'
#' as.teal_slices(x)
#'
#' \method{as.list}{teal_slices}(x, recursive = FALSE, ...)
#'
#' \method{[}{teal_slices}(x, i)
#'
#' \method{c}{teal_slices}(...)
#'
#' \method{format}{teal_slices}(x, show_all = FALSE, trim_lines = TRUE, ...)
#'
#' \method{print}{teal_slices}(x, ...)
#'
#' @details
#' `teal_slices()` collates multiple `teal_slice` objects into a `teal_slices` object,
#' a complete filter specification. This is used by all classes above `FilterState`
#' as well as `filter_panel_api` wrapper functions.
Expand All @@ -27,10 +52,12 @@
#' - `"all"` to have counts of single `FilterState` to show number of observation in filtered
#' and unfiltered dataset. Note, that issues were reported when using this option with `MultiAssayExperiment`.
#' Please make sure that adding new filters doesn't fail on target platform before deploying for production.
#' @param allow_add (`logical(1)`) logical flag specifying whether the user will be able to add new filters
#' @param x object to test for `teal_slices`, object to convert to `teal_slices` or a `teal_slices` object
#' @param i (`character` or `numeric` or `logical`) indicating which elements to extract
#' @param recursive (`logical(1)`) flag specifying whether to also convert to list the elements of this `teal_slices`
#' @param allow_add (`logical(1)`) logical flag specifying whether the user will be able to add new filters.
#' @param x object to test for `teal_slices`, object to convert to `teal_slices` or a `teal_slices` object.
#' @param i (`character` or `numeric` or `logical`) indicating which elements to extract.
#' @param recursive (`logical(1)`) flag specifying whether to also convert to list the elements of this `teal_slices`.
#' @param show_all (`logical(1)`) whether to display non-null elements of constituent `teal_slice` objects.
#' @param trim_lines (`logical(1)`) whether to trim lines.
#'
#' @return
#' `teal_slices`, which is an unnamed list of `teal_slice` objects.
Expand Down Expand Up @@ -86,9 +113,12 @@
#' - [`teal_slice`] for creating constituent elements of `teal_slices`
#' - [`teal::slices_store`] for robust utilities for saving and loading `teal_slices` in `JSON` format
#'
#' @aliases is.teal_slices as.teal_slices as.list.teal_slices format.teal_slices print.teal_slices c.teal_slices
#' [.teal_slices
#'
#' @export
#'
teal_slices <- function(...,
teal_slices <- function(..., # When editing function parameters, please remember to update @usage section.
exclude_varnames = NULL,
include_varnames = NULL,
count_type = NULL,
Expand Down Expand Up @@ -126,17 +156,13 @@ teal_slices <- function(...,
)
}


#' @rdname teal_slices
#' @export
#' @keywords internal
#'
is.teal_slices <- function(x) { # nolint
inherits(x, "teal_slices")
}


#' @rdname teal_slices
#' @export
#' @keywords internal
#'
Expand All @@ -149,8 +175,6 @@ as.teal_slices <- function(x) { # nolint
do.call(teal_slices, c(ans, attrs))
}


#' @rdname teal_slices
#' @export
#' @keywords internal
#'
Expand All @@ -160,8 +184,6 @@ as.list.teal_slices <- function(x, recursive = FALSE, ...) { # nolint
ans
}


#' @rdname teal_slices
#' @export
#' @keywords internal
#'
Expand All @@ -184,8 +206,6 @@ as.list.teal_slices <- function(x, recursive = FALSE, ...) { # nolint
y
}


#' @rdname teal_slices
#' @export
#' @keywords internal
#'
Expand All @@ -206,10 +226,6 @@ c.teal_slices <- function(...) {
)
}


#' @rdname teal_slices
#' @param show_all (`logical(1)`) whether to display non-null elements of constituent `teal_slice` objects
#' @param trim_lines (`logical(1)`) whether to trim lines
#' @export
#' @keywords internal
#'
Expand All @@ -228,7 +244,6 @@ format.teal_slices <- function(x, show_all = FALSE, trim_lines = TRUE, ...) {
jsonify(slices_list, trim_lines)
}

#' @rdname teal_slices
#' @export
#' @keywords internal
#'
Expand Down
1 change: 0 additions & 1 deletion man/teal_slice.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions man/teal_slices.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading