maelstrom-research / Rmonize

3 stars 0 forks source link

harmonized_dossier_visualize(): different errors with/without harmonized_dossier_summary input #62

Open zchenmr opened 1 month ago

zchenmr commented 1 month ago

Rmonize v1.1.0.9000, madshapR v1.1.0.9002

I get different errors when I run harmonized_dossier_visualize with or without an harmonized_dossier_summary input argument.

With the input:

harmonized_dossier_visualize(harmonized_dossier = harmonized_dossier,
                             harmonized_dossier_summary = harmonized_dossier_summary,
                             bookdown_path = "path")

Error:

image

Traceback:

46: stop(fallback)
45: signal_abort(cnd)
44: cnd_signal(cnd)
43: (function (cnd) 
    {
        cnd$subscript_action <- subscript_action(type)
        cnd$subscript_elt <- "column"
        cnd_signal(cnd)
    })(structure(list(message = "", trace = structure(list(call = list(
        variable_visualize(dataset, col = "adm_id_participant", data_dict = data_dict, 
            group_by = "Rmonize::harmonized_col_dataset", valueType_guess = "FALSE", 
            variable_summary = dataset_summary), unique(pull(`Variables summary (all)` %>% 
            dplyr::filter(.data$name %in% col) %>% select(starts_with("Grouping variable:")))), 
        pull(`Variables summary (all)` %>% dplyr::filter(.data$name %in% 
            col) %>% select(starts_with("Grouping variable:"))), 
        pull.data.frame(`Variables summary (all)` %>% dplyr::filter(.data$name %in% 
            col) %>% select(starts_with("Grouping variable:"))), 
        tidyselect::vars_pull(names(.data), !!enquo(var)), pull_as_location2(loc, 
            n, vars, error_arg = error_arg, error_call = error_call), 
        with_subscript_errors(type = "pull", {
            i <- vctrs::vec_as_subscript2(i, logical = "error", arg = error_arg, 
                call = error_call)
            if (length(i) != 1) {
     ...
42: signalCondition(cnd)
41: signal_abort(cnd)
40: cnd_signal(x$err)
39: result_get(vec_as_location2_result(i, n = n, names = NULL, negative = negative, 
        missing = missing, arg = arg, call = call))
38: vctrs::num_as_location2(i, n = n, negative = "ignore", arg = error_arg, 
        call = error_call)
37: withCallingHandlers(expr, vctrs_error_subscript = function(cnd) {
        cnd$subscript_action <- subscript_action(type)
        cnd$subscript_elt <- "column"
        cnd_signal(cnd)
    })
36: with_subscript_errors(type = "pull", {
        i <- vctrs::vec_as_subscript2(i, logical = "error", arg = error_arg, 
            call = error_call)
        if (length(i) != 1) {
            cli::cli_abort("{.arg {error_arg}} must select exactly one column.", 
                call = error_call)
        }
        if (is.numeric(i)) {
            vctrs::num_as_location2(i, n = n, negative = "ignore", 
                arg = error_arg, call = error_call)
        }
        else {
            vctrs::vec_as_location2(i, n = n, names = names, arg = error_arg, 
                call = error_call, )
        }
    })
35: pull_as_location2(loc, n, vars, error_arg = error_arg, error_call = error_call)
34: tidyselect::vars_pull(names(.data), !!enquo(var))
33: pull.data.frame(`Variables summary (all)` %>% dplyr::filter(.data$name %in% 
        col) %>% select(starts_with("Grouping variable:")))
32: pull(`Variables summary (all)` %>% dplyr::filter(.data$name %in% 
        col) %>% select(starts_with("Grouping variable:")))
31: unique(pull(`Variables summary (all)` %>% dplyr::filter(.data$name %in% 
        col) %>% select(starts_with("Grouping variable:"))))
30: variable_visualize(dataset, col = "adm_id_participant", data_dict = data_dict, 
        group_by = "Rmonize::harmonized_col_dataset", valueType_guess = "FALSE", 
        variable_summary = dataset_summary)
29: eval(expr, envir, enclos)
28: eval(expr, envir, enclos)
27: eval_with_user_handlers(expr, envir, enclos, user_handlers)
26: withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers))
25: withCallingHandlers(withVisible(eval_with_user_handlers(expr, 
        envir, enclos, user_handlers)), warning = wHandler, error = eHandler, 
        message = mHandler)
24: handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, 
        envir, enclos, user_handlers)), warning = wHandler, error = eHandler, 
        message = mHandler))
23: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, 
        envir, enclos, user_handlers)), warning = wHandler, error = eHandler, 
        message = mHandler)))
22: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
        debug = debug, last = i == length(out), use_try = stop_on_error != 
            2L, keep_warning = keep_warning, keep_message = keep_message, 
        log_echo = log_echo, log_warning = log_warning, output_handler = output_handler, 
        include_timing = include_timing)
21: evaluate::evaluate(...)
20: evaluate(code, envir = env, new_device = FALSE, keep_warning = if (is.numeric(options$warning)) TRUE else options$warning, 
        keep_message = if (is.numeric(options$message)) TRUE else options$message, 
        stop_on_error = if (is.numeric(options$error)) options$error else {
            if (options$error && options$include) 
                0L
            else 2L
        }, output_handler = knit_handlers(options$render, options))
19: in_dir(input_dir(), expr)
18: in_input_dir(evaluate(code, envir = env, new_device = FALSE, 
        keep_warning = if (is.numeric(options$warning)) TRUE else options$warning, 
        keep_message = if (is.numeric(options$message)) TRUE else options$message, 
        stop_on_error = if (is.numeric(options$error)) options$error else {
            if (options$error && options$include) 
                0L
            else 2L
        }, output_handler = knit_handlers(options$render, options)))
17: eng_r(options)
16: block_exec(params)
15: call_block(x)
14: process_group(group)
13: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
        error = function(e) if (xfun::pkg_available("rlang", "1.0.0")) rlang::entrace(e))
12: xfun:::handle_error(withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
        error = function(e) if (xfun::pkg_available("rlang", "1.0.0")) rlang::entrace(e)), 
        function(e, loc) {
            setwd(wd)
            write_utf8(res, output %n% stdout())
            paste0("\nQuitting from lines ", loc)
        }, if (labels[i] != "") sprintf(" [%s]", labels[i]), get_loc)
11: process_file(text, output)
10: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
9: rmarkdown::render(main, output_format, ..., clean = clean, envir = envir)
8: render_cur_session(files, main, config, output_format, clean, 
       envir, ...)
7: render_book(input = paste0("index.Rmd"))
6: in_dir(dir = bookdown_path, expr = render_book(input = paste0("index.Rmd")))
5: withCallingHandlers(expr, message = function(c) if (inherits(c, 
       classes)) tryInvokeRestart("muffleMessage"))
4: suppressMessages({
       in_dir(dir = bookdown_path, expr = render_book(input = paste0("index.Rmd")))
   })
3: bookdown_render(path_to, overwrite = FALSE)
2: dataset_visualize(dataset = pooled_harmonized_dataset, group_by = attributes(pooled_harmonized_dataset)$`Rmonize::harmonized_col_dataset`, 
       bookdown_path = bookdown_path, taxonomy = taxonomy, valueType_guess = valueType_guess, 
       dataset_summary = harmonized_dossier_summary)
1: harmonized_dossier_visualize(harmonized_dossier = harmonized_anderson_t1_qx, 
       harmonized_dossier_summary = stat_report_anderson_t1_qx, 
       bookdown_path = "commons/reports/post_harmo/SaskCov_t1_qx_visual_report_3_2")

Without the input:

harmonized_dossier_visualize(harmonized_dossier = harmonized_dossier,
                             bookdown_path = "path")

Error:

image

Traceback:

21: stop(fallback)
20: signal_abort(cnd, .file)
19: abort(message, class = error_class, parent = parent, call = error_call)
18: h(simpleError(msg, call))
17: .handleSimpleError(function (cnd) 
    {
        local_error_context(dots, i = frame[[i_sym]], mask = mask)
        if (inherits(cnd, "dplyr:::internal_error")) {
            parent <- error_cnd(message = bullets(cnd))
        }
        else {
            parent <- cnd
        }
        message <- c(cnd_bullet_header(action), i = if (has_active_group_context(mask)) cnd_bullet_cur_group_label())
        abort(message, class = error_class, parent = parent, call = error_call)
    }, "object 'label:en' not found", base::quote(NULL))
16: ifelse(.data$name == "-190719831562453", "-190719831562453", 
        `label:en`)
15: .Call(dplyr_mask_eval_all_mutate, quo, private)
14: eval()
13: mask$eval_all_mutate(quo)
12: mutate_col(dots[[i]], data, mask, new_columns)
11: withCallingHandlers(for (i in seq_along(dots)) {
        poke_error_context(dots, i, mask = mask)
        context_poke("column", old_current_column)
        new_columns <- mutate_col(dots[[i]], data, mask, new_columns)
    }, error = dplyr_error_handler(dots = dots, mask = mask, bullets = mutate_bullets, 
        error_call = error_call, error_class = "dplyr:::mutate_error"), 
        warning = dplyr_warning_handler(state = warnings_state, mask = mask, 
            error_call = error_call))
10: mutate_cols(.data, dplyr_quosures(...), by)
9: mutate.data.frame(., missing = ifelse(.data$name == "-190719831562453", 
       TRUE, .data$missing), `:=`(!!as_any_symbol(label), ifelse(.data$name == 
       "-190719831562453", "-190719831562453", !!as_any_symbol(label))))
8: mutate(., missing = ifelse(.data$name == "-190719831562453", 
       TRUE, .data$missing), `:=`(!!as_any_symbol(label), ifelse(.data$name == 
       "-190719831562453", "-190719831562453", !!as_any_symbol(label))))
7: data_dict_group_by$Categories %>% mutate(missing = ifelse(.data$name == 
       "-190719831562453", TRUE, .data$missing), `:=`(!!as_any_symbol(label), 
       ifelse(.data$name == "-190719831562453", "-190719831562453", 
           !!as_any_symbol(label))))
6: list2(...)
5: bind_rows(data_dict[["Categories"]], data_dict_group_by$Categories %>% 
       mutate(missing = ifelse(.data$name == "-190719831562453", 
           TRUE, .data$missing), `:=`(!!as_any_symbol(label), ifelse(.data$name == 
           "-190719831562453", "-190719831562453", !!as_any_symbol(label)))))
4: distinct(.)
3: bind_rows(data_dict[["Categories"]], data_dict_group_by$Categories %>% 
       mutate(missing = ifelse(.data$name == "-190719831562453", 
           TRUE, .data$missing), `:=`(!!as_any_symbol(label), ifelse(.data$name == 
           "-190719831562453", "-190719831562453", !!as_any_symbol(label))))) %>% 
       distinct()
2: dataset_summarize(dataset = pooled_harmonized_dataset, group_by = attributes(pooled_harmonized_dataset)$`Rmonize::harmonized_col_dataset`, 
       taxonomy = taxonomy, valueType_guess = valueType_guess)
1: harmonized_dossier_visualize(harmonized_dossier = harmonized_anderson_t1_qx, 
       bookdown_path = "commons/reports/post_harmo/SaskCov_t1_qx_visual_report_3_2")