Download and install:
- R
- RStudio
Download the dummy csv file from this gist ( https://gist.github.com/psychemedia/9690079 )
In RStudio run:
install.packages("shiny")
Download and install:
Download the dummy csv file from this gist ( https://gist.github.com/psychemedia/9690079 )
In RStudio run:
install.packages("shiny")
example.md: example.Rmd | |
./knit | |
example.ipynb: example.md | |
notedown example.md | sed 's/%%r/%%R/' > example.ipynb |
#' Simplified loading and installing of packages | |
#' | |
#' This is a wrapper to \code{\link{require}} and \code{\link{install.packages}}. | |
#' Specifically, this will first try to load the package(s) and if not found | |
#' it will install then load the packages. Additionally, if the | |
#' \code{update=TRUE} parameter is specified it will check the currently | |
#' installed package version with what is available on CRAN (or mirror) and | |
#' install the newer version. | |
#' | |
#' @param pkgs a character vector with the names of the packages to load. |
Country | Alpha-2 code | Alpha-3 code | Numeric code | Latitude (average) | Longitude (average) | |
---|---|---|---|---|---|---|
Afghanistan | AF | AFG | 4 | 33 | 65 | |
Åland Islands | AX | ALA | 248 | 60.116667 | 19.9 | |
Albania | AL | ALB | 8 | 41 | 20 | |
Algeria | DZ | DZA | 12 | 28 | 3 | |
American Samoa | AS | ASM | 16 | -14.3333 | -170 | |
Andorra | AD | AND | 20 | 42.5 | 1.6 | |
Angola | AO | AGO | 24 | -12.5 | 18.5 | |
Anguilla | AI | AIA | 660 | 18.25 | -63.1667 | |
Antarctica | AQ | ATA | 10 | -90 | 0 |
set.seed(12345) | |
dat <- data.frame(category=rep(c("Food", "Drinks"),20), | |
product=rep(c("Cheese", "Wine", "Bread", "Beer"), 10), | |
year=sort(rep(c(2004:2013),4)), | |
value=sort(rnorm(40))) | |
dat <- dat[with(dat, order(category, year)),] | |
library(lattice) | |
# Change some of the default lattice settings |
This gist consists of a makefile
and a script
that can automate the creation of PDFs from Slidify generated HTML slides. The script assumes that the makefile
and the script makepdf.js
are in the same directory as the Rmd
file. The makepdf.js
script uses casperjs, a very useful utility to automate tasks that require browser interaction. You may follow the installation instructions on the casperjs website, to make sure that you have all the dependencies correctly installed before trying this out.
require(quantmod) | |
prepare.indicator = function(close, indicator, roc.n, normalize=FALSE, func=mean) { | |
rets = ROC(close, type="discrete", n=roc.n) | |
if(normalize) { | |
# Normalize the returns to daily | |
rets = ((1 + rets) ^ (1/roc.n)) - 1 | |
} | |
require(shiny); | |
require(caret); | |
require(e1071); | |
require(randomForest); | |
require(nnet); | |
require(glmnet); | |
#code for plotting nnets, taken from: http://beckmw.wordpress.com/2013/03/04/visualizing-neural-networks-from-the-nnet-package/ | |
# the formula of the output of train is off and doesn't work correctly though. | |
#Function for plotting nnets, not working right now |
This is a short demo of how to use brew
and knitr
in combination with each other to get the best of the templating facilities in brew
and the literate programming functions in knitr
. The main idea is to write a function brew_knit
# Preprocess template using brew and then run knit on the output
brew_knit <- function(template, params, ...){
brew::brew(template, envir = list2env(params))
input = gsub(".Rnwe", '.Rnw', template)
knitr::knit(input)
}
library(ggplot) | |
nosql.df <- read.csv("nosql.csv", header=TRUE) | |
nosql.df$Database <- factor(nosql.df$Database, | |
levels=c("MongoDB","Cassandra","Redis","HBase","CouchDB", | |
"Neo4j","Riak","MarkLogic","Couchbase","DynamoDB")) | |
gg <- ggplot(data=nosql.df, aes(x=Quarter, y=Index)) | |
gg <- gg + geom_point(aes(color=Quarter), size=3) | |
gg <- gg + facet_grid(Database~.) |