Advertisement

10.08.2008 at 08:57AM PDT, ID: 23797856
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Plot means with confidence intervals by groups in R

Asked by justearth in Probability & Statistics, Math & Science, Microsoft Excel Spreadsheet Software

Hello,
I am trying to plot a graph that uses the mean instead of a density/count on the Y-axis. I of course want to use groups and I would like to also include error bars (standard deviation). I found this code below. My data is in a different format.

Q1: How can I select data that has 'scape' = 2 and 'Pri_No' = 1 or 2.
Q2: Plot this selection for one of the other variable i.e. bbED
So this plot would have the mean bbED from scape=2 and the groups to be plotted would be Pri_No = 1 & 2.

I have also considered using:
bargraph.CI  (http://mutualism.williams.edu/sciplot/)
or barp function in the plotrix package

Thanks,
justearth
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
# ------- bar plot for STD, 95%CI and SEM ------
 
 
a <- c(25, 30, 34, 38, 43, 43, 46, 46, 49, 49, 52, 52, 55, 55, 58, 58, 62, 64,
66, 75)
b <- c(5, 5, 35, 44, 44, 47, 51, 55, 55, 58, 58, 62, 64, 64, 67, 67, 71, 74,
79, 85)
 
 
   ## Convert data vectors to dataframes
   adf <- data.frame(Group = " Group A ", Measure = a)
   bdf <- data.frame(Group = " Group B ", Measure = b)
 
   ## Combine into a dataframe using rbind
   abData <- rbind(adf, bdf)
 
attach(abData)
 
tmp = split(Measure, Group)
 
means = sapply(tmp, mean)
medians = sapply(tmp, median)
 
stdev = sapply(tmp, sd)
 
# to calculate SE
require(sciplot)
se = sapply(tmp, se)
 
n     <- sapply(tmp, length)
ciw   <- qt(0.975, n) * stdev / sqrt(n)
 
# to make the 3 graphs in one row...
# however they actually don't look nice :-(
# maybe by controlling the "ylim" part things get better
par(mfrow=c(1,3))
 
# typeface set to Serif (or Times)
par(family="serif")
 
# ----- bar plot with SD
require(gplots)
plotCI(barcol="blue", pch=16, col="blue", barplot(means, col=c("white",
"gray90"),
      ylim=c(0,max(means + stdev)), xlab = "Error bars: ±1SD", ylab="Measure")
       , means, stdev,
      add=TRUE)
 
# --------- bar plot with 95%CI
 
plotCI(barcol="red", pch=16, col="red", barplot(means, col=c("white", "grey90"),
      ylim=c(0,max(means + ciw)), xlab = "Error bars: 95% CI", ylab="Measure"),
means, uiw=ciw,
        add=TRUE)
Attachments:
 
Spreadsheet with values to create plots
 
[+][-]10.08.2008 at 09:49AM PDT, ID: 22670771

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.08.2008 at 10:20AM PDT, ID: 22671032

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 02:04AM PDT, ID: 22676604

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Probability & Statistics, Math & Science, Microsoft Excel Spreadsheet Software
Sign Up Now!
Solution Provided By: oheil
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.09.2008 at 02:07AM PDT, ID: 22676617

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628