This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(PerformanceAnalytics) | |
require(xtsExtra) #if you get error, please install xtsExtra from r-forge as shown in the top line | |
require(RColorBrewer) | |
#function add alpha or transparency to colors | |
addalpha <- function(cols,alpha=180) { | |
rgbcomp <- col2rgb(cols) | |
rgbcomp[4] <- alpha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#plot.xts with horizons | |
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(PerformanceAnalytics) | |
require(quantmod) | |
require(xtsExtra) #if you get error, install xtsExtra from r-forge | |
horizon.panel <- function(index,x,...) { | |
#get some decent colors from RColorBrewer | |
#we will use colors on the edges so 2:4 for red and 7:9 for blue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
require(quantmod) | |
require(rugarch) | |
require(xtsExtra) #if you get an error, see first line and install from r-forge | |
getSymbols("DEXJPUS",src="FRED") | |
DEXJPUS<-1/to.weekly(DEXJPUS) | |
ugarch.panel <- function(index,x,type,cex,col,pch,...){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple approach to visually-weighted regression plots | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2", "reshape2", "MASS") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some data: | |
nn <- 1000 | |
myData <- data.frame(X = rnorm(nn), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replicating / improving http://shaheeilyas.com/flags/ | |
# Drawing a scatter plot of raster images | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("png", "reshape", "ggplot2", "MASS") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Go to https://www.gosquared.com/resources/2400-flags, download the ZIP, | |
# and put the 64 x 64 files into a directory of your choosing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("foreign", "ggplot2", "devtools") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
source_gist("https://gist.github.com/818983") | |
source_gist("https://gist.github.com/818986") | |
source_gist("https://gist.github.com/818998") | |
# Get NOMINATE data from voteview.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Markdown example with knitr and googleVis | |
=========================================== | |
This is a little Markdown example file. | |
Set the googleVis options first. | |
In this case change the behaviour of plot.gvis | |
```{r setOptions, message=FALSE} | |
library(googleVis) | |
op <- options(gvis.plot.tag='chart') | |
``` | |
The following plot statements will automatically return the HTML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleVis) ## Version >= 0.3.2 required | |
library(knitr) | |
library(markdown) | |
library(RCurl) | |
## URL to the Markdown example file on github:gist | |
gist <- "https://raw.github.com/gist/3968910/4633a98fdc5193eb7da156059d182e61ccbfd4a8/MarkdownExampleWithGoogleVis.Rmd" | |
knitrRmd <- paste(readLines(textConnection(getURL(gist))), collapse="\n") | |
## Write the content of knitrRmd into a Rmd-file, knit it and convert it | |
## into a html output. Finally show the file with the R-help http |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ReadImages", "reshape", "ggplot2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Image URL: | |
allImageURLs <- c("http://media.charlesleifer.com/blog/photos/thumbnails/akira_940x700.jpg", | |
"http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg", | |
"http://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Official_portrait_of_Barack_Obama.jpg/441px-Official_portrait_of_Barack_Obama.jpg", | |
"http://cache.boston.com/universal/site_graphics/blogs/bigpicture/obama_11_05/obama22_16604051.jpg", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("jpeg", "reshape2", "ggplot2") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Image URL: | |
allImageURLs <- c("http://media.charlesleifer.com/blog/photos/thumbnails/akira_940x700.jpg", | |
"http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg", | |
"http://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Official_portrait_of_Barack_Obama.jpg/441px-Official_portrait_of_Barack_Obama.jpg", | |
"http://cache.boston.com/universal/site_graphics/blogs/bigpicture/obama_11_05/obama22_16604051.jpg", |