This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| counts.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rlang::last_error() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| future::plan(future:::multiprocess) | |
| do_and_return = function(tbl, code){ | |
| # Execute future | |
| dummy = future::future(code()) | |
| # Return | |
| tbl | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| approximated_modified_bessel_second_kind_log = function(z, v, s = max(0,v-10)){ | |
| # s = 0 not approximated | |
| 0.5 * ( log(pi) - log(2) ) + (-z - 0.5 * log(z)) + | |
| foreach(j = s:floor(v-0.5), .combine = c) %do% { | |
| lgamma(j + abs(v) - 0.5 + 1) - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generate_gamma_sum <- function(N, k, theta) { | |
| n_means = length(k) | |
| sums = numeric(N) | |
| for(n in 1:N) sums[n] = sum(rgamma(n_means, shape = k, scale = theta)) | |
| list(sums = sums, shape = k, scale = theta) | |
| } | |
| k=c(3,4,5) | |
| theta=c(1, 2, 1) | |
| generate_gamma_sum(10000, c(3,4,5), c(1, 2, 1)) %$% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #################################################################### | |
| # From within R | |
| #################################################################### | |
| #################################################################### | |
| # Initialisation of makefiles | |
| #################################################################### | |
| dotR <- file.path(Sys.getenv("HOME"), ".R") | |
| if (!file.exists(dotR)) dir.create(dotR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get_bimodality = function(fit) { | |
| fit %>% | |
| tidybayes::gather_draws(exposure_rate[S]) %>% summarise( | |
| bimodal = diptest::dip.test(`.value`) %$% `p.value` | |
| ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ToDataFrameTypeColFull = function(tree, ...){ | |
| tree %>% | |
| Clone() %>% | |
| { | |
| t = (.) | |
| foreach(l=1:(t %$% Get("level") %>% max), .combine = bind_rows) %do% { | |
| data.tree::Clone(t) %>% | |
| { data.tree::Prune(., function(x) x$level <= l + 1); . } %>% | |
| data.tree::ToDataFrameTypeCol(...) %>% | |
| as_tibble |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Convert array of quosure (e.g. c(col_a, col_b)) into character vector | |
| #' | |
| #' @keywords internal | |
| #' | |
| #' @importFrom rlang quo_name | |
| #' @importFrom rlang quo_squash | |
| #' @importFrom purrr when | |
| #' @importFrom magrittr equals | |
| #' | |
| #' @param v A array of quosures (e.g. c(col_a, col_b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Theme | |
| friendly_cols <- dittoSeq::dittoColors() | |
| # scale_fill_manual(values = friendly_cols) | |
| # scale_color_manual(values = friendly_cols) | |
| theme_multipanel = | |
| theme_bw() + | |
| theme( | |
| panel.border = element_blank(), |
OlderNewer