Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fmichonneau
fmichonneau / carpentries-workshops-through-time.R
Created October 13, 2020 14:43
Create animated map of all Carpentries workshops through time
library(jsonlite)
library(tidyverse)
library(maps)
library(gganimate)
library(countrycode)
workshop_data <- jsonlite::fromJSON(
"https://feeds.carpentries.org/all_workshops.json"
)

I'm a regular list

  1. first
  2. second
  3. third

I'm a modified list

{:start="10"}

  1. tenth
library(tidyverse)
library(maps)
library(gganimate)
library(countrycode)
wkshp_data <- read_csv("https://data.softwarecarpentry.org/api/queries/118/results.csv?api_key=GR8itg5dtYtq1A1Myv8bR5rrDNMZRlGc4cMVSnfB") %>%
filter(start_date < "2019-07-01")
wkshp_data <- wkshp_data %>%
# Resolving this: http://stackoverflow.com/questions/32035865/r-remove-rows-from-a-data-frame-that-contain-a-duplicate-of-either-combination-o
# using dplyr
Var1 <- c(1,2,3,4,5,5)
Var2 <- c(4,3,2,1,5,5)
f <- c("blue","green","yellow","red","orange2","grey")
g <- c("blue","green","yellow","red","orange1","grey")
testdata <- data.frame(Var1,Var2,f,g)
library(dplyr)
@fmichonneau
fmichonneau / tt.nex
Created November 2, 2015 21:55
Bug in read.annotated.nexus
#NEXUS
Begin taxa;
Dimensions ntax=39;
Taxlabels
N0292
N0293
NA
S0187
S0432
tab <- data.frame(a = letters[1:4], b = 1:4, c = letters[5:8], d = 5:8,
stringsAsFactors = FALSE)
last_row <- apply(tab, 2, function(x) {
res <- as.numeric(x)
if (any(is.na(res)))
""
else sum(res)
})
@fmichonneau
fmichonneau / keybase.md
Created April 5, 2015 00:15
keybase.md

Keybase proof

I hereby claim:

  • I am fmichonneau on github.
  • I am fmic (https://keybase.io/fmic) on keybase.
  • I have a public key whose fingerprint is B006 8A5E 65F6 09AD 0ED3 F312 F880 00E1 0E83 70CF

To claim this, I am signing this object:

@fmichonneau
fmichonneau / gist:cd987db756a27c6bda67
Created November 30, 2014 23:47
UBSAN + valgrind -- rncl output
==15073== Memcheck, a memory error detector
==15073== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15073== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==15073== Command: /usr/local/lib64/R/bin/exec/R -f test-all.R --restore --save --no-readline --vanilla
==15073==
R Under development (unstable) (2014-11-29 r67076) -- "Unsuffered Consequences"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
@fmichonneau
fmichonneau / RSC_applicants.R
Last active August 29, 2015 14:07
RSC applicants template
library(whisker)
library(knitr)
responses <- read.csv(file="applicants.csv", stringsAsFactors=FALSE)
names(responses)[ncol(responses)] <- "attendance"
responses_lst <- apply(responses, 1, function(x) as.list(x))
template <- "
--------------------
##' Converts a tree created by RAxML so that the bootstrap values are
##' assigned to nodes instead of edges.
##'
##' By default, (and rightly so), RAxML returns the bootstrap values
##' on an unrooted tree assigned to the edges. Most often, users want
##' the bootstrap values assigned to nodes instead. This function uses
##' a little regular expression to assign the boostrap values to the
##' nodes. It might not always work, use with caution.
##' @title Convert RAxML edge labels bootstrap values to node labels
##' @param f the tree file generated by RAxML