knitr::opts_chunk$set(echo = TRUE)

This package holds functions I wrote or collected that are useful for myself.

You can install it with devtools::install_github("daijiang/dli55"), but you will likely get compile errors. I have also iploaded a binary version, which you can install with install.packages("https://raw.githubusercontent.com/daijiang/dli55/master/dli55_1.0.1.tgz", repos = NULL).

PCD

Adopted from the picante R package, wrote by Ives and Helmus 2010.

library(dli55)
x1.c = pcd_pred(comm_old = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
              comm_new = read.csv("data/li_2015_new.csv", row.names = 1, check.names = F),
                  tree = ape::read.tree("data/phy.tre"), reps = 100)
x1.r = pcd_pred(comm_old = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
                comm_new = read.csv("data/li_2015_new.csv", row.names = 1, check.names = F),
                tree = ape::read.tree("data/phy.tre"), reps = 100, cpp = F)
x1.c; x1.r

library(microbenchmark)
microbenchmark(pcd_pred(comm_old = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
                        comm_new = read.csv("data/li_2015_new.csv", row.names = 1, check.names = F),
                        tree = ape::read.tree("data/phy.tre"), reps = 100, cpp = FALSE),
               pcd_pred(comm_old = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
                        comm_new = read.csv("data/li_2015_new.csv", row.names = 1, check.names = F),
                        tree = ape::read.tree("data/phy.tre"), reps = 100, cpp = TRUE),
               times = 20)
microbenchmark(pcd2(comm = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
                    tree = ape::read.tree("data/phy.tre"), 
                    expectation = x1.c, cpp = F),
               pcd2(comm = read.csv("data/li_2015_old.csv", row.names = 1, check.names = F),
                    tree = ape::read.tree("data/phy.tre"), 
                    expectation = x1.c, cpp = T),
               times = 20)


daijiang/dli55 documentation built on Jan. 9, 2020, 3:30 p.m.