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
| // [[Rcpp::depends(RcppArmadillo, bigmemory, BH)]] | |
| #include <RcppArmadillo.h> | |
| #include <bigmemory/MatrixAccessor.hpp> | |
| using namespace Rcpp; | |
| // [[Rcpp::export]] | |
| NumericVector prod1(XPtr<BigMatrix> bMPtr, const NumericVector& x) { | |
| MatrixAccessor<char> macc(*bMPtr); |
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
| #include <Rcpp.h> | |
| using namespace Rcpp; | |
| // [[Rcpp::export]] | |
| bool checkDuplicate(const IntegerMatrix& pop, int ind) { | |
| if (ind == 1) { | |
| return(true); | |
| } else { | |
| int i, j, k = ind - 1; | |
| int n = pop.nrow(); |
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
| N <- 23e4 | |
| n <- 2e4 | |
| prb <- ifelse(sample(0:1, size = N, replace = TRUE) == 1, 1.0, 0.05) | |
| smpl <- sampling::UPrandomsystematic(n / sum(prb) * prb) | |
| table(prb[as.logical(smpl)]) | |
| table(prb[sample.int(N, size = n, replace = FALSE, prob = prb)]) |
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
| unicode2hex <- function(html_file) { | |
| new_text <- gsub(pattern = "<U\\+([0-9]{4})>", replacement = "&#x\\1", | |
| x = readLines(html_file, encoding = "UTF-8")) | |
| writeLines(new_text, con = html_file, useBytes = TRUE) | |
| } |
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
| #### IN ORDER #### | |
| # In first session, run: | |
| write(1, "test.txt") | |
| obj.lock <- flock::lock("test.txt") | |
| # In second session, run this (this will wait the unlock in the first session) | |
| obj.lock <- flock::lock("test.txt") | |
| write(2, "test.txt", append = TRUE) | |
| flock::unlock(obj.lock) |
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
| library(dplyr) | |
| # dplyr programming | |
| my_summarise <- function(df, group) { | |
| group <- enquo(group) | |
| df %>% | |
| group_by(!!group) %>% | |
| summarise_all(mean) | |
| } |
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
| library(dplyr) | |
| # dplyr programming | |
| my_summarise <- function(df, group) { | |
| group <- enquo(group) | |
| df %>% | |
| group_by(!!group) %>% | |
| summarise_all(mean) | |
| } |
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
| library(dplyr) | |
| # dplyr programming | |
| my_summarise <- function(df, group) { | |
| group <- enquo(group) | |
| df %>% | |
| group_by(!!group) %>% | |
| summarise_all(mean) | |
| } |
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
| library(dplyr) | |
| # dplyr programming | |
| my_summarise <- function(df, group) { | |
| group <- enquo(group) | |
| df %>% | |
| group_by(!!group) %>% | |
| summarise_all(mean) | |
| } |
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
| MY_THEME <- function(p, coeff = 1) { | |
| p + theme_bw() + | |
| theme(plot.title = element_text(size = rel(2.0 * coeff), hjust = 0.5), | |
| plot.subtitle = element_text(size = rel(1.5 * coeff), hjust = 0.5), | |
| legend.title = element_text(size = rel(1.8 * coeff)), | |
| legend.text = element_text(size = rel(1.3 * coeff)), | |
| axis.title = element_text(size = rel(1.5 * coeff)), | |
| axis.text = element_text(size = rel(1.2 * coeff)), | |
| legend.key.height = unit(1.3 * coeff, "line"), | |
| legend.key.width = unit(1.3 * coeff, "line")) |
OlderNewer