File:Contribution size.png

From mediawiki.org

Original file(792 × 612 pixels, file size: 47 KB, MIME type: image/png)

Generated using data from Oct 1 2009 - May 31 2010. Unofficial personal work, has not been peer reviewed.

"R" source:

input_file = "rawamount.txt.csv"
subtitle = "(2009 fund season)"
output_format = "ps"

dollar_range_endpoints = c(0, 30, 50, 100, 200, 1000, 1000000)
interval_labels = c("less than $30", "$30 to $50", "$50 to $100", "$100 to $200", "$200 to $1,000", "$1000 and up")
    #lab = paste(levels(dollar_range_endpoints), "\n", signif(avgs, 2)),
    # t("less than %C") t("%C to %C") t("%C and up")

data_bin <- function(data, breaks)
{
    h = hist(data,
        breaks = breaks,
        plot = FALSE
    )
    cuts = cut(data,
        breaks = h$breaks,
        include.lowest = TRUE,
        dig.lab = 10
    )
    out = {}
    out$counts = h$counts
    #out$medians =
    out$avgs = tapply(data, cuts, mean)
    out$areas = out$counts * out$avgs
    out$portions = out$areas / sum(out$areas)
    return(out)
}

start_output_capture = function(label)
{
    output_path = paste("./", label, ".", output_format, sep="")
    postscript(file = output_path)
}


data = scan(
    file = input_file,
    skip = 0,
    sep = ","
)

start_output_capture("contribution size - pie")
bins = data_bin(data, dollar_range_endpoints)
labels = gettextf(
    "%s\n (%d%% of total, mean $%0.2f)",
    interval_labels,
    round(bins$portions * 100),
    signif(bins$avgs, 4)
)
pie(
    bins$areas,
    lab = labels,
    main = paste("Relative contributions to total, by donation size", subtitle),
    col = heat.colors(length(bins$avgs))
)
dev.off()

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current07:48, 3 July 2012Thumbnail for version as of 07:48, 3 July 2012792 × 612 (47 KB)Adamw (talk | contribs)
18:04, 28 June 2012Thumbnail for version as of 18:04, 28 June 2012623 × 611 (39 KB)Adamw (talk | contribs)Generated using data from Oct 1 2009 - May 31 2010 "R": file = "rawamount.txt.csv" d=scan(file=file, skip=0, sep=",") breaks = c(0, 30, 50, 100, 200, 1000, 1000000) h=hist(d, breaks=breaks, plot=FALSE ) cs=cut(d, breaks=breaks, inclu...

There are no pages that use this file.