Skip to content

Instantly share code, notes, and snippets.

@karthik
karthik / Berkeley_job.md
Created March 22, 2013 23:22
Berkeley R position

An interdisciplinary research team at the University of California, Berkeley, seeks a programmer to build a scientific computing framework for statistical algorithms as part of a project funded by the National Science Foundation. The successful applicant will implement a Domain-Specific Language, built in R and C++, for programming hierarchical statistical models and algorithms. This position will be supervised by faculty and staff in biology (Perry de Valpine), statistics (Chris Paciorek), and computer science (Ras Bodik). Applicants must have experience implementing language and compiler components, including context-free grammars and abstract syntax trees. They must know how to use closures and tree rewriting to implement a Domain-Specific language. Applicants must have experience with object-oriented programming, C++, and R or a related functional programming language. Knowledge of numerical computational methods would be beneficial. The successful applicant will gain experience with computational s

@karthik
karthik / impact_report.R
Created March 30, 2013 00:49
Impact Story metrics via R
library(rImpactStory)
# I precreated this collection via the website
# If your impactstory key is not stored in your .rprofile, add it below with key =
metrics <- collection_metrics(collection_id = "d4npn7")
# From all the fields returned, I just need the metrics
data <- metrics[[5]]
tabular_data <- llply(data, function(x) {
# stars
stars_metrics <- data.frame(x$metrics$`github:stars`$values$github)
stars_data <- data.frame(count = x$metrics$`github:stars`$values$raw,
@karthik
karthik / gist:5355900
Created April 10, 2013 15:55
table margins
install.packages('pander')
library(pander)
table_1 <- read.csv("table_1.csv", header = TRUE)
# To generate a pandoc friendly table that respects margins, wrap at some character limit
# default is 30, use a lower number to make it fit.
pandoc.table(table_1, split.cells = 30)
@karthik
karthik / load_all
Last active December 19, 2015 01:59
Figuring out a `load_all` error in devtools.
# This is my entry for devtools in my .rprofile
options(devtools.desc.author = "Karthik Ram <[email protected]> [aut, cre]")
# However, during load_all(), it throws up the following error:
> load_all()
Loading ropensciDemos
Invalid DESCRIPTION:
Malformed Authors@R field:
<text>:1:9: unexpected symbol
This is the __holy grail__ of metadata infrastructure and ostensibly the primary purpose of EML, see [Jones et al 2006]. Despite that, integration is not actually possible without semantic definitions as well, see [Michener & Jones 2012], from which we adapt this minimal example below.
This example provides minimal and sometimes missing semantics; which may make it unresolvable. A complete semantic solution is diagrammed in the figure from [Michener & Jones 2012].
### Dataset 1
```ruby
dat = data.frame(river=c("SAC", "SAC", "AM"),
spp = c("king", "king", "ccho"),
@karthik
karthik / wordcloud.R
Created June 28, 2013 15:30
wordclouds
# First install some packages
install.packages("wordcloud")
# Next run this in R
library(wordcloud)
setwd('~/Desktop')
words <- structure(list(term = c("effect size", "review (but not systematic)",
"synthesis", "meta-anal", "summary", "integration", "nceas",
@karthik
karthik / julie_L.R
Created July 10, 2013 00:01
Julie's R question
# Example for Julie
# So I read the data in through the script because you didn't give me a file.
# If you did, all this would be one line.
# example:
# df <- read.csv("julies_data.csv", header = T)
# Function reads your csv into an object called df. I also noted that it has a header row.
df <- read.table(textConnection("
Student Question Response_Option Answer_Match
@karthik
karthik / web_data.R
Created August 2, 2013 20:27
testin 3 APIs
# Acquiring data from the web
# combining 3 APIs
library(rgbif)
library(taxize)
library(rfisheries)
# rfisheries
# list of species
@karthik
karthik / test.R
Created September 18, 2013 13:54
```{r, echo = FALSE}
head(iris[, 1:3])
```
```{r echo = FALSE}
install.packages("ggplot2")
library(ggplot2)
```

Notes:

  • I've tried to break up in to separate pieces, but it's not always possible: e.g. knowledge of data structures and subsetting are tidy intertwined.

  • Level of Bloom's taxonomy listed in square brackets, e.g. http://bit.ly/15gqPEx. Few categories currently assess components higher in the taxonomy.

Programming R curriculum

Data structures