I only have basic skills with R and concerning the subject line I have tried the following approach: I have a huge data-set (Data_IlA) from which I want to analyze one variable (LMXnofive) through a bar chart. However, I want to analyze all observations based on their group-belonging (G1_ID) and also want to give the percentage of particular answers given (the scale is from 0 to 7). Hence, I created a df:
Data_IlA %>%
select(LMXnofive, G1_ID) %>%
na.omit -> data_items
data_items %>%
gather(key = items, value = answer) %>%
mutate(answer = factor(answer)) %>%
ggplot(aes(x = items)) +
geom_bar(aes(fill = answer), position = "fill") + coord_flip()
I am not exactly sure how to go about assigning the values in LMXnofive to the different groups from G1_ID (1 to 6) in order to have one bar for each group with different colours for the different percentages depending on the answers/ values in each group. The graph I get with the calculation above is the following
Every help is much appreciated, thank you.