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
Comparison of mutr, testthat, and tinytest | |
Mutr | |
Purpose: A minimalistic unit-testing framework designed for simplicity and ease of integration into small projects. | |
Features: Provides core testing functions (TEST, TEST_SET, TEST_ERROR), simple test reporting, and minimal dependency (base R). | |
Advantages: Extremely lightweight and easy to use for self-contained or basic testing scenarios. | |
Limitations: Lacks advanced features like mocking, test parameterization, or integration with CI systems, making it unsuitable for complex projects. | |
Testthat | |
Purpose: The most popular and feature-rich testing framework for R, designed for comprehensive testing of R packages. |
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
error404 = paste0( | |
"<!DOCTYPE html>", | |
"<html lang=\"en\">", | |
"<head>", | |
" <meta charset=\"UTF-8\">", | |
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">", | |
" <title>Resources not found</title>", | |
"</head>", | |
"<body>", | |
" <div class=\"main\">", |
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
# unison-fsmonitor is not available in the repositories | |
# it is reported and discussed for like 8 years already | |
# there is no hope, only manual compile | |
#!/bin/bash | |
UNISON_VERSION=2.51.5 # version in Ubuntu repo | |
echo "Install Unison." \ | |
&& apt install wget ocaml \ | |
&& pushd /tmp \ | |
&& wget https://github.com/bcpierce00/unison/archive/v$UNISON_VERSION.tar.gz \ |
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
is_odd_bitwise = \(x) bitwAnd(x, 1L) | |
is_odd_mod = \(x) x %% 2L | |
s = sample(1:1e7) | |
bench::mark(is_odd_bitwise(s), is_odd_mod(s)) |
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
# constructor based on the simpleError function | |
my_error = function(message, call = NULL){ | |
class = c("my_error", "error", "condition") | |
structure( | |
list(as.character(message), call = call), | |
class = class | |
) | |
} | |
# my_error still needs to be signaled with stop(): |
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
count_to = function(x = 5){ | |
current = 0 | |
function(){ | |
if(i >= x) | |
return(NULL) | |
i <<- i+1 | |
i | |
} | |
} |
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
#' sra.r | |
#' | |
#' Function for a programatical access to a SRA and GEO databases | |
#' | |
#' depends on rentrez, matrittr and xml packages | |
#' externally depends on sratools, all sratools must be available in path | |
import::here("magrittr", "%>%") | |
import::here("xml2", "read_xml", "as_list") | |
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<beast namespace="beast.core:beast.evolution.alignment:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood" required="" version="2.6"> | |
<data id="test" dataType="standard"> | |
<sequence taxon="A">0325001134145320315521441333450540150340142324031053552343434540345422555515404425225332030455334311</sequence> | |
<sequence taxon="B">3303111402245533434135501501430403113451242121243211312030250523440504251354554250554133235411202323</sequence> | |
<sequence taxon="C">0203545342141415331211042134245105533321245534032452154450211324241122021354024412103533542044452213</sequence> | |
<sequence taxon="D">5321401114230445532511142242040052431341215151200525030545523403103545524535302424314202314031013500</sequence> | |
<sequence taxon="E">00433510520542445013055315141311044142443015520443332013354310110010033533343440431233501314422223 |
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
turn_of_casting = function(spell_fatigue, reinvigoration, turn_max=100){ | |
tcast = c() | |
fatigue = 0 | |
for(turn in seq_len(turn_max)){ | |
if(fatigue < 100){ | |
# cast spell | |
fatigue = fatigue + spell_fatigue | |
tcast = c(tcast, turn) | |
} else { |