Skip to content

Instantly share code, notes, and snippets.

@karthik
karthik / ant_web_example.R
Created February 4, 2014 22:37
An example of how to write web queries to AntWeb
# We'll use the httr library to make web calls
library(httr)
library(rjson) # to parse the json
library(plyr) # to convert lists to data.frames
library(assertthat) # To make assertions for right inputs
# If you don't have these packages run:
# install.packages(c("httr", "plyr", "rjson", "assertthat"))
@karthik
karthik / package_install.R
Created February 7, 2014 17:31
Checking package installation
if(!require(testthat)) {
install.package("testthat")
}
library(testthat)
# If you're going to require dplyr it would make sense to have students be on at least version 3.
expect_equal(R.version$major, "3")
package_list <- installed.packages (fields = c ("Package", "Version"))
# Next check to see that people have at least the major versions of key packages
@karthik
karthik / dplyr_issues.md
Last active August 29, 2015 13:56
My issues with dplyr failing intermittently (esp when examples are allowed to run).

CRAN maintainers now require that examples not be boxed in by the \dontrun{ tags. Since most of rOpenSci's packages retrieve data from the web, this can be problematic, especially if the API requires a key. But in cases where a key isn't required, I'm fine with allowing the examples to run.

When I use dplyr::rbind_all(list_name) over do.call(rbind, list_name) to combine data.frames, I get this issue when running a devtools::check().

> ### ** Examples
> 
> data_by_code <- aw_code(code = "casent0104669")
Warning in rbind_all(image_data) :
  Unequal factor levels: coercing to character
@karthik
karthik / packages.md
Created February 12, 2014 21:12
List of rOpenSci packages

List of packages we need on rOpenSci's new Rstudio Server


Please add to list as needed

  • rgbif
  • ggplot2
  • plyr
  • dplyr
@karthik
karthik / rodents_summary.csv
Created February 24, 2014 20:56
rodents_csv
State year Counts
1 OR 1953 8
2 NV 1965 16
3 OR 1961 64
4 CA 1964 112
5 OK 1962 8
6 OK 1963 8
7 NE 1962 136
8 NV 1962 1432
9 OR 1963 12976
@karthik
karthik / ecoengine_rodentia.r
Last active August 29, 2015 13:56
rMaps test
setwd("~/Desktop")
library(ecoengine)
library(plyr)
library(lubridate)
library(dplyr)
# rMaps is not available on CRAN yet.
# Install from here: https://github.com/ropensci/rmaps#installation
library(rMaps)
# I do not recommend running the next code block unless you have 20+ minutes to spare.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@karthik
karthik / ecoengine_large_requests.md
Last active August 29, 2015 13:57
How to make large requests to the ecoengine

Here are two ways to combine data from large requests to ecoengine

Method 1 (trivial)

library(ecoengine)
library(plyr)
@karthik
karthik / contributions.r
Last active August 29, 2015 13:57
more_gitr_functions.R
# Since these aren't in the package yet, first run
library(scales)
library(ggplot2)
library(dplyr)
library(wordcloud)
library(git2r)
# devtools::install_github("ropensci/git2r")
@karthik
karthik / 00install.out
Created March 19, 2014 23:00
check_fail
* installing *source* package 'git2r' ...
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed