Plotting Categorical Variable with Percentage Points Instead of Counts on Y-Axis in R (2 Examples)

  Рет қаралды 5,397

Statistics Globe

Statistics Globe

Күн бұрын

Пікірлер: 15
@dangunwangum
@dangunwangum 3 жыл бұрын
..count.. very nice. I created a similar chart but it was far more complicated. Thank you.
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Glad it was helpful! Thank you for the comment! :)
@thomascamminga1576
@thomascamminga1576 2 жыл бұрын
Thank you for the video! I was wondering how you can do something similar if you also have groups. When I applied the aes(y = (..count..)/sum(..count..)) code to a grouped barchart, it expresses the percentages of certain categories as relative to the whole sample, but I want to have the percentages of categories relative to the answers of the group. So in other words, I would like to create a graph in which I want to plot for two groups separately the mean percentages of frequencies in different categories. So similar to your graph but then with the two groups next to each other for each category. How can I best achieve this?
@cansustatisticsglobe
@cansustatisticsglobe 2 жыл бұрын
Hello Thomas, Thank you for your interest in our tutorials. Sorry for the late response. If I understood your question correctly, you could use the facet_grid() function. Please see the example below. set.seed(927456) # Creating example data data
@maxarendorff6521
@maxarendorff6521 3 жыл бұрын
Great stuff. These videos are very helpful.
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Glad you like them Max, thank you for the nice comment!
@deniseortiz8567
@deniseortiz8567 2 жыл бұрын
You are GREAT and super helpful thank you!! I'm wondering how to do this with 2 categorical variables. I have looked through multiple videos but only find count with 2 cat vars. Any help from anyone would be appreciated.
@cansustatisticsglobe
@cansustatisticsglobe 2 жыл бұрын
Hello Denise, You can use facet_grid as follows: set.seed(927456) # Creating example data data
@hyadiro123
@hyadiro123 3 жыл бұрын
Is it possible to show both bars (counts and percentage) in the same graph?
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey Santiago, yes this would be possible, but you would have to perform some data manipulation first. For instance, you could use a grouped barplot for this: statisticsglobe.com/draw-grouped-barplot-in-r Regards, Joachim
@ghaidabaothman2269
@ghaidabaothman2269 3 жыл бұрын
Thanks for the video, can you please tell me how to add percentage labels above each bar
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey Ghaida, thank you very much for the comment! You can add labels to a barplot as explained here: statisticsglobe.com/r-position-geom_text-labels-in-grouped-ggplot2-barplot Regards, Joachim
@נועהנבון-ד3ע
@נועהנבון-ד3ע 2 жыл бұрын
@@StatisticsGlobe Thanks for the video, it was very helpful. i still didnt understand how to add percentage labels above each bar. The problem is taht in this example the Y is "(..count..)/sum(..count..)" and in the link y is defined as "height" , the label's code does not work the same way
@nayeemislam8123
@nayeemislam8123 3 жыл бұрын
where did you use the scales package?
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey Nayeem, when I use percent in the last line of code.
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН
Bar Charts with {ggplot2}
13:38
yuzaR Data Science
Рет қаралды 7 М.
Factor Variables in R
9:51
Equitable Equations
Рет қаралды 18 М.
Bar Charts using ggplot geom_bar - R Lesson 16
9:11
CradleToGraveR
Рет қаралды 41 М.
R vs Python
7:07
IBM Technology
Рет қаралды 345 М.
ggplot2 Scales and Transformations - Data Communication / Data Visualization
13:37
Econometrics, Causality, and Coding with Dr. HK
Рет қаралды 3,1 М.