diff --git a/articles/r_expr_addons.html b/articles/r_expr_addons.html index 1ef3cad..4dcd355 100644 --- a/articles/r_expr_addons.html +++ b/articles/r_expr_addons.html @@ -123,7 +123,7 @@

1. %?<-%: Assign if invalid#> $aa #> [1] 1 #> user system elapsed -#> 0 0 0 +#> 0.001 0.000 0.000

2. JavaScript-style of creating functions diff --git a/pkgdown.yml b/pkgdown.yml index aa322ba..f53bba2 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,7 +5,7 @@ articles: r_expr_addons: r_expr_addons.html shiny_customized_widgets: shiny_customized_widgets.html utility_functions: utility_functions.html -last_built: 2024-06-27T03:11Z +last_built: 2024-06-27T03:14Z urls: reference: https://dipterix.org/dipsaus/reference article: https://dipterix.org/dipsaus/articles diff --git a/reference/as_pipe.html b/reference/as_pipe.html index 1e3b489..e0632a2 100644 --- a/reference/as_pipe.html +++ b/reference/as_pipe.html @@ -125,7 +125,7 @@

Examples#> { #> plot(1:10, 1:10, ..., pch = pch, main = "[input:title]") #> } -#> <environment: 0x556d320a1588> +#> <environment: 0x564eda2b2868> # vary_title is pipe-friendly with `pch` default 16 vary_title(title = 'My Title') @@ -150,7 +150,7 @@

Examples#> { #> f(..., x = "[input:x]") #> } -#> <environment: 0x556d329f3dc8> +#> <environment: 0x564edac05070> f_pipable(2) #> [1] 3 diff --git a/reference/collapse.html b/reference/collapse.html index 96fb260..13f74de 100644 --- a/reference/collapse.html +++ b/reference/collapse.html @@ -114,8 +114,8 @@

Examples) #> Unit: microseconds #> expr min lq mean median uq max neval -#> result 854.983 854.983 854.983 854.983 854.983 854.983 1 -#> compare 665.530 665.530 665.530 665.530 665.530 665.530 1 +#> result 978.347 978.347 978.347 978.347 978.347 978.347 1 +#> compare 641.448 641.448 641.448 641.448 641.448 641.448 1 # large data big difference x = array(rnorm(prod(300,200,105)), c(300,200,105,1)) @@ -127,8 +127,8 @@

Examples }) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> result 45.76934 45.76934 45.76934 45.76934 45.76934 45.76934 1 -#> compare 115.42565 115.42565 115.42565 115.42565 115.42565 115.42565 1 +#> result 46.67072 46.67072 46.67072 46.67072 46.67072 46.67072 1 +#> compare 114.92104 114.92104 114.92104 114.92104 114.92104 114.92104 1

diff --git a/reference/fastcov2.html b/reference/fastcov2.html index 248fd4c..91ebf5f 100644 --- a/reference/fastcov2.html +++ b/reference/fastcov2.html @@ -134,9 +134,9 @@

Examples unit = 'ms', times = 10 ) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> fastcov2 1.393356 1.412291 1.45820 1.418934 1.463637 1.614207 10 -#> cov 5.978667 6.194460 6.26936 6.221747 6.281773 6.868225 10 +#> expr min lq mean median uq max neval +#> fastcov2 1.393682 1.420512 1.492968 1.453204 1.528975 1.771037 10 +#> cov 6.017287 6.164441 6.262547 6.246399 6.284104 6.817741 10 diff --git a/reference/fastquantile.html b/reference/fastquantile.html index 40bbfc2..a6becac 100644 --- a/reference/fastquantile.html +++ b/reference/fastquantile.html @@ -120,14 +120,14 @@

Examples } ) #> Unit: microseconds -#> expr min lq mean median -#> { fastquantile(x, 0.5) } 56.725 116.537 123.8212 122.824 -#> { quantile(x, 0.5, na.rm = TRUE) } 278.539 295.140 326.3404 301.572 -#> { median(x, na.rm = TRUE) } 213.327 225.390 252.7259 231.121 +#> expr min lq mean median +#> { fastquantile(x, 0.5) } 57.097 103.413 121.3093 124.3425 +#> { quantile(x, 0.5, na.rm = TRUE) } 287.757 301.117 333.4637 309.1320 +#> { median(x, na.rm = TRUE) } 218.628 231.768 256.6752 237.4935 #> uq max neval -#> 133.8195 178.663 100 -#> 319.4650 500.062 100 -#> 242.8220 397.480 100 +#> 135.0725 177.552 100 +#> 326.9305 491.227 100 +#> 245.1125 399.035 100 diff --git a/reference/fastqueue2.html b/reference/fastqueue2.html index 5764676..13f7f67 100644 --- a/reference/fastqueue2.html +++ b/reference/fastqueue2.html @@ -125,7 +125,7 @@

Examples# the second item x[[2]] #> function(){ "c" } -#> <environment: 0x556d3379ada0> +#> <environment: 0x564edb9284f8> # first two items in a list x[c(1,2)] @@ -134,7 +134,7 @@

Examples#> #> [[2]] #> function(){ "c" } -#> <environment: 0x556d3379ada0> +#> <environment: 0x564edb9284f8> #> print(x) @@ -145,7 +145,7 @@

Examples#> #> [[2]] #> function(){ "c" } -#> <environment: 0x556d3379ada0> +#> <environment: 0x564edb9284f8> #> #> [[3]] #> [1] 4 diff --git a/reference/forelse.html b/reference/forelse.html index 2c8ec5e..46f207f 100644 --- a/reference/forelse.html +++ b/reference/forelse.html @@ -165,10 +165,10 @@

Examples#> { forelse(1:10, FUN, "wow") } #> { y <- unlist(lapply(1:10, FUN)) if (length(y)) { y <- y[[1]] } else { y <- "wow" } } #> { y <- NULL for (x in 1:10) { y <- FUN(x) } if (is.null(y)) { y <- "wow" } } -#> min lq mean median uq max neval -#> 20.17828 20.18697 20.1975 20.19565 20.20711 20.21857 3 -#> 100.75283 100.88440 100.9597 101.01596 101.06308 101.11020 3 -#> 100.77415 100.92302 100.9750 101.07188 101.07536 101.07884 3 +#> min lq mean median uq max neval +#> 20.17484 20.18778 20.21316 20.20071 20.23232 20.26394 3 +#> 100.78831 100.96106 101.02056 101.13380 101.13668 101.13957 3 +#> 100.72339 100.90244 100.97274 101.08150 101.09741 101.11333 3 diff --git a/reference/grapes-equals-greater-than-grapes.html b/reference/grapes-equals-greater-than-grapes.html index 27d24dc..f935361 100644 --- a/reference/grapes-equals-greater-than-grapes.html +++ b/reference/grapes-equals-greater-than-grapes.html @@ -90,7 +90,7 @@

Examples#> { #> print(a) #> } -#> <environment: 0x556d392a45a0> +#> <environment: 0x564ee14c5b40> # Informal arguments list(a=) %=>% { @@ -100,7 +100,7 @@

Examples#> { #> print(a) #> } -#> <environment: 0x556d392a45a0> +#> <environment: 0x564ee14c5b40> # Multiple inputs c(a, b = 2, ...) %=>% { @@ -110,7 +110,7 @@

Examples#> { #> print(c(a, b, ...)) #> } -#> <environment: 0x556d392a45a0> +#> <environment: 0x564ee14c5b40> # ----- JavaScript style of forEach ----- # ### Equivalent JavaScript Code: diff --git a/reference/mask_function2.html b/reference/mask_function2.html index d373fd5..57cebb0 100644 --- a/reference/mask_function2.html +++ b/reference/mask_function2.html @@ -103,9 +103,9 @@

Examples#> [1] 2 environment(f1) # global env -#> <environment: 0x556d32c75800> +#> <environment: 0x564ed9f376c0> environment(f2) # masked env -#> <environment: 0x556d34f3e408> +#> <environment: 0x564edd403300> env <- environment(f2) identical(parent.env(env), environment(f1)) # true diff --git a/reference/new_function2.html b/reference/new_function2.html index 879c69c..6588939 100644 --- a/reference/new_function2.html +++ b/reference/new_function2.html @@ -138,7 +138,7 @@

Examples#> { #> print(a + 1:10) #> } -#> <environment: 0x556d2bab64d0> +#> <environment: 0x564ed3ca0930> f2(0) #> [1] 1 2 3 4 5 6 7 8 9 10 @@ -156,26 +156,26 @@

Examples#> function (a = 123) #> { #> } -#> <environment: 0x556d39439a58> +#> <environment: 0x564eda1bf520> # default with values unevaluated new_function2(list(a = quote(default))) # function (a = default){} #> function (a = default) #> { #> } -#> <environment: 0x556d34dab8a0> +#> <environment: 0x564eda3977c0> new_function2(alist(a = default)) #> function (a = default) #> { #> } -#> <environment: 0x556d32fdb230> +#> <environment: 0x564ee029c018> # missing default new_function2(alist(a = )) # function (a){} #> function (a) #> { #> } -#> <environment: 0x556d329dbe98> +#> <environment: 0x564eda8ca3e0> diff --git a/reference/shared_finalizer.html b/reference/shared_finalizer.html index 995bf85..a326478 100644 --- a/reference/shared_finalizer.html +++ b/reference/shared_finalizer.html @@ -251,7 +251,7 @@

Examples#> NULL gc() #> used (Mb) gc trigger (Mb) max used (Mb) -#> Ncells 1331293 71.1 2318278 123.9 2318278 123.9 +#> Ncells 1331293 71.1 2318241 123.9 2318241 123.9 #> Vcells 2470345 18.9 12235024 93.4 23896472 182.4 file_exists #> [1] TRUE @@ -260,7 +260,7 @@

Examplesrm(e1); gc() #> [1] "Clean some shared files" #> used (Mb) gc trigger (Mb) max used (Mb) -#> Ncells 1331304 71.1 2318278 123.9 2318278 123.9 +#> Ncells 1331304 71.1 2318241 123.9 2318241 123.9 #> Vcells 2470389 18.9 12235024 93.4 23896472 182.4 e2$valid() # FALSE #> [1] FALSE @@ -269,7 +269,7 @@

Examplesrm(e2); gc() #> [1] "Clean some shared files" #> used (Mb) gc trigger (Mb) max used (Mb) -#> Ncells 1331325 71.2 2318278 123.9 2318278 123.9 +#> Ncells 1331325 71.2 2318241 123.9 2318241 123.9 #> Vcells 2470399 18.9 12235024 93.4 23896472 182.4 diff --git a/reference/sumsquared.html b/reference/sumsquared.html index 304916e..5138e44 100644 --- a/reference/sumsquared.html +++ b/reference/sumsquared.html @@ -87,9 +87,9 @@

Examples r = {sum(x^2)} ) #> Unit: microseconds -#> expr min lq mean median uq max neval -#> cpp 37.971 38.0510 38.63397 38.176 38.3415 58.629 100 -#> r 26.670 27.0605 27.94585 27.476 28.3130 34.836 100 +#> expr min lq mean median uq max neval +#> cpp 37.780 37.8960 38.30509 38.0410 38.2270 49.573 100 +#> r 25.708 26.1885 27.24805 26.5495 28.0825 37.170 100 diff --git a/reference/time_delta.html b/reference/time_delta.html index 5214b69..8e5225d 100644 --- a/reference/time_delta.html +++ b/reference/time_delta.html @@ -90,9 +90,9 @@

Examplesb = Sys.time() time_delta(a, b) # In seconds, around 0.3 -#> [1] 0.3018517 +#> [1] 0.3022311 time_delta(a, b, 'mins') # in minutes, around 0.005 -#> [1] 0.005030862 +#> [1] 0.005037185 diff --git a/search.json b/search.json index 17b7bc2..1bc3950 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"assign-if-invalid","dir":"Articles","previous_headings":"","what":"1. %?<-%: Assign if invalid","title":"R Expression Add-on","text":"coding R, data checking actually headache. example, check variable aa exists NULL, otherwise set default value 1, check looks like: time repeating . %?<-% operator, just need: powerful part left-hand side can expression. example, value exists, %?<-% nothing (even evaluate expressions right-hand side)","code":"if( exists('aa') && !is.null(aa) ){ aa <- 1 } aa %?<-% 1 print(aa) #> [1] 1 l %?<-% list() l$aa %?<-% 1 print(l) #> $aa #> [1] 1 # e already exists e <- list(aa = 1) # %?<-% will not evaluate rhs, nor assign values system.time({ e %?<-% { Sys.sleep(10); list(aa = 2) } print(e) }) #> $aa #> [1] 1 #> user system elapsed #> 0 0 0"},{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"javascript-style-of-creating-functions","dir":"Articles","previous_headings":"","what":"2. JavaScript-style of creating functions","title":"R Expression Add-on","text":"modern JavaScript, function can created via (arg) => { ... }. example, dipsaus provides functions iapply, %=>%, together glue package, can apply elements like : %=>% collect left-hand side elements arguments right-hand side expression body create function:","code":"const li = ['A', 'T', 'G', 'C']; li.map((el, ii) => { return(`The index for ${el} is ${ii}`); }); # gl <- glue::glue # `%>%` <- magrittr::`%>%` li <- c('A', 'T', 'G', 'C') li %>% iapply(c(el, ii) %=>% { gl('The index for {el} is {ii}') }) #> [1] \"The index for A is 1\" \"The index for T is 2\" \"The index for G is 3\" #> [4] \"The index for C is 4\" c(a, b=a^2, ...) %=>% { print(c(a , b,...)) } #> function (a, b = a^2, ...) #> { #> print(c(a, b, ...)) #> }"},{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"match-nested-calls-match_calls","dir":"Articles","previous_headings":"","what":"3. Match nested calls match_calls","title":"R Expression Add-on","text":"function match.call provided base package let us format calls formals matched. already powerful can parse expressions using .list() get input parameters. However, encounter nested calls like shiny UI components, match.call work well. can’t see matched results inside nested functions. match_calls solves problem recursively calling match.call: can also change modify calls. example, want add ns input ID shiny modules, following replave_args changes \"inputId\" ns(\"inputId\")","code":"match.call(textInput, call = quote(textInput('inputId', 'label', 'aaa'))) #> textInput(inputId = \"inputId\", label = \"label\", value = \"aaa\") match.call(tagList, call = quote(tagList( div( tags$ul( tags$li(textInput('inputId', 'label', 'aaa')) ) ) ))) #> tagList(div(tags$ul(tags$li(textInput(\"inputId\", \"label\", \"aaa\"))))) match_calls(call = tagList( div( tags$ul( tags$li(textInput('inputId', 'label', 'aaa')) ) ) ), recursive = TRUE) #> tagList(div(tags$ul(tags$li(textInput(inputId = \"inputId\", label = \"label\", #> value = \"aaa\"))))) match_calls(call = tagList( div( tags$ul( tags$li(textInput('inputId', 'label', 'aaa')) ) ) ), recursive = TRUE, replace_args = list( 'inputId' = function(v, ...){ as.call(list(quote(ns), v)) } )) #> tagList(div(tags$ul(tags$li(textInput(inputId = ns(\"inputId\"), #> label = \"label\", value = \"aaa\")))))"},{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"pipe-friendly-functions","dir":"Articles","previous_headings":"","what":"4. Pipe-friendly functions","title":"R Expression Add-on","text":"Pipe functions can simplify workflow make R code readable. popular pipe %>% allows left-hand elements first input right-hand side functions. dipsaus provides several pipe-friendly functions.","code":""},{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"no-operations-no_op","dir":"Articles","previous_headings":"4. Pipe-friendly functions","what":"No-operations no_op","title":"R Expression Add-on","text":"no_op takes whatever input , returns input, side effects. example, want plot results pipe continue analysis, usually happens: no_op, pipe becomes: ’s example","code":"x %>% do_something(...) -> x_tmp plot(x_tmp) x_tmp %>% do_others(...) -> final_results x %>% do_something(...) %>% no_op(plot, ylim = c(0,100)) %>% do_others(...) -> final_results par(mfrow = c(1,2)) (1:10) %>% iapply(c(el, ii) %=>% { rnorm(20, el, ii) }, simplify = FALSE) %>% unlist %>% # Begin no-ops, result will not change no_op({ # Use expression and \".\" to refer the data print(summary(.)) }) %>% no_op( # Use function and pass ... to function plot, x = seq(0,1,length.out = 200), type = 'p', ylim = c(-20,20), pch = 16, xlab = 'Time', ylab = 'Value', las = 1 ) %>% no_op(hist, xlab = 'Values', main = 'Histogram') -> result #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -8.101 1.379 4.588 6.344 10.196 35.644 str(result) #> num [1:200] -0.4 1.255 -1.437 0.994 1.622 ..."},{"path":"https://dipterix.org/dipsaus/articles/r_expr_addons.html","id":"do_aggregate","dir":"Articles","previous_headings":"4. Pipe-friendly functions","what":"do_aggregate","title":"R Expression Add-on","text":"wrapper aggregate function. using formula, aggregate requires formula first element. pipe results data.frame want use formula, ’s super inconvenient. do_aggregate allows first element data frames using formula:","code":"## S3 method for class 'formula' aggregate(formula, data, FUN, ..., subset, na.action = na.omit) ToothGrowth %>% do_aggregate(len ~ ., mean) #> supp dose len #> 1 OJ 0.5 13.23 #> 2 VC 0.5 7.98 #> 3 OJ 1.0 22.70 #> 4 VC 1.0 16.77 #> 5 OJ 2.0 26.06 #> 6 VC 2.0 26.14"},{"path":"https://dipterix.org/dipsaus/articles/shiny_customized_widgets.html","id":"styled-action-button","dir":"Articles","previous_headings":"","what":"1. Styled Action Button","title":"Shiny Customized Widgets","text":"default shiny actionButton fully use Bootstrap theme full features defined HTML. example, button class always btn btn-default can’t disable/enable button easy way. actionButtonStyled solves two problems: type allows add Bootstrap styles button. supported types : default, primary, info, success, warning, danger customized CSS styles, class provides flexible way add classes updating button, disabled allows disable/enable button usage listed follows: Show-case:","code":"# UI function actionButtonStyled(inputId, label, icon = NULL, width = NULL, btn_type = \"button\", type = \"primary\", class = \"\", ...) # Update function updateActionButtonStyled(session, inputId, label = NULL, icon = NULL, type = NULL, disabled = NULL, ...)"},{"path":"https://dipterix.org/dipsaus/articles/shiny_customized_widgets.html","id":"compound-inputs-grouped-inputs","dir":"Articles","previous_headings":"","what":"2. Compound Inputs (grouped Inputs)","title":"Shiny Customized Widgets","text":"compoundInput2 provides group inputs group contains multiple shiny inputs. examples create list input groups minimum 0 maximum 10. User can control size groups pressing + - buttons. value input$components looks like : found input extremely useful clinic trial experiment condition grouped developers don’t know ahead number condition groups. details can found demo('example-compountInput2', package='dipsaus'). source file can found using system.file('demo/example-compountInput2.R', package='dipsaus').","code":"compoundInput2( 'compound', 'Group Label', label_color = 1:10, components = div( textInput('txt', 'Text'), selectInput('sel', 'Select', choices = 1:10, multiple = TRUE), sliderInput('sli', 'Slider', max=1, min=0, val=0.5) ), max_ncomp = 10, min_ncomp = 0, initial_ncomp = 1 ) #> [[1]] #> [[1]]$txt #> [1] \"\" #> #> [[1]]$sel #> [1] \"1\" \"3\" #> #> [[1]]$sli #> [1] 0.5 #> #> [[2]] ..."},{"path":"https://dipterix.org/dipsaus/articles/shiny_customized_widgets.html","id":"synchronize-multiple-inputs","dir":"Articles","previous_headings":"","what":"3. Synchronize Multiple Inputs","title":"Shiny Customized Widgets","text":"sync_shiny_inputs provides way update among multiple inputs dead-locks. example, input (textInput) shares information input B (sliderInput). Updating trigger B update. want updated B changed? following code might cause recursive updates: case, can use sync_shiny_inputs: inputIds refers input ID synchronized. one inputs changed, value passed corresponding uniform functions stored, updates notify inputs update UI values. input updates stored value. example, input changed \"0\" \"1\", first function uniform triggered, function(){.numeric()} evaluated =\"1\". result, numeric 1 stored. Next, functions updates called, 1 (stored previous step) input, results changing slider input B 1. whole process trigger re-update.","code":"# Bad example observeEvent(input$A, { updateSliderInput(session, 'B', value = input$A) }) observeEvent(input$B, { updateTextInput(session, 'A', value = input$B) }) sync_shiny_inputs(input, session, inputIds = c('A', 'B'), uniform = list( function(a){as.numeric(a)}, function(b){ b } ), updates = list( function(a){updateTextInput(session, 'A', value = a)}, function(b){updateSliderInput(session, 'B', value = b)} ))"},{"path":"https://dipterix.org/dipsaus/articles/utility_functions.html","id":"cat-strings-with-levels-debug-info-warning-error-and-fatal","dir":"Articles","previous_headings":"","what":"1. Cat strings with levels: DEBUG, INFO, WARNING, ERROR, and FATAL","title":"Utility Functions","text":"Level FATAL raise errors.","code":"cat2('Debug passed!', level = 'DEBUG') #> ✔ Debug passed! cat2('You are all set.', level = 'INFO') #> ♥ You are all set. cat2('Wait a second...', level = 'WARNING') #> ⚠ Wait a second... cat2('Ooops', level = 'ERROR') #> ✖ Ooops cat2('Bi--Doop---', level = 'FATAL') #> ✖ Bi--Doop--- #> Error: #> ..."},{"path":"https://dipterix.org/dipsaus/articles/utility_functions.html","id":"parse_svec-and-deparse_svec","dir":"Articles","previous_headings":"","what":"2. parse_svec and deparse_svec","title":"Utility Functions","text":"parse_svec converts characters like \"7-10,14-15\" numeric vectors deparse_svec reverse process Parameter max_lag deparse_svec changes threshold integers collapsed together:","code":"parse_svec(\"7-10,14-15\") #> [1] 7 8 9 10 14 15 deparse_svec(c(2,5,3,1,7)) #> [1] \"1-3,5,7\" deparse_svec(c(1,2,4,7,11)) #> [1] \"1-2,4,7,11\" deparse_svec(c(1,2,4,7,11), max_lag = 2) #> [1] \"1-4,7,11\" deparse_svec(c(1,2,4,7,11), max_lag = 3) #> [1] \"1-7,11\""},{"path":"https://dipterix.org/dipsaus/articles/utility_functions.html","id":"system-information","dir":"Articles","previous_headings":"","what":"3. System Information","title":"Utility Functions","text":"goal work alternative retrieve system information. example, R doesn’t provide functions get memory limits, CPU chip-set information Linux MacOS.","code":"# Total RAM in bytes get_ram() #> 16757342208.0 B # Print-friendly to_ram_size(get_ram(), 1024) #> 15.6 GB # WARNING: $free is the total RAM - R usage, is no the actual free RAM mem_limit2() #> $total #> 16757342208.0 B #> $free #> 16696189352.0 B"},{"path":"https://dipterix.org/dipsaus/articles/utility_functions.html","id":"interactive-questions","dir":"Articles","previous_headings":"","what":"4. Interactive Questions","title":"Utility Functions","text":"askYesNo comes utils package allows ask yes/questions returns logical value. cancel entered, function returns NA, answers yes, cancel given, raise error. dipsaus::ask_yesno ask question user actually say yes ask_or_default instead asking yes/question, asks question default answer. User don’t type answers accept defaults:","code":"> ask_yesno('Please answer an yes/no question, ok?') ## ♥ Please answer an yes/no question, ok? (Yes/no): > qweee ## ⚠ Please answer Y/yes, N/no, or c to cancel. (Yes/no): > ttt ## ⚠ Please answer Y/yes, N/no, or c to cancel. (Yes/no): > y ## [1] TRUE > ask_or_default(\"What is your password\", default = 'I will not tell you!') ## ♥ What is your password ## [default is ‘I will not tell you!’] > ## [1] \"I will not tell you!\""},{"path":"https://dipterix.org/dipsaus/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Zhengjia Wang. Author, maintainer. John Magnotti. Contributor. Contributed `rutabaga.R` Xiang Zhang. Contributor. Contributed `rutabaga.R`","code":""},{"path":"https://dipterix.org/dipsaus/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Wang Z (2024). dipsaus: Dipping Sauce Data Analysis Visualizations. R package version 0.2.8.9005, https://dipterix.org/dipsaus/, https://github.com/dipterix/dipsaus.","code":"@Manual{, title = {dipsaus: A Dipping Sauce for Data Analysis and Visualizations}, author = {Zhengjia Wang}, year = {2024}, note = {R package version 0.2.8.9005, https://dipterix.org/dipsaus/}, url = {https://github.com/dipterix/dipsaus}, }"},{"path":"https://dipterix.org/dipsaus/index.html","id":"dipping-sauce-for-data-analysis-and-visualization","dir":"","previous_headings":"","what":"A Dipping Sauce for Data Analysis and Visualizations","title":"A Dipping Sauce for Data Analysis and Visualizations","text":"Package dipsaus provides add-ons various packages shiny, rlang, future, etc. enhance packages. install package, dipsaus provides add-ons following perspectives:","code":"# To install the development package # remotes::install_github('dipterix/dipsaus') # To install from CRAN install.packages(\"dipsaus\")"},{"path":"https://dipterix.org/dipsaus/index.html","id":"id_1-shiny-customized-widgets-vignette","dir":"","previous_headings":"","what":"1. Shiny Customized Widgets (Vignette)","title":"A Dipping Sauce for Data Analysis and Visualizations","text":"compoundInput2 assembles shiny native inputs create variable-length input; actionButtonStyled add styles shiny default actionButton updating function can also update styles enable/disable button; sync_shiny_inputs synchronize among shiny inputs without causing dead-locks UI changes; set_shiny_input set shiny input object; flex_div display elements flex layout; html_asis escapes string displayed ‘-’ websites; progress2 shows shiny progress bar, also works without shiny; shiny_is_running check shiny running;","code":""},{"path":"https://dipterix.org/dipsaus/index.html","id":"id_2-parallel-functions","dir":"","previous_headings":"","what":"2. Parallel Functions","title":"A Dipping Sauce for Data Analysis and Visualizations","text":"collapse parallel solution calculate sum/mean along arrays, providing 4x speed-ups large arrays; make_forked_clusters enables multicore (forked clusters) future package even RStudio environment; baseline_array baseline arrays multicore; shift_array shift arrays along given dimensions; lapply_async2 uses future package, progress bar either console shiny apps; fastcov2 calculates covariance matrices parallel; rs_exec starts new R session job RStudio;","code":""},{"path":"https://dipterix.org/dipsaus/index.html","id":"id_3-r-expressions-vignette","dir":"","previous_headings":"","what":"3. R Expressions (Vignette)","title":"A Dipping Sauce for Data Analysis and Visualizations","text":"eval_dirty works base::eval, supports quosures generated rlang::quo; match_calls match calls nested manner, support changing call arguments recursively; %?<-% assigns default values left-hand object. E.g. %?<-% 1 assigns 1 NULL exist; %=>% provides JavaScript-style creating functions; new_function2 creates new function quasi-quotation; mask_function2 modifies function mask certain elements within function; capture_expr captures messages always return results one-line string; forelse provides Python-like -else syntax; test_farg tests whether function contains desired arguments;","code":""},{"path":"https://dipterix.org/dipsaus/index.html","id":"id_4-utility-functions-vignette","dir":"","previous_headings":"","what":"4. Utility Functions (Vignette)","title":"A Dipping Sauce for Data Analysis and Visualizations","text":"check_installed_packages, package_installed checks package(s) installed; col2hexStr convert color hex strings friendly HTML, CSS JavaScript; parse_svec converts string integer vectors, deparse_svec converts integer vectors back compact string; drop_nulls removes invalid items within lists; get_ram, mem_limit2 gets total RAM size alternatives mem.limits non-windows environment; to_ram_size provides simple way convert numbers printable storage sizes given units; time_delta calculates time differences returns number given units; ask_yesno, ask_or_default interactively ask user’s input either console RStudio; fastmap2 fastqueue2 provides wrapper fastmap package, giving object list-like operations; shared_finalizer finalizes multiple elements last element garbage collected; dev_create allows managing grouping graphic devices; print_directory_tree prints directory containing files tree-structures; rs_* functions wrapping rstudioapi functions, work without RStudio; sexp_type2 get internal data type code; to_datauri converts file base64 formats.","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractMap.html","id":null,"dir":"Reference","previous_headings":"","what":"Abstract Map to store key-value pairs — AbstractMap","title":"Abstract Map to store key-value pairs — AbstractMap","text":"Abstract Map store key-value pairs","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractQueue.html","id":null,"dir":"Reference","previous_headings":"","what":"Defines abstract queue class — AbstractQueue","title":"Defines abstract queue class — AbstractQueue","text":"class inspired https://cran.r-project.org/package=txtq. difference AbstractQueue introduce abstract class can extended can queue text messages, also arbitrary R objects, including expressions environments. queue types package inherit class.","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractQueue.html","id":"abstract-public-methods","dir":"Reference","previous_headings":"","what":"Abstract Public Methods","title":"Defines abstract queue class — AbstractQueue","text":"Methods start @... thread-safe. used directly users. However, might want override inherit abstract class. Methods marked \"(override)\" implemented, meaning supposed implement details. Methods marked \"(optional)\" usually default alternatives. initialize(...) (override) constructor. Usually three things process: 1. set get_locker free_locker want use default lockers. 2. set lock file (using default lockers). 3. call self$connect(...) get_locker(), free_locker() (optional) Default NULL methods, queue uses internal private$default_get_locker private$default_free_locker. two methods customized locker, please implement two methods functions self$initialization get_locker obtains lock access (exclusive), free_locker frees locker. implemented, private$exclusive take care rest. Type: function; parameters: none; return: none @get_head(), @set_head(v) (override) Get head know queue self$@get_head() return integer indicating queue self$@set_head(v) stores integer. Parameter v always non-negative, guaranteed. Users supposed call methods directly, use self$head self$head<- instead. However, inherit class, supposed override methods. @get_total(), @set_total(v) (override) Similar @get_head @set_head, defines total items ever stored queue. total-head equals current items queue. @inc_total(n=1) (optional) Increase total, usually need override, unless using files store total want decrease number file connections @append_header(msg, ...) (override) msg vector strings, separated \"|\", containing encoded headers: `time`, `key`, `hash`, `message`. decode inside, can use self$print_items(stringr::str_split_fixed(msg, '\\|', 4)). Make sure return number, indicating number items stored. Unless handled elsewhere, usually return(length(msg)). @store_value(value, key) (override) Defines store value. `key` unique identifier generated time, queue ID, value. Usually use file name key ID database. value arbitrary R object store. need store value somewhere return string passed `hash` self$restore_value. restore_value(hash, key, preserve = FALSE) (override) Method restore value given combination `hash` `key`. `hash` string returned @store_value, `key` key @store_value. preserve indicator whether preserve value future use. set FALSE, supposed free resource related value. (free memory disk space) @log(n = -1, = FALSE) (override) get n items saved @append_header. n less equal 0 means listing possible items. =TRUE, return items (number rows equals self$total), including popped items. =FALSE, return items queue (number rows self$count). returned value n x 4 matrix. Usually use stringr::str_split_fixed(..., '\\|', 4). Please see types implemented example. @reset(...) (override) Reset queue, remove items reset head, total 0. @clean() (override) Clean queue, remove popped items. @validate() (override) Validate queue. Stop queue broken. @connect(con, ...) (override) Set connection. Usually called end self$initialization connect database, folder, existing queue checks whether connection new existing queue. connect(con, ...) (optional) Thread-safe version. sometimes need override function instead @connect, private$exclusive requires lockfile exist locked. lockers ready, need set lockers connection, override one. destroy() (optional) Destroy queue, free space call delayedAssign('.lockfile', {stop(...)}, assign.env=private) raise error destroyed queue called later.","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractQueue.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public Methods","title":"Defines abstract queue class — AbstractQueue","text":"Usually need override unless know . push(value, message='',...) Function push arbitrary R object queue. message string giving notes pushed item. Usually message stored header, separated values. goal describe value. ... passed @append_header pop(n = 1, preserve = FALSE) Pop n items queue. preserve indicates whether free resources, though always guaranteed. print_item(item), print_items(items) decode matrix returned log(), returning named list data frame four heads: `time`, `key`, `hash`, `message`. list(n=-1) List items queue, decoded. n less equal 0, list results. result equivalent self$print_items(self$log(n)) log(n=-1,=FALSE) List items queue, encoded. used self$print_items. =TRUE, result list records ever pushed queue since last time queue cleaned. =FALSE, results items queue. n number items.","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractQueue.html","id":"public-active-bindings","dir":"Reference","previous_headings":"","what":"Public Active Bindings","title":"Defines abstract queue class — AbstractQueue","text":"id Read-property. Returns unique ID current queue. lockfile lock file. head Integer, total number items popped, .e. inactive items. total Total number items ever pushed queue since last cleaned, integer. count Integer, read-, equals total - head, number active items queue","code":""},{"path":"https://dipterix.org/dipsaus/reference/AbstractQueue.html","id":"private-methods-or-properties","dir":"Reference","previous_headings":"","what":"Private Methods or properties","title":"Defines abstract queue class — AbstractQueue","text":".id use directly. Used store queue ID. .lockfile Location lock file. lock Preserve file lock. exclusive(expr,...) Function make sure methods thread-safe default_get_locker() Default method lock queue default_free_locker Default method free queue","code":""},{"path":"https://dipterix.org/dipsaus/reference/PersistContainer.html","id":null,"dir":"Reference","previous_headings":"","what":"Wrapper to cache key-value pairs and persist across sessions — PersistContainer","title":"Wrapper to cache key-value pairs and persist across sessions — PersistContainer","text":"class designed persist arbitrary R objects locally share across different sessions. container consists two-level caches. first one session-based, meaning valid current R session cleared session shut . second persist-level map, persist hard drive shared across sessions. See cache method 'details'.","code":""},{"path":"https://dipterix.org/dipsaus/reference/PersistContainer.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public Methods","title":"Wrapper to cache key-value pairs and persist across sessions — PersistContainer","text":"initialize(..., backend = rds_map) constructor. backend must inherit AbstractMap, ... passed backend$new(...). check available back-ends use cases, see map. reset(= FALSE) Reset container. set true, reset session-based hard-drive-based, otherwise reset session-based container. destroy(= FALSE) destroy container. use want finalize container reg.finalizer. (key, signature = NULL) returns list true/false (logical) vectors indicating whether keys exist container, signature used caching key-value pairs, also checks whether signature matches. important even keys match signature wrong, results false. remove(keys, = TRUE) Remove keys container. Default remove keys levels. =FALSE, remove key current session cache(key, value, signature = NULL, replace = FALSE, persist = FALSE) key signature together form unique identifier value. default signature none, useful value large, key string. replace indicates whether force replace key-value pairs even entry exists. persist true, value stored hard-disks, otherwise value deleted session closed.","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/PersistContainer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Wrapper to cache key-value pairs and persist across sessions — PersistContainer","text":"","code":"container = PersistContainer$new(tempfile()) # Reset the container so that values are cleared container$reset(all = TRUE) # Store `1` to 'a' with signature 111 to a non-persist map # returns 1 container$cache(key = 'a', value = 1, signature = 111, persist = FALSE) #> [1] 1 # Replace 'a' with 3 # returns 3 container$cache(key = 'a', value = 3, signature = 111, persist = TRUE, replace = TRUE) #> [1] 3 # check if 'a' exists with signature 111 container$has('a', signature = 111) # TRUE #> a #> TRUE # When you only have 'a' but no signature container$has('a') # TRUE #> a #> TRUE # check if 'a' exists with wrong signature 222 container$has('a', signature = 222) # FALSE #> a #> FALSE # Store 'a' with 2 with same signature # will fail and ignore the value (value will not be evaluated if signatured) # Return 2 (Important! use cached values) container$cache(key = 'a', value = { print(123) return(2) }, signature = 111, replace = FALSE) #> [1] 3 # When no signature is present # If the key exists (no signature provided), return stored value # returns 3 container$cache(key = 'a', value = 4) #> [1] 3 # replace is TRUE (no signature provided), signature will be some default value container$cache(key = 'a', value = 2, replace = TRUE) #> [1] 2 # destroy the container to free disk space container$destroy()"},{"path":"https://dipterix.org/dipsaus/reference/actionButtonStyled.html","id":null,"dir":"Reference","previous_headings":"","what":"Action Button but with customized styles — actionButtonStyled","title":"Action Button but with customized styles — actionButtonStyled","text":"Action Button customized styles","code":""},{"path":"https://dipterix.org/dipsaus/reference/actionButtonStyled.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Action Button but with customized styles — actionButtonStyled","text":"","code":"actionButtonStyled( inputId, label, icon = NULL, width = NULL, type = \"primary\", btn_type = \"button\", class = \"\", ... )"},{"path":"https://dipterix.org/dipsaus/reference/actionButtonStyled.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Action Button but with customized styles — actionButtonStyled","text":"inputId, label, icon, width, ... passed shiny::actionButton type button type, choices `default`, `primary`, `info`, `success`, `warning`, `danger` btn_type HTML tag type, either \"button\" \"\" class additional classes added button","code":""},{"path":"https://dipterix.org/dipsaus/reference/actionButtonStyled.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Action Button but with customized styles — actionButtonStyled","text":"`HTML` tags","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/actionButtonStyled.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Action Button but with customized styles — actionButtonStyled","text":"","code":"# demo('example-actionButtonStyled', package='dipsaus') library(shiny) library(dipsaus) ui <- fluidPage( actionButtonStyled('btn', label = 'Click me', type = 'default'), actionButtonStyled('btn2', label = 'Click me2', type = 'primary') ) server <- function(input, output, session) { btn_types = c('default', 'primary', 'info', 'success', 'warning', 'danger') observeEvent(input$btn, { btype = btn_types[((input$btn-1) %% (length(btn_types)-1)) + 1] updateActionButtonStyled(session, 'btn2', type = btype) }) observeEvent(input$btn2, { updateActionButtonStyled(session, 'btn', disabled = c(FALSE,TRUE)[(input$btn2 %% 2) + 1]) }) } if( interactive() ){ shinyApp(ui, server, options = list(launch.browser=TRUE)) }"},{"path":"https://dipterix.org/dipsaus/reference/add_to_session.html","id":null,"dir":"Reference","previous_headings":"","what":"Store/Get key-value pairs in 'shiny' session — add_to_session","title":"Store/Get key-value pairs in 'shiny' session — add_to_session","text":"key missing, 'll created, otherwise ignored overwritten.","code":""},{"path":"https://dipterix.org/dipsaus/reference/add_to_session.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Store/Get key-value pairs in 'shiny' session — add_to_session","text":"","code":"add_to_session( session, key = \"rave_id\", val = paste(sample(c(letters, LETTERS, 0:9), 20), collapse = \"\"), override = FALSE )"},{"path":"https://dipterix.org/dipsaus/reference/add_to_session.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Store/Get key-value pairs in 'shiny' session — add_to_session","text":"session 'Shiny' session key character, key store val value store override key exists, whether overwrite value","code":""},{"path":"https://dipterix.org/dipsaus/reference/add_to_session.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Store/Get key-value pairs in 'shiny' session — add_to_session","text":"session shiny session, returns current value stored session, otherwise returns NULL","code":""},{"path":"https://dipterix.org/dipsaus/reference/as_pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert functions to pipe-friendly functions — as_pipe","title":"Convert functions to pipe-friendly functions — as_pipe","text":"Convert functions pipe-friendly functions","code":""},{"path":"https://dipterix.org/dipsaus/reference/as_pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert functions to pipe-friendly functions — as_pipe","text":"","code":"as_pipe( x, ..., call, arg_name, .name = arg_name, .env = parent.frame(), .quoted = FALSE )"},{"path":"https://dipterix.org/dipsaus/reference/as_pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert functions to pipe-friendly functions — as_pipe","text":"x R object input ... default arguments explicitly display returned function call function call, function arg_name argument name varied. argument first argument new function pipe-friendly. .name new argument name; default arg_name .env executing environment .quoted whether call quoted","code":""},{"path":"https://dipterix.org/dipsaus/reference/as_pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert functions to pipe-friendly functions — as_pipe","text":"x missing, returns function takes one argument, otherwise run function given x","code":""},{"path":"https://dipterix.org/dipsaus/reference/as_pipe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert functions to pipe-friendly functions — as_pipe","text":"","code":"# modify a function call vary_title <- as_pipe(call = plot(1:10, 1:10), pch = 16, arg_name = 'main', .name = 'title') vary_title #> #> function (title, ..., pch = 16) #> { #> plot(1:10, 1:10, ..., pch = pch, main = \"[input:title]\") #> } #> # vary_title is pipe-friendly with `pch` default 16 vary_title(title = 'My Title') # `pch` is explicit vary_title(title = 'My Title', pch = 1) # other variables are implicit vary_title(title = 'My Title', type = 'l') # modify a function f <- function(b = 1, x){ b + x } f_pipable <- as_pipe(call = f, arg_name = 'x') f_pipable #> #> function (x, ...) #> { #> f(..., x = \"[input:x]\") #> } #> f_pipable(2) #> [1] 3 # Advanced use # Set option dipsaus.debug.as_pipe=TRUE to debug options(\"dipsaus.debug.as_pipe\" = TRUE) # Both `.(z)` and `z` work image2 <- as_pipe(call = image( x = seq(0, 1, length.out = nrow(z)), y = 1:ncol(z), z = matrix(1:16, 4), xlab = \"Time\", ylab = \"Freq\", main = \"Debug\" ), arg_name = 'z') #> options(\"dipsaus.debug.as_pipe\") is set to TRUE. This should be used only in debug mode. Do not use for production! # main can be overwritten image2(matrix(1:50, 5), main = \"Production\") # reset debug option options(\"dipsaus.debug.as_pipe\" = FALSE)"},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a Line from the Terminal, but with Default Values — ask_or_default","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"Ask question read terminal interactive scenario","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"","code":"ask_or_default(..., default = \"\", end = \"\", level = \"INFO\")"},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"..., end, level passed cat2 default default value return case blank input","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"character user's input, default value. See details.","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"prompt string ask question, providing defaults. Users need enter answer. answer blank (space), returns default, otherwise returns user input. can used interactive session.","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/ask_or_default.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read a Line from the Terminal, but with Default Values — ask_or_default","text":"","code":"if(interactive()){ ask_or_default('What is the best programming language?', default = 'PHP') }"},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":null,"dir":"Reference","previous_headings":"","what":"Ask and Return True or False from the Terminal — ask_yesno","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"Ask question read terminal interactive scenario","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"","code":"ask_yesno( ..., end = \"\", level = \"INFO\", error_if_canceled = TRUE, use_rs = TRUE, ok = \"Yes\", cancel = \"No\", rs_title = \"Yes or No:\" )"},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"..., end, level passed cat2 error_if_canceled raise error canceled use_rs whether use rstudioapi possible ok button label yes cancel button label rs_title message title 'RStudio' question box pops .","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"logical NULL raise error. \"yes\" entered, returns TRUE; \"\" entered, returns FALSE; \"c\" entered, error_if_canceled=TRUE result error, otherwise return NULL","code":""},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"prompt string ask yes question. Users need enter \"y\", \"yes\" yes, \"n\", \"\" , \"c\" cancel (case-insensitive). can used interactive session.","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/ask_yesno.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ask and Return True or False from the Terminal — ask_yesno","text":"","code":"if(interactive()){ ask_yesno('Do you know how hard it is to submit an R package and ', 'pass the CRAN checks?') ask_yesno('Can I pass the CRAN check this time?') }"},{"path":"https://dipterix.org/dipsaus/reference/async.html","id":null,"dir":"Reference","previous_headings":"","what":"Evaluate expression in async_expr — async","title":"Evaluate expression in async_expr — async","text":"Evaluate expression async_expr","code":""},{"path":"https://dipterix.org/dipsaus/reference/async.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Evaluate expression in async_expr — async","text":"","code":"async(expr)"},{"path":"https://dipterix.org/dipsaus/reference/async.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Evaluate expression in async_expr — async","text":"expr R expression","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/async_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply R expressions in a parallel way — async_expr","title":"Apply R expressions in a parallel way — async_expr","text":"Apply R expressions parallel way","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply R expressions in a parallel way — async_expr","text":"","code":"async_expr( .X, .expr, .varname = \"x\", envir = parent.frame(), .pre_run = NULL, .ncore = future::availableCores(), ... )"},{"path":"https://dipterix.org/dipsaus/reference/async_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply R expressions in a parallel way — async_expr","text":".X vector list apply evaluation .expr R expression, unquoted .varname variable name representing element .X envir environment evaluate expressions .pre_run expressions evaluated looping. .ncore number CPU cores ... passed future::future","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply R expressions in a parallel way — async_expr","text":"list whose length equals .X. value item returned depends whether async called. See details workflow.","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_expr.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Apply R expressions in a parallel way — async_expr","text":"async_expr uses lapply future::future internally. Within loop, item \".X\" assigned variable \"x\" (defined \".varname\") enter evaluation. evaluation, function async provided. Expressions within async evaluated another session, otherwise evaluated current session. workflow: Run .pre_run seq_along(.X): 1. Assign x .X[[]], variable name x defined .varname 2. Evaluate expr current session. . async called, return evaluated expr b. async(aync_expr) called, evaluate aync_expr another session, return evaluation results aync_expr","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_flapply.html","id":null,"dir":"Reference","previous_headings":"","what":"Wrapper for future.apply::future_lapply — async_flapply","title":"Wrapper for future.apply::future_lapply — async_flapply","text":"Wrapper future.apply::future_lapply","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_flapply.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wrapper for future.apply::future_lapply — async_flapply","text":"","code":"async_flapply(X, FUN, ...)"},{"path":"https://dipterix.org/dipsaus/reference/async_flapply.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Wrapper for future.apply::future_lapply — async_flapply","text":"X, FUN, ... passing future.apply::future_lapply","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":null,"dir":"Reference","previous_headings":"","what":"Run jobs in other R sessions without waiting — async_works","title":"Run jobs in other R sessions without waiting — async_works","text":"function deprecated. Please use lapply_callr instead.","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run jobs in other R sessions without waiting — async_works","text":"","code":"async_works( X, FUN, ..., .globals = NULL, .name = \"Untitled\", .rs = FALSE, .wait = TRUE, .chunk_size = Inf, .nworkers = future::availableCores(), .simplify = FALSE, .quiet = FALSE, .log )"},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run jobs in other R sessions without waiting — async_works","text":"X vector list applied FUN function first argument element X ... arguments passed FUN .globals global variables evaluated FUN .name job names, used backed rstudioapi jobs .rs whether use rstudioapi jobs .wait whether wait results .chunk_size used .wait=FALSE, chunk size workers time. useful printing progress messages, might slow process .chunk_size small .nworkers number workers time .simplify whether simplify results, .e. merge list results vectors arrays .quiet whether suppress printing messages .log internally used","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run jobs in other R sessions without waiting — async_works","text":".wait=TRUE, returns applied results FUN X. result types depend .simplify (compare difference lapply sapply). .wait=FALSE, returns function can check result. function takes timeout argument blocks session timeout seconds waiting results. See examples.","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run jobs in other R sessions without waiting — async_works","text":"Unlike future package, global variables can automatically detected, async_works require users specify global variables explicitly via .globals async_works almost surely slower future.apply packages. However, provides functionality future.apply can hardly achieve: non-block. setting .wait=FALSE, process run background, one may run many tasks want. especially useful large data generating process occurs ( read file, process, generate summarizing reports).","code":""},{"path":"https://dipterix.org/dipsaus/reference/async_works.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run jobs in other R sessions without waiting — async_works","text":"","code":"if (FALSE) { # requires a sub-process to run the code # Basic usage a <- 1 async_works(1:10, function(ii){ ii + a # sub-process don't know a, hence must pass a as globals }, .globals = list(a = a)) # non-blocking case system.time({ check <- async_works(1:10, function(ii){ # simulating process, run run run Sys.sleep(ii) Sys.getpid() }, .wait = FALSE) }) # check the results res <- check(timeout = 0.1) attr(res, 'resolved') # whether it's resolved # block the session waiting for the results res <- check(timeout = Inf) attr(res, 'resolved') }"},{"path":"https://dipterix.org/dipsaus/reference/attached_packages.html","id":null,"dir":"Reference","previous_headings":"","what":"Get attached package names in current session (Internally used) — attached_packages","title":"Get attached package names in current session (Internally used) — attached_packages","text":"Get attached package names current session (Internally used)","code":""},{"path":"https://dipterix.org/dipsaus/reference/attached_packages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get attached package names in current session (Internally used) — attached_packages","text":"","code":"attached_packages(include_base = FALSE)"},{"path":"https://dipterix.org/dipsaus/reference/attached_packages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get attached package names in current session (Internally used) — attached_packages","text":"include_base whether include base packages","code":""},{"path":"https://dipterix.org/dipsaus/reference/attached_packages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get attached package names in current session (Internally used) — attached_packages","text":"characters, package names attached current session","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64-url.html","id":null,"dir":"Reference","previous_headings":"","what":"Encode or decode 'base64' — base64-url","title":"Encode or decode 'base64' — base64-url","text":"Compatible results package 'base64url', implemented package 'base64enc'. simply like depend two packages can achieve goal. implementation slower. 'base64url' installed, please use version.","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64-url.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Encode or decode 'base64' — base64-url","text":"","code":"base64_urlencode(x) base64_urldecode(x)"},{"path":"https://dipterix.org/dipsaus/reference/base64-url.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Encode or decode 'base64' — base64-url","text":"x character vector encode decode","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64-url.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Encode or decode 'base64' — base64-url","text":"character vector length x","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64-url.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Encode or decode 'base64' — base64-url","text":"","code":"x = \"plain text\" encoded = base64_urlencode(x) decoded = base64_urldecode(encoded) print(encoded) #> [1] \"cGxhaW4gdGV4dA\" print(decoded) #> [1] \"plain text\""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_image.html","id":null,"dir":"Reference","previous_headings":"","what":"Save ","title":"Save ","text":"Save \"Base64\" Data Images","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_image.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Save ","text":"","code":"base64_to_image(data, path)"},{"path":"https://dipterix.org/dipsaus/reference/base64_to_image.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Save ","text":"data characters, encoded \"Base64\" data images path file path save ","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_image.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Save ","text":"Absolute path saved file","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert ","title":"Convert ","text":"Decode \"Base64\" data generating characters","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert ","text":"","code":"base64_to_string(what)"},{"path":"https://dipterix.org/dipsaus/reference/base64_to_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert ","text":"characters, encoded \"Base64\" data","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert ","text":"String","code":""},{"path":"https://dipterix.org/dipsaus/reference/base64_to_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert ","text":"","code":"input <- \"The quick brown fox jumps over the lazy dog\" # Base64 encode what <- base64enc::base64encode(what = charToRaw(input)) # Base64 decode base64_to_string(what) #> [1] \"The quick brown fox jumps over the lazy dog\""},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate Contrasts of Arrays in Different Methods — baseline_array","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"Provides five methods baseline array calculate contrast.","code":""},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"","code":"baseline_array( x, along_dim, baseline_indexpoints, unit_dims = seq_along(dim(x))[-along_dim], method = c(\"percentage\", \"sqrt_percentage\", \"decibel\", \"zscore\", \"sqrt_zscore\", \"subtract_mean\") )"},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"x array (tensor) calculate contrast along_dim integer range 1 maximum dimension x. baseline along dimension, usually time dimension. baseline_indexpoints integer vector, index points counted baseline window? index ranges 1 dim(x)[[along_dim]]. See Details. unit_dims integer vector, baseline unit: see Details. method character, baseline method options : \"percentage\", \"sqrt_percentage\", \"decibel\", \"zscore\", \"sqrt_zscore\"","code":""},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"Contrast array dimension x.","code":""},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"Consider scenario want baseline bunch signals recorded different locations. location, record n sessions. session, signal decomposed frequency-time domain. case, input x following form: $$session x frequency x time x location$$ Now want calibrate signals session, frequency location using first 100 time points baseline points, code $$baseline_array(x, along_dim=3, 1:100, unit_dims=c(1,2,4))$$ along_dim=3 dimension time, case, third dimension x. baseline_indexpoints=1:100, meaning first 100 time points used calculate baseline. unit_dims defines unit signal. value c(1,2,4) means unit signal per session (first dimension), per frequency (second) per location (fourth). cases, might want calculate baseline across frequencies unit signal \\(frequency x time\\), .e. signals share session location also share baseline. case, assign unit_dims=c(1,4). five baseline methods. fit different types data. Denote \\(z\\) unit signal, \\(z_0\\) baseline slice. baseline methods : \"percentage\" $$ \\frac{z - \\bar{z_{0}}}{\\bar{z_{0}}} \\times 100\\% $$ \"sqrt_percentage\" $$ \\frac{\\sqrt{z} - \\bar{\\sqrt{z_{0}}}}{\\bar{\\sqrt{z_{0}}}} \\times 100\\% $$ \"decibel\" $$ 10 \\times ( \\log_{10}(z) - \\bar{\\log_{10}(z_{0})} ) $$ \"zscore\" $$ \\frac{z-\\bar{z_{0}}}{sd(z_{0})} $$ \"sqrt_zscore\" $$ \\frac{\\sqrt{z}-\\bar{\\sqrt{z_{0}}}}{sd(\\sqrt{z_{0}})} $$","code":""},{"path":"https://dipterix.org/dipsaus/reference/baseline_array.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate Contrasts of Arrays in Different Methods — baseline_array","text":"","code":"library(dipsaus) set.seed(1) # Generate sample data dims = c(10,20,30,2) x = array(rnorm(prod(dims))^2, dims) # Set baseline window to be arbitrary 10 timepoints baseline_window = sample(30, 10) # ----- baseline percentage change ------ # Using base functions re1 <- aperm(apply(x, c(1,2,4), function(y){ m <- mean(y[baseline_window]) (y/m - 1) * 100 }), c(2,3,1,4)) # Using dipsaus re2 <- baseline_array(x, 3, baseline_window, c(1,2,4), method = 'percentage') # Check different, should be very tiny (double precisions) range(re2 - re1) #> [1] -4.547474e-13 1.818989e-12 # Check speed for large dataset if(interactive()){ dims = c(200,20,300,2) x = array(rnorm(prod(dims))^2, dims) # Set baseline window to be arbitrary 10 timepoints baseline_window = seq_len(100) f1 <- function(){ aperm(apply(x, c(1,2,4), function(y){ m <- mean(y[baseline_window]) (y/m - 1) * 100 }), c(2,3,1,4)) } f2 <- function(){ # equivalent as bl = x[,,baseline_window, ] # baseline_array(x, along_dim = 3, baseline_indexpoints = baseline_window, unit_dims = c(1,2,4), method = 'sqrt_percentage') } microbenchmark::microbenchmark(f1(), f2(), times = 3L) }"},{"path":"https://dipterix.org/dipsaus/reference/capture_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Captures Evaluation Output of Expressions as One Single String — capture_expr","title":"Captures Evaluation Output of Expressions as One Single String — capture_expr","text":"Evaluate expression captures output characters, concatenate one single string.","code":""},{"path":"https://dipterix.org/dipsaus/reference/capture_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Captures Evaluation Output of Expressions as One Single String — capture_expr","text":"","code":"capture_expr(expr, collapse = \"\\n\", type = c(\"output\", \"message\"), ...)"},{"path":"https://dipterix.org/dipsaus/reference/capture_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Captures Evaluation Output of Expressions as One Single String — capture_expr","text":"expr R expression collapse character concatenate outputs type, ... passed capture.output","code":""},{"path":"https://dipterix.org/dipsaus/reference/capture_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Captures Evaluation Output of Expressions as One Single String — capture_expr","text":"Character length 1: output captured capture.output","code":""},{"path":"https://dipterix.org/dipsaus/reference/capture_expr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Captures Evaluation Output of Expressions as One Single String — capture_expr","text":"","code":"x <- data.frame(a=1:10) x_str <- capture_expr({ print(x) }) x_str #> [1] \" a\\n1 1\\n2 2\\n3 3\\n4 4\\n5 5\\n6 6\\n7 7\\n8 8\\n9 9\\n10 10\" cat(x_str) #> a #> 1 1 #> 2 2 #> 3 3 #> 4 4 #> 5 5 #> 6 6 #> 7 7 #> 8 8 #> 9 9 #> 10 10"},{"path":"https://dipterix.org/dipsaus/reference/cat2.html","id":null,"dir":"Reference","previous_headings":"","what":"Color Output — cat2","title":"Color Output — cat2","text":"Color Output","code":""},{"path":"https://dipterix.org/dipsaus/reference/cat2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Color Output — cat2","text":"","code":"cat2( ..., level = \"DEBUG\", print_level = FALSE, file = \"\", sep = \" \", fill = FALSE, labels = NULL, append = FALSE, end = \"\\n\", pal = list(DEBUG = \"grey60\", INFO = \"#1d9f34\", WARNING = \"#ec942c\", ERROR = \"#f02c2c\", FATAL = \"#763053\", DEFAULT = \"grey60\"), use_cli = TRUE, bullet = \"auto\" )"},{"path":"https://dipterix.org/dipsaus/reference/cat2.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Color Output — cat2","text":"... printed level 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL' (total 5 levels) print_level true, prepend levels messages file, sep, fill, labels, append pass base::cat end character append string pal named list defining colors see details use_cli logical, whether use package 'cli' bullet character, use 'cli', symbol show. see symbol","code":""},{"path":"https://dipterix.org/dipsaus/reference/cat2.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Color Output — cat2","text":"none.","code":""},{"path":"https://dipterix.org/dipsaus/reference/cat2.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Color Output — cat2","text":"five levels colors default: 'DEBUG', 'INFO', 'WARNING', 'ERROR', FATAL. Default colors : 'DEBUG' (grey60), 'INFO' (#1d9f34), 'WARNING' (#ec942c), 'ERROR' (#f02c2c), 'FATAL' (#763053) 'DEFAULT' (#000000, black). level preset five levels, color \"default\"-black color.","code":""},{"path":"https://dipterix.org/dipsaus/reference/check_installed_packages.html","id":null,"dir":"Reference","previous_headings":"","what":"Check If Packages Are Installed, Returns Missing Packages — check_installed_packages","title":"Check If Packages Are Installed, Returns Missing Packages — check_installed_packages","text":"Check Packages Installed, Returns Missing Packages","code":""},{"path":"https://dipterix.org/dipsaus/reference/check_installed_packages.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check If Packages Are Installed, Returns Missing Packages — check_installed_packages","text":"","code":"check_installed_packages( pkgs, libs = base::.libPaths(), auto_install = FALSE, ... )"},{"path":"https://dipterix.org/dipsaus/reference/check_installed_packages.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check If Packages Are Installed, Returns Missing Packages — check_installed_packages","text":"pkgs vector packages install libs paths libraries auto_install automatically install packages missing ... parameters install.packages","code":""},{"path":"https://dipterix.org/dipsaus/reference/check_installed_packages.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check If Packages Are Installed, Returns Missing Packages — check_installed_packages","text":"package names installed","code":""},{"path":"https://dipterix.org/dipsaus/reference/clear_env.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to clear all elements within environment — clear_env","title":"Function to clear all elements within environment — clear_env","text":"Function clear elements within environment","code":""},{"path":"https://dipterix.org/dipsaus/reference/clear_env.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to clear all elements within environment — clear_env","text":"","code":"clear_env(env, ...)"},{"path":"https://dipterix.org/dipsaus/reference/clear_env.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to clear all elements within environment — clear_env","text":"env environment clean, can R environment, fastmap2 instance ... ignored","code":""},{"path":"https://dipterix.org/dipsaus/reference/clear_env.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to clear all elements within environment — clear_env","text":"","code":"env = new.env() env$a = 1 print(as.list(env)) #> $a #> [1] 1 #> clear_env(env) print(as.list(env)) #> list()"},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert color to Hex string — col2hexStr","title":"Convert color to Hex string — col2hexStr","text":"Convert color Hex string","code":""},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert color to Hex string — col2hexStr","text":"","code":"col2hexStr(col, alpha = NULL, prefix = \"#\", ...)"},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert color to Hex string — col2hexStr","text":"col character integer indicating color alpha NULL numeric, transparency. See grDevices::rgb prefix character, default \"#\" ... passing adjustcolor","code":""},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert color to Hex string — col2hexStr","text":"characters containing hex value color. See details","code":""},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert color to Hex string — col2hexStr","text":"col2hexStr converts colors 1, 2, 3, \"red\", \"blue\", ... hex strings can easily recognized `HTML`, `CSS` `JavaScript`. Internally function uses adjustcolor two differences: returned hex string contain alpha value alpha NULL; leading prefix \"#\" can customized","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/col2hexStr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert color to Hex string — col2hexStr","text":"","code":"col2hexStr(1, prefix = '0x') # \"0x000000\" #> [1] \"0x000000\" col2hexStr('blue') # \"#0000FF\" #> [1] \"#0000FF\" # Change default palette, see \"grDevices::colors()\" grDevices::palette(c('orange3', 'skyblue1')) col2hexStr(1) # Instead of #000000, #CD8500 #> [1] \"#CD8500\""},{"path":"https://dipterix.org/dipsaus/reference/collapse.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse Sensors And Calculate Summations/Mean — collapse","title":"Collapse Sensors And Calculate Summations/Mean — collapse","text":"Collapse Sensors Calculate Summations/Mean","code":""},{"path":"https://dipterix.org/dipsaus/reference/collapse.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse Sensors And Calculate Summations/Mean — collapse","text":"","code":"collapse(x, keep, average = FALSE)"},{"path":"https://dipterix.org/dipsaus/reference/collapse.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse Sensors And Calculate Summations/Mean — collapse","text":"x numeric multi-mode tensor (array), without NA keep dimension keep average collapse sum mean","code":""},{"path":"https://dipterix.org/dipsaus/reference/collapse.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse Sensors And Calculate Summations/Mean — collapse","text":"collapsed array values mean summation along collapsing dimensions","code":""},{"path":"https://dipterix.org/dipsaus/reference/collapse.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse Sensors And Calculate Summations/Mean — collapse","text":"","code":"# Example 1 x = matrix(1:16, 4) # Keep the first dimension and calculate sums along the rest collapse(x, keep = 1) #> [1] 28 32 36 40 rowSums(x) # Should yield the same result #> [1] 28 32 36 40 # Example 2 x = array(1:120, dim = c(2,3,4,5)) result = collapse(x, keep = c(3,2)) compare = apply(x, c(3,2), sum) sum(abs(result - compare)) # The same, yield 0 or very small number (1e-10) #> [1] 0 # Example 3 (performance) # Small data, no big difference, even slower x = array(rnorm(240), dim = c(4,5,6,2)) microbenchmark::microbenchmark( result = collapse(x, keep = c(3,2)), compare = apply(x, c(3,2), sum), times = 1L, check = function(v){ max(abs(range(do.call('-', v)))) < 1e-10 } ) #> Unit: microseconds #> expr min lq mean median uq max neval #> result 854.983 854.983 854.983 854.983 854.983 854.983 1 #> compare 665.530 665.530 665.530 665.530 665.530 665.530 1 # large data big difference x = array(rnorm(prod(300,200,105)), c(300,200,105,1)) microbenchmark::microbenchmark( result = collapse(x, keep = c(3,2)), compare = apply(x, c(3,2), sum), times = 1L , check = function(v){ max(abs(range(do.call('-', v)))) < 1e-10 }) #> Unit: milliseconds #> expr min lq mean median uq max neval #> result 45.76934 45.76934 45.76934 45.76934 45.76934 45.76934 1 #> compare 115.42565 115.42565 115.42565 115.42565 115.42565 115.42565 1"},{"path":"https://dipterix.org/dipsaus/reference/compoundInput2.html","id":null,"dir":"Reference","previous_headings":"","what":"Compound input that combines and extends shiny inputs — compoundInput2","title":"Compound input that combines and extends shiny inputs — compoundInput2","text":"Compound input combines extends shiny inputs","code":""},{"path":"https://dipterix.org/dipsaus/reference/compoundInput2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compound input that combines and extends shiny inputs — compoundInput2","text":"","code":"compoundInput2( inputId, label = \"Group\", components = shiny::tagList(), initial_ncomp = 1, min_ncomp = 0, max_ncomp = 10, value = NULL, label_color = NA, max_height = NULL, ... )"},{"path":"https://dipterix.org/dipsaus/reference/compoundInput2.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compound input that combines and extends shiny inputs — compoundInput2","text":"inputId character, shiny input ID label character, show groups components `HTML` tags defines combines HTML components within groups initial_ncomp numeric initial number groups show, non-negative min_ncomp minimum number groups, default 0, non-negative max_ncomp maximum number groups, default 10, greater equal min_ncomp value list lists, initial values inputs, see examples. label_color integer characters, length 1 max_ncomp, assigning colors group labels; default NA, try get color foreground par(\"fg\") max_height maximum height widget ... ignored","code":""},{"path":"https://dipterix.org/dipsaus/reference/compoundInput2.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compound input that combines and extends shiny inputs — compoundInput2","text":"`HTML` tags","code":""},{"path":[]},{"path":"https://dipterix.org/dipsaus/reference/compoundInput2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compound input that combines and extends shiny inputs — compoundInput2","text":"","code":"library(shiny); library(dipsaus) compoundInput2( 'input_id', 'Group', div( textInput('text', 'Text Label'), sliderInput('sli', 'Slider Selector', value = 0, min = 1, max = 1) ), label_color = 1:10, value = list( list(text = '1'), # Set text first group to be \"1\" list(), # no settings for second group list(sli = 0.2) # sli = 0.2 for the third group )) #> Warning: In sliderInput(): `value` should be greater than or equal to `min` (value = 0, min = 1). #> Warning: In sliderInput(): `value` should be greater than or equal to `min` (value = 0, min = 1). #>
#>
{\"template\":[\"<div class=\\\"dipsaus-compound-input-item col-xs-12\\\" data-value=\\\"${{ind}}\\\">\\n <fieldset style=\\\"border: 1px solid #efefef; padding:.35em .625em .75em; margin-bottom: 15px;\\\">\\n <legend style=\\\"border:none; margin: 0; padding: 0 10px; font-size: 14px; color: ${{label_color}}\\\">Group - ${{ind}}<\\/legend>\\n <div>\\n <div class=\\\"form-group shiny-input-container\\\">\\n <label class=\\\"control-label\\\" id=\\\"input_id_text_${{ind}}-label\\\" for=\\\"input_id_text_${{ind}}\\\">Text Label<\\/label>\\n <input id=\\\"input_id_text_${{ind}}\\\" type=\\\"text\\\" class=\\\"shiny-input-text form-control\\\" value=\\\"\\\"/>\\n <\\/div>\\n <div class=\\\"form-group shiny-input-container\\\">\\n <label class=\\\"control-label\\\" id=\\\"input_id_sli_${{ind}}-label\\\" for=\\\"input_id_sli_${{ind}}\\\">Slider Selector<\\/label>\\n <input class=\\\"js-range-slider\\\" id=\\\"input_id_sli_${{ind}}\\\" data-skin=\\\"shiny\\\" data-min=\\\"1\\\" data-max=\\\"1\\\" data-from=\\\"0\\\" data-step=\\\"0.02\\\" data-grid=\\\"true\\\" data-grid-num=\\\"NaN\\\" data-grid-snap=\\\"false\\\" data-prettify-separator=\\\",\\\" data-prettify-enabled=\\\"true\\\" data-keyboard=\\\"true\\\" data-data-type=\\\"number\\\"/>\\n <\\/div>\\n <\\/div>\\n <\\/fieldset>\\n<\\/div>\"],\"initial_ncomp\":[1],\"min_ncomp\":[0],\"max_ncomp\":[10],\"bind_infos\":{\"text\":{\"binding\":[\"shiny.textInput\"],\"update_function\":[\"shiny::updateTextInput\"],\"call_function\":[\"shiny::textInput\"]},\"sli\":{\"binding\":[\"shiny.sliderInput\"],\"update_function\":[\"shiny::updateSliderInput\"],\"call_function\":[\"shiny::sliderInput\"]}},\"label_color\":[\"#CD8500\",\"#87CEFF\",\"#CD8500\",\"#87CEFF\",\"#CD8500\",\"#87CEFF\",\"#CD8500\",\"#87CEFF\",\"#CD8500\",\"#87CEFF\"],\"initial_value\":[{\"text\":[\"1\"]},[],{\"sli\":[0.2]}]}<\/div> #>
<\/div> #>
#>
<\/div> #> <\/div> #>
#>
#>
#> Group - ...junk...<\/legend> #>
#>
#>