choonghyunryu / dlookr

Tools for Data Diagnosis, Exploration, Transformation
https://choonghyunryu.github.io/dlookr/
208 stars 35 forks source link

Quitting from lines 273-275 (transformation_temp.Rmd) Error in plot.window(...) : need finite 'xlim' values #68

Closed iqbaljamal closed 2 years ago

iqbaljamal commented 2 years ago

dlookr (0.6.0.9000)

When running transformation_web_report. eda_web_report and diagnose_web_report ran fine. Here's the traceback:

Error in plot.window(...) : need finite 'xlim' values 40. stop(e) 39. value[3L] 38. tryCatchOne(expr, names, parentenv, handlers[[1L]]) 37. tryCatchList(expr, classes, parentenv, handlers) 36. tryCatch({ result <- withVisible(rlang::eval_tidy(expr)) if (result$visible) { capture.output(print(result$value)) ... 35. capturePlot(~{ plot(bins[[index]], base_family = base_family) }, device = device, width = width pixelratio, height = height pixelratio, res = 72 * pixelratio) 34. rlang::eval_tidy(rlang::expr(capturePlot({ { expr } ... 33. htmltools::plotTag({ plot(bins[[index]], base_family = base_family) }, sprintf("A plot of bins"), width = 600, height = 400, device = grDevices::png) 32. (function (index) { p_hist <- htmltools::plotTag({ plot(bins[[index]], base_family = base_family) ... 31. do.call(func, args[seq_len(numArgs)]) 30. callFunc(details, index) 29. FUN(X[[i]], ...) 28. lapply(seq_len(nrow(data)), function(index) { callFunc(details, index) }) 27. FUN(X[[i]], ...) 26. lapply(columnKeys, function(key) { column <- list(accessor = key, name = key, type = colType(data[[key]])) if (!is.null(columns[[key]])) { column <- mergeLists(column, columns[[key]]) ... 25. reactable(., defaultColDef = colDef(style = "font-size: 14px;color: hsl(0, 0%, 40%);"), columns = list(variables = colDef(name = "Variables", minWidth = 100, maxWidth = 150), types = colDef(name = "Data Types", minWidth = 80, maxWidth = 100), unique_count = colDef(name = "Unique", ... 24. tab_numerical %>% reactable(defaultColDef = colDef(style = "font-size: 14px;color: hsl(0, 0%, 40%);"), columns = list(variables = colDef(name = "Variables", minWidth = 100, maxWidth = 150), types = colDef(name = "Data Types", minWidth = 80, maxWidth = 100), unique_count = colDef(name = "Unique", ... 23. html_binning(reportData, base_family = base_family) 22. eval(expr, envir, enclos) 21. eval(expr, envir, enclos) 20. eval_with_user_handlers(expr, envir, enclos, user_handlers) 19. withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)) 18. withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler) 17. handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler)) 16. timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler))) 15. 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, output_handler = output_handler, include_timing = include_timing) 14. evaluate::evaluate(...) 13. evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) 0L ... 12. in_dir(input_dir(), expr) 11. in_input_dir(evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) ... 10. eng_r(options) 9. block_exec(params) 8. call_block(x) 7. process_group.block(group) 6. process_group(group) 5. withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), error = function(e) { setwd(wd) cat(res, sep = "\n", file = output %n% "") ... 4. process_file(text, output) 3. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet) 2. rmarkdown::render(paste(path, rmd, sep = "/"), output_file = output_file) 1. transformation_web_report(data_for_QA, output_dir = QA_dir, author = "HS HSM Team", title = paste0("transformation", percent_sample, "%"), outputfile = paste0("transform", dbo_table_name, " ", percent_sample, ".html"), theme = "blue", browse = TRUE, sample_percent = percent_sample)

choonghyunryu commented 2 years ago

It is difficult to troubleshoot the exact cause with the error message. I need a reproduction to figure out the cause of this problem. Please share the data, or if you can't, let us know that the result of the following command is:

dlookr::describe(data_for_QA)

iqbaljamal commented 2 years ago

Thanks. Here are the results:

dlookr::describe(data_for_QA) A tibble: 6 x 26 described_variables n na mean sd se_mean IQR skewness kurtosis p00 p01 p05 p10 p20 p25 p30 p40 p50 p60 p70 p75 p80 p90 p95 p99 p100

V1 1333273 0 2016. 0 0 0 -1.00 -2.00 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. 2016. V2 1333132 141 2 0 0 0 NaN NaN 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 V3 1333273 0 1.95 9.62 0.00833 0 9.89 95.8 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 98 V4 1333127 146 8.46 3.83 0.00332 6 -0.299 -1.11 1 2 2 3 3 6 7 8 8 10 12 12 12 13 13 15 16 V5 1333273 0 3.71 12.2 0.0106 2 59.5 10268. 1 1 1 1 1 1 1 1 1 2 2 3 3 7 13 43.3 2973 V6 1333127 146 13.4 24.3 0.0210 9 8.96 165. 0 0 1 2 3 4 5 6 7 9 12 13 16 27 44 114 1571
choonghyunryu commented 2 years ago

@iqbaljamal,

An error occurred because variable V2 is a constant with all values equal to 2. Binning constant values in data analysis is unnecessary. Try doing it after removing the V2 variable.

I'll put logic to handle exceptions in the case of a data set that contains constants like this.

choonghyunryu commented 2 years ago

@iqbaljamal,

A version that fixes this problem has been uploaded to github. CRAN is not reflected in a short period of time. To use the function now, install the modified version as follows and use it.:

devtools::install_github("choonghyunryu/dlookr")

iqbaljamal commented 2 years ago

Thank you so much for this fix!