Skip to content

Instantly share code, notes, and snippets.

Carl Boettiger cboettig

Block or report user

Report or block cboettig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cboettig
cboettig / db_mutate.R
Last active Feb 26, 2019
Allow dplyr::mutate with arbitrary R functions when using database backends
View db_mutate.R
#' Add new variables to a database
#'
#' [dplyr::mutate()] cannot pass arbitrary R functions over a database connection.
#' This function provides a way to work around this, by querying the data in chunks
#' and applying the function to each chunk, which is then appended back out to a
#' temporary table.
#' @param db a database connection, [DBI::DBIConnection()]
#' @param tbl the name of a table
#' @param r_fn any R function that can be called on a vector (column) of the table
#' @param col the name of the column to which the R function is applied.
View ex.json
{
"stuff": {
"buried": {
"deep": [
{
"goodstuff": "here",
"name": "Bob Rudis",
"secret_power": 5
},
{
View eml-software.xml
<?xml version="1.0" encoding="UTF-8"?>
<eml:eml xmlns:eml="eml://ecoinformatics.org/eml-2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
packageId="eml-1.2" system="knb"
xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.1/ eml.xsd">
<software>
<alternateIdentifier>eml2</alternateIdentifier>
<title>eml2: Create and Manipulate Data using the Ecological Metadata Language</title>
<creator id="http://orcid.org/0000-0002-1642-628X">
<individualName>
@cboettig
cboettig / redlist_api.R
Created Apr 7, 2018
row iteration examples
View redlist_api.R
## From DS421, iterating over multiple parameters in an API call
## pmap not necessary since we could create a single vector of urls to iterate over via mutate
library(tidyverse)
extinct = read_csv("https://espm-157.github.io/extinction-module/extinct.csv")
out <-
extinct[1:5,] %>% # use a subset for testing
pmap_df( function(Genus, Species, ...){ # ... to swallow extra rows
url <- paste0("http://api.iucnredlist.org/index/species/",
Genus, "-", Species, ".json")
View tipping-bass.Rmd
```{r}
library(ggplot2)
```
Here's the J model:
```{r}
p1 <- 1
@cboettig
cboettig / jqr.R
Last active Dec 30, 2017
schema mapping via jqr
View jqr.R
library(jqr)
eml <-
'
{
"id": "https://doi.org/10.data",
"type": "Dataset",
"coverage": {
"temporalCoverage": {
"beginDate": "2012-06-01",
@cboettig
cboettig / giithub_clone_pull.R
Created Jul 21, 2017
tidy-ish R commands to clone all repos in a user's account, pull from all local repos.
View giithub_clone_pull.R
library(gh)
library(git2r)
library(purrr)
library(dplyr)
## CHECK YOU ARE IN THE DESIRED WORKING DIRECTORY!
Sys.setenv(GITHUB_PAT="XXX")
## Clone all of the user's private repos under account "cboettig"
View keybase.md

Keybase proof

I hereby claim:

  • I am cboettig on github.
  • I am cboettig (https://keybase.io/cboettig) on keybase.
  • I have a public key ASAz0gxbUzsHhf-cDSJjzISTtSHg7sKqQnmgegw0x6Sv0wo

To claim this, I am signing this object:

View circle-github-deploy.sh
#!/bin/bash
set -e
if [ -e ".git/shallow"] then
git config user.name 'Circle CI' && \
git config user.email 'bot@circleci.com'
git fetch --unshallow
git add docs/ && \
git commit -m 'site built on circle ci [ci skip]'
You can’t perform that action at this time.