2
$\begingroup$

I have some funky data that I'd like to put into a final presentation form and I was hoping to get some creative ideas on how to do it. My data compares measurements of different lengths, so for example I have 52 week long samples of 6 different chemicals (times several duplicates), 26 2 week long samples, 12 month long samples, 4 quarterly samples, 2 semiannuals and an annual sample. I have compared the accuracy of each duration with one another for a total of 15 comparisons (week vs 2 week, week vs month, etc) to find how much one deviates from another on average by computing the % bias, where negative bias indicates that the longer of the 2 samples under-reports and positive bias indicates that the shorter of the 2 samples under-reported. So I have an average % bias and a 95% confidence interval for each of 6 chemicals for each duration comparison. My confidence intervals are of varying widths because I obviously have many fewer data points for comparisons involving annual samples. An example is given below:

Chem1
     week v biweek    week v month    week v quarter    week v semiannual    ....
low95    -10               -12              -15               -17
mean      0                  2                2                -1
high95    10                14               17                15

How might I pack this into one nice looking graphic (or color coded table, or something) that can convey the average bias for each chem and the accompanying confidence interval (maybe highlighting those with greater power?) and also for each duration comparison (ideally maintaining some visual representation of relative time lengths). I would be content having 6 graphics (one for each chemical), but I don't think I want 15 (one for each comparison). I was thinking that a color ramp would help ad an extra dimension to it, but I don't really know how to implement that in R. Any creative solutions? Help on the color-ramping? Please keep in mind that I'm working in R and I'd say my R skills are about intermediate. Thanks a ton!

$\endgroup$

migrated from stackoverflow.com Jul 2 '12 at 22:08

This question came from our site for professional and enthusiast programmers.

5
$\begingroup$

Here are some ideas

dataset <- expand.grid(Chemical = factor(1:6), Comparison = c("week vs biweek", "week vs month", "biweek vs month"))
dataset$Bias <- runif(nrow(dataset))
    dataset$Width <- rnorm(nrow(dataset), mean = 3)
dataset$LCL <- dataset$Bias - dataset$Width
    dataset$UCL <- dataset$Bias + dataset$Width
dataset$Class <- cut(dataset$Width, c(0, 4, 8))
library(ggplot2)
ggplot(dataset, aes(x = Comparison, y = Bias, ymin = LCL, ymax = UCL, colour = Chemical, size = Class)) + geom_hline(yintercept = 0, linetype = 3) + geom_errorbar(position = position_dodge(0.5)) + geom_point(position = position_dodge(0.5))
ggplot(dataset, aes(x = Comparison, y = Bias, ymin = LCL, ymax = UCL, colour = Class)) + geom_hline(yintercept = 0, linetype = 3) + geom_errorbar(position = position_dodge(0.5)) + geom_point(position = position_dodge(0.5)) + facet_wrap(~ Chemical)
$\endgroup$
  • 1
    $\begingroup$ I really like that 1st one. I've only recently been exposed to the glorious world of ggplot2. You've not only given me a place to take off from, but you've got me pumped on graphs! Thanks! PS I'll vote it up as soon as I have the rep to do so. $\endgroup$ – rnorberg Jul 3 '12 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.