Skip to content

Instantly share code, notes, and snippets.

View hemprichbennett's full-sized avatar

Dave Hemprich-Bennett hemprichbennett

View GitHub Profile
@hemprichbennett
hemprichbennett / networklevel_apply.R
Last active March 25, 2022 13:31
Quickly calculating network metrics in bipartite
library(bipartite)
# make some example networks
mat_list <- list()
for(i in 1:512){
mat_list[[i]] <- matrix(ncol = 10, nrow = 10,
sample(c(0,1), 100, replace = T))
}
# now do all the calculations at once (depending on your computers ability)
@hemprichbennett
hemprichbennett / SE_asian_bat_species.R
Last active October 3, 2019 15:36
Get the species names of all GBIF records from Malaysia, Indonesia and Brunei
#### Header ####
## Project: NA
## Script purpose: Get all the species of bats with GBIF records from Malaysia,
## Indonesia and Brunei
## Date:
## Author: Dave Hemprich-Bennett (hemprich.bennett@gmail.com)
## Notes
##################################################
# Code repurposed from the fantastic lesson at https://ourcodingclub.github.io/2016/01/01/data-synthesis.html
@hemprichbennett
hemprichbennett / google_docs_backup.R
Created August 5, 2019 13:50
Backs up all documents in your google docs folder to a local directory
library(googledrive)
library(dplyr)
# Make a directory for todays date
date <- as.character(Sys.Date())
# Set the location for where the docs should be saved
outdir <- paste0("~/Dropbox/work/google_docs_backups/", date)
if (!dir.exists(outdir)) {
@hemprichbennett
hemprichbennett / twitter_bot.R
Last active April 9, 2018 10:10 — forked from noamross/get_bat_wiki_pages.R
This script mines a wikipedia page for bat facts and (if they meet a basic QC) tweets them out. Then it waits 3 hours, before doing it again
##Wikipedia querying from Noam Ross https://gist.github.com/noamross/88a51bb880f18da88e4b259eefdefe87
library(tidyverse)
library(xml2)
library(rvest)
library(WikipediR)
library(urltools)
library(stringr)