I am trying to make a bar plot displaying the male/female ratio of respondents of my survey. Assuming that qual$Q1.4 is a column of the dataframe containing factors (either male of female), I have the following code:
qual %>%
compute_tabulate(~Q1.4) %>%
ggvis(x = ~x_, y = ~count_/sum(count_), fill = ~x_) %>%
layer_bars() %>%
add_axis("x", title = "Gender") %>%
add_axis("y", title = "Percentage", format = "%")
This works well but both bars have 100%. If I remove the fill attribute, then my bars have the correct height but are not colored.
Any idea why the y axis stops working correctly when I put a variable fill property?
The data looks like that: data sample
The output of the code above looks like that: output
dput()your data instead of posting pictures, and preferably more than one column sincecompute_tabulateonly works withdata.frame's - mtoto