# [R] bargraph.ci - CI and color question.

Michael Just mgjust at gmail.com
Wed Nov 4 05:49:43 CET 2009

```Thank you.

On Tue, Nov 3, 2009 at 3:08 PM, Manuel Morales
<Manuel.A.Morales at williams.edu> wrote:
> On Tue, 2009-11-03 at 10:20 -0600, Michael Just wrote:
>> Hello,
>>
>> Thanks for the responses.  Yes, I did try to use ?bargraph.CI for the
>> colors. When I said bars,  I meant the main bars on the graph not the
>> error bars. However, this "col=c("color", "color")" is what I was
>> needed and while it didn't find in the ?bargraph.ci help, I suspect
>> its a  more fundamental R thing that I was unaware of.  Regardless,
>> thank you for the example.
>>
>> bargraph.CI(dose, len, group = supp, data =ToothGrowth,
>> + col=c("gray","black"))
>>
>> Regarding the confidence intervals.  Yes, I am looking for the 95%
>> confidence interval of the mean.  Using the ci.fun can I get +/- 1.96
>> SD?
>>
>> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
>> ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
>>
>> I tried variations on this like,
>>
>> ci.fun= function(x) c(mean(x)-(1.96*sd(x))), mean(x) + (1.96*sd(x))) )
>
> You do +/- 1.96*se to get the approximate 95% CI of the mean. +/-
> 1.96*SD gives the 95% CI of the distribution.
>
> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun=
> function(x) c(mean(x)-1.96*se(x), mean(x)+1.96*se(x)) )
>>
>> but this didn't work.  Maybe this approach above seems silly, but I
>> hope I am exhibiting that I do indeed what the 95% CI for the mean,
>> but that I am unsure how to have the error bars reflect this using the
>> ci.fun argument.  Can I use this argument or is some pre-processing
>> necessary?  If this information is located somewhere besides the
>> ?bargraph.ci help I would greatly appreciate an indication of where it
>> is.
>>
>> Thank you kindly,
>> Michael Just
>>
>> On Tue, Nov 3, 2009 at 8:53 AM, Manuel Morales
>> <Manuel.A.Morales at williams.edu> wrote:
>> > On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
>> >> Hello,
>> >> When using bargraph.CI in package sciplot can the bars for each group
>> >> be different colors?  How do I select the color for each group?
>> >
>> > With the option err.col
>> >
>> > bargraph.CI(dose, len, group = supp, data =ToothGrowth,
>> > err.col=c("gray","black"))
>> >
>> >> When I use this instead of the default (SD vs SE):
>> >>
>> >> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
>> >>
>> >>                ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
>> >>
>> >>
>> >> Am I getting 95% CI bars?
>> >
>> > No. You're plotting +/- 1 SD.
>> >>
>> >> Thank you kindly,
>> >> Michael Just
>> >>
>> >> ______________________________________________
>> >> R-help at r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >
>> >
>> > --
>> > http://mutualism.williams.edu
>> >
>> >
>
>
> --
> http://mutualism.williams.edu
>
>

```