r - using the arrows function to add confidence limits stored in a dataframe to a barplot -


i'm sure simple problem of :) have looked around r pages , on here , know function need (arrows think) don't understand how use it. question is:

i have dataframe (data) results of experiment have simplified this:

treatment   y   lower_limit_ci  upper_limit_ci 1   0.13284413  0.1224  0.1438 2   0.263072558 0.2458  0.2809 3   0.234218546 0.217   0.2521 4   0.394980185 0.3702  0.4201 5   0.474533107 0.4457  0.5035 6   0.583333333 0.5526  0.6136 

i have drawn barplot of data so:

plot <- barplot(data$y) 

and know need function arrows (yes?) add confidence limits stored in dataframe plot.

can please show me how use arrows correct info. dataframe? have tried on advice of someone:

arrows(plot, data$y - data$lower_limit_ci,    plot, data$y + data$upper_limit_ci,    code=3, angle=90, length =0.1) 

which gives giant bars incorrect. can help?

thanks!

i suggest instead of barplot , arrows functions, use more flexible , powerful ggplot2 package. here's how ggplot, geom_bar , geom_errorbar functions can used create barchart confidence interval:

ggplot(data, aes(treatment, y, fill=1:6)) + geom_bar(position=position_dodge(), stat="identity") + geom_errorbar(aes(ymin=data$lower_limit_ci, ymax=data$upper_limit_ci), width=.2, position=position_dodge(.9)) 

the output looks this:

enter image description here


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -