How to create a stacked bar chart from summarized data in ggplot2

Viewed 5352

I'm trying to create a stacked bar graph using ggplot 2. My data in its wide form, looks like this. The numbers in each cell are the frequency of responses.

activity                         yes    no  dontknow
Social events                     27    3   3
Academic skills workshops         23    5   8
Summer research                   22    7   7
Research fellowship               20    6   9
Travel grants                     18    8   7
Resume preparation                17    4   12
RAs                               14    11  8
Faculty preparation               13    8   11
Job interview skills              11    9   12
Preparation of manuscripts        10    8   14
Courses in other campuses          5    11  15
Teaching fellowships               4    14  16
TAs                                3    15  15
Access to labs in other campuses   3    11  18
Interdisciplinary research         2    11  18
Interdepartamental projects        1    12  19

I melted this table using reshape2 and

 melted.data(wide.data,id.vars=c("activity"),measure.vars=c("yes","no","dontknow"),variable.name="haveused",value.name="responses")

That's as far as I can get. I want to create a stacked bar chart with activities on the x axis, frequency of responses in the y axis, and each bar showing the distribution of the yes, nos and dontknows

I've tried

ggplot(melted.data,aes(x=activity,y=responses))+geom_bar(aes(fill=haveused))

but I'm afraid that's not the right solution

Any help is much appreciated.

1 Answers
Related