Skip to content

Instantly share code, notes, and snippets.

@fmichonneau
fmichonneau / gist:9463307
Last active August 29, 2015 13:57
Code that fails only for sparc on CRAN
## code to reproduce error as seen at: http://www.r-project.org/nosvn/R.check/r-patched-solaris-sparc/phylobase-00check.html
## 2014-03-10
library(phylobase)
library(RUnit)
## create object from scratch
ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9))
descendant <- as.integer(c(7,1,2,8,3,6,9,4,5))
edge <- cbind(ancestor, descendant)
@fmichonneau
fmichonneau / install.log
Last active August 29, 2015 13:57
Error during package installation using
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/francois/phylobase.Rcheck/phylobase/libs/phylobase.so':
/home/francois/phylobase.Rcheck/phylobase/libs/phylobase.so: undefined symbol: __ubsan_vptr_type_cache
Error: loading failed
Execution halted
ERROR: loading failed
_____
@fmichonneau
fmichonneau / zissouRodent.R
Created May 12, 2014 17:35
Code to reproduce the mean weight per species using the Zissou color palette (from #datacarpentry tweet)
## Code to reproduce: https://twitter.com/FrancoisInvert/status/464493646151446528
library(wesanderson) # for the Zissou palette
library(RCurl) # needed to get data with HTTPS protocol
rodentURL <- getURL("https://raw.githubusercontent.com/NESCent/2014-05-08-datacarpentry/master/data/surveys.csv")
rodentData <- read.csv(textConnection(rodentURL))
meanPerSpecies <- aggregate(wgt ~ species, data=rodentData, mean, na.rm=TRUE)
##' 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
@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 <- "
--------------------
@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 / 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:

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 / 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
# 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)