Skip to content

Instantly share code, notes, and snippets.

View zkamvar's full-sized avatar
🐈‍⬛

Zhian N. Kamvar zkamvar

🐈‍⬛
View GitHub Profile
@zkamvar
zkamvar / maintainer-check.R
Last active August 7, 2023 20:57
Get maintainers who still need to confirm that they have reset their local repositories
#' List maintainers who still need to respond to the Workbench transition issue
#'
#' @param org the name of the github organisation
#' @param repo name of the repository
#' @return a character vector of github user names for maintainers who still need to confirm
#' transition to The Workbench
#'
#' @details The Workbench transition requires maintainers to confirm that they have re-cloned
#' their local repositories to avoid a situation where they overwrite commits with the old
#' version of the repository
@zkamvar
zkamvar / scrape-workshops.R
Created November 8, 2022 15:57
Scrape lessons from workshops and determine if they have workbench lessons
library("jsonlite")
library("polite")
library("rvest")
library("purrr")
library("dplyr")
workbench_slugs <- c(
"r-ecology-lesson",
"r-socialsci",
@zkamvar
zkamvar / renv.lock
Created December 15, 2021 18:29
renv.lock file from failing repo
{
"R": {
"Version": "4.1.0",
"Repositories": [
{
"Name": "carpentries",
"URL": "https://carpentries.r-universe.dev"
},
{
"Name": "carpentries_archive",
@zkamvar
zkamvar / keybase.md
Created September 20, 2021 16:58
Keybase proof

Keybase proof

I hereby claim:

  • I am zkamvar on github.
  • I am zkamvar (https://keybase.io/zkamvar) on keybase.
  • I have a public key ASDqVco4Xm3D5M11ckLrYgE9XyqlHFxA7MwqWszJxWvmSAo

To claim this, I am signing this object:

@zkamvar
zkamvar / README.md
Last active August 18, 2020 17:32
pandoc markdown_github with section-divs booboo

This compares the differences between pandoc's markdown and markdown_github engines when parsing <div> tags within sections.

Problem

In essence, if a <div> tag contains a header out of order with the main document, its contents will be appended to the div in the html document with markdown_github. If the following div appears after a level 3 header:

<div class='boo'>

## level 2
# test file
sample_chunk <- "
```{r hello, testing=as.logical(1), another=1 + 1}
x <- 1 + 1 # this evaluates to two
```
the value of x is `r x`"
file = "sample.Rmd"
writeLines(sample_chunk, con = file)
# delete temp Rmd file
on.exit(unlink(file))
@zkamvar
zkamvar / render-demo.R
Last active August 23, 2018 13:33
Render an R demo
#!/usr/bin/env Rscript
args <- commandArgs(trailingOnly = TRUE)
if (length(args) != 2) {
msg <- "
usage:
render-demo.R <demo> <package>
This utility will render the code and figures from a given package as a PDF
and place them into a directory called `<demo>-generated_files`. This requires
knitr, rmarkdown and LaTeX to be installed on your system.
@zkamvar
zkamvar / bootstrap-genet-dist.md
Last active August 21, 2018 09:55
Generating a bootstrap dendrogram with hierfstat's genet.dist
title author date
Generating a bootstrap dendrogram with hierfstat's genet.dist
Zhian N. Kamvar
2018-08-21

This short tutorial is an answer to the question posed on the poppr forum: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/poppr/vEQ8vb2oObQ/RjTsndaCEQAJ

My ultimate goal when asking the previous question was to employ aboot in order to create a bootstraped dendrogram based on distances offered by the genet.dist function in hierfstat. That's why I was trying to create a tree based on Nei's distance this way - to verify that it worked! Unfortunately even after reading the aboot documentation, I still fail to understand how to do this. I would be grateful if someone could provide an example of using aboot in combination with genet.dist.

@zkamvar
zkamvar / guide_generator.R
Created January 5, 2018 20:13
Generate guides for making a poster in inkscape
#' Get the size of a single panel
#'
#' @param n the number of panels
#' @param len the overall length of the side
#' @param margin the outer margin width (will be multiplied by 2)
#' @param gutter the space between panels
#'
#' @return a numeric value specifying the panel width/length
#'
#' @examples
@zkamvar
zkamvar / statphi.R
Last active December 18, 2017 17:46
Get Phi statistics from amova object from either pegas or ade4
ade4phi <- function(sig){
n <- length(sig)
f <- rep(0, n - 1)
if (length(sig) == 3) {
f <- rep(0, 1)
}
f[1] <- (sig[n] - sig[n - 1]) / sig[n]
if (length(f) > 1) {
s1 <- cumsum(sig[(n - 1):2])[-1]