I am trying to graph qualitative policy analysis data in R. My database has one row for each policy, and then columns for binary variables, conditions that are coded "1" if that condition is met. Finally, each row also contains a column for whether that policy is mandatory, voluntary, or partial.
I want to create a bar chart that sums the columns, then colors in the bars according to what percentage of the sum is Mandatory, Voluntary, or Partial.
The ideal outcome would be to create a bar chart like the one below, but coded by color according to the ratio of Mandatory, Voluntary, or Partial policies
Here is some sample data in the same format:
df<- data.frame(ID=c(1,2,3,4,5,6),
policy=c("Policy A", "Policy B", "Policy C", "Policy D",
"Policy E","Policy F" ),
Data_collection= c(1, 0, 0, 1, 1, 0),
Handling_release= c(0, 1, 0, 1, 0, 1),
Gear_modification= c(1, 0, 0, 1, 1, 0),
Stength=c("M", "V", "M", "P", "P", "M"),
stringsAsFactors=FALSE)