I am using R version 3.5.1.
I started with this problem, and used the code suggested by the top comment on my own dataset, where time_len
is a categorical variable telling how long it takes to play game i, with values of short, medium, and long; num_fans
is a numeric variable telling how many fans game i has:
ggplot(cdata) +
aes(x = time_len, y = num_fans) +
geom_bar(stat = "identity")
Here is the plot:
I created the bar chart using the code above, but the problem is that the num_fans
variable looks like it is a total. I want it to show the average for each category.
EDIT: here is a sample of my data.
game_id min_players single_player max_players family_game avg_time time_len year life avg_rating
1 161936 2 multi 4 family 60 short 2015 4 8.65105
2 187645 2 multi 4 family 240 long 2016 3 8.45420
3 12333 2 multi 2 small 180 long 2005 14 8.32843
4 193738 2 multi 4 family 150 medium 2016 3 8.28646
5 162886 1 single 4 family 120 medium 2017 2 8.39401
6 84876 2 multi 4 family 90 medium 2011 8 8.12803
geek_rating rating age owned num_fans
1 8.49375 8.572400 13 47498 2168
2 8.16391 8.309055 14 23989 1594
3 8.18051 8.254470 13 45955 3639
4 8.07144 8.178950 12 21513 835
5 7.96162 8.177815 13 13743 1002
6 8.01120 8.069615 12 49353 1866
Again, I am only asking about time_len. Is there a way to show the average of num_fans
?