Skip to content

Instantly share code, notes, and snippets.

df <- structure(list(Quantile = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), .Label = c("P90-95",
"P95-99", "P99-99.5", "P99.5-99.9", "P99.9-99.99", "P99.99-100"
), class = "factor"), variable = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Labor Income",
"Capital Income", "Mixed Income"), class = "factor"), value = c(0.88,
0.776, 0.601, 0.478, 0.366, 0.271, 0.05, 0.082, 0.151, 0.224,
0.375, 0.579, 0.07, 0.141, 0.248, 0.298, 0.26, 0.151), Levels = c(1,
2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6)), .Names = c("Quantile",
"variable", "value", "Levels"), row.names = c(NA, -18L), class = "data.frame")
@annoporci
annoporci / currency_format.R
Last active August 29, 2015 14:12
sketch of extension of R package scales to support multi currency formatting
#' Currency formatter: round to nearest cent and display currency symbol.
#' Particular emphasis on the following currency symbols:
#' euro , pound/sterling, yen (Japan), renminbi/yuan (China).
#' French and British formatting styles (U.S. style in scales package)
#' intended for use with ggplot2 and the scales package
#'
#' Dependencies:
#' \code{require(scales)}
#' \code{require(plyr)} # function round_any
#'
# swap_grobs()
# a function to swap parts of the grobs between two very similar plot objects
# Data
df <- structure(list(Year = c(1950, 2013, 1950, 2013), Country = structure(c(1L,
1L, 2L, 2L), .Label = c("France", "United States"), class = "factor"),
Category = c("Hourly minimum wage", "Hourly minimum wage",
"Hourly minimum wage", "Hourly minimum wage"), value = c(2.14,
9.43, 3.84, 7.25), variable = c("France (2013 euros)",
"France (2013 euros)", "United States (2013 dollars)", "United States (2013 dollars)"
@annoporci
annoporci / chartTemplate.html
Last active August 29, 2015 14:01
shiny app with dimple plots and highcharts - problem formatting axes data and labels
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript">
$(document).ready(function(){
draw{{chartId}}()
});
function draw{{chartId}}(){
var opts = {{{ opts }}},
data = {{{ data }}}
var data = d3.nest()
# server.R
library("shiny")
shinyServer(
function(input, output) {
myFunction <- function(myinput)
{
# server.R
library("shiny")
shinyServer(
function(input, output) {
myFunction <- function(myinput)
{
# compute output
myoutput <- myinput*myinput
myoutput
}