Skip to content

Commit

Permalink
enhance metadata.table1 edge cases
Browse files Browse the repository at this point in the history
- provide error message when there is no records.
- restrict drill down listing for 50,000 rows to improve performance.
  • Loading branch information
elong0527 committed Dec 13, 2022
1 parent a3431ac commit e4bd482
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: What the package does (one paragraph).
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Imports:
metalite,
reactable,
Expand Down
8 changes: 7 additions & 1 deletion R/interactive_table1.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interactive_table1 <- function(meta,
var_listing = NULL,
download = "none",
type = NULL,
max_row = 50000,
...) {

download <- match.arg(download, choices = c("none", "listing", "table", "all"))
Expand All @@ -22,10 +23,15 @@ interactive_table1 <- function(meta,
return(NULL)
}

listing <- nrow(meta$data_population) <= max_row
if(! listing){
message("Drill-down listing is not provided because there are more than ", max_row, " rows in the datasets")
}

tbl <- metalite::collect_n_subject(meta,
population = population,
parameter = parameter,
listing = TRUE,
listing = listing,
histogram = TRUE,
type = type,
var_listing = var_listing
Expand Down
8 changes: 7 additions & 1 deletion R/metalite_table1.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#' @param id a variable name
#' @param var_listing a character vector of additional variables included in the listing.
#' @param download a character to enable download button. Allowed value include
#' @param type a character value to control section title (e.g. "Subjects", "Records")
#' "none", "listing", "table", and 'all'.
#' @param type a character value to control section title (e.g. "Subjects", "Records")
#'
#' @export
metalite_table1 <- function(formula,
Expand All @@ -15,6 +15,12 @@ metalite_table1 <- function(formula,
var_listing = NULL,
download = "none",
type = NULL) {

if(nrow(data) == 0){
stop("There is no records in the input dataset")
}


if (formula[[2]][[1]] == "|") {
var <- all.vars(formula[[2]][[2]])
group <- all.vars(formula[[2]][[3]])
Expand Down
6 changes: 3 additions & 3 deletions man/metalite_table1.Rd

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

0 comments on commit e4bd482

Please sign in to comment.