| Method 1 | Method 2 | Method 3 | Method 3 | Method 5 |
|---|---|---|---|---|
| 1 | 4 | 2 | 3 | 10 |
| 2 | 8 | 2 | 4 | 0 |
| 3 | 8 | 2 | 5 | 9 |
| 4 | 0 | 4 | 6 | 5 |
| 6 | 10 | 8 | 7 | 6 |
| 5 | 9 | 0 | 9 | 2 |
| 3 | 1 | 0 | 3 | |
| 10 | 4 | 2 | 9 | 5 |
| 4 | 3 | 0 | 1 | 4 |
| 4 | 4 | 7 | 6 | 3 |
I am trying to plot a stacked bar graph with percentages for each level.
I provided an example dataset above that looks like the dataset I have right now.
I am trying to plot responses to each method on an 11-point point scoring scale. the dataset used for my code is pain similar to the one above.
The code i managed to get what I have is :
head(pain)
pain[1:5] <- lapply(pain[1:5], factor, levels= c('0', '1', '2', '3', '4', '5', '6', '7','8', '9', '10'))
pain <- as.data.frame(pain)
painlikert <- likert(pain)
painlikerts <- likert(summary = painlikert$results)
title <- "Pain on Pain Scale"
plyr::ddply
plot(painlikerts,include.center=FALSE, colors =c("dodgerblue", "mediumseagreen", "springgreen4","olivedrab", "darkgoldenrod1", "orange", "darkorange", "darkorange2", "orangered2", "red1", "darkred" )) + ggtitle(title) + ggeasy::easy_center_title() + guides(fill = guide_legend(title = NULL))
I get a graph that is similar to this. Note there are some missing values that I want to get rid off and not all the levels are in my dataset (say 0-10). I was wondering if i could use the ggplot package as opposed to likert since I find it hard to include percentages.
I basically wanted a stacked barplot for each method with percentages of each level.