Population pyramid chart with geom_bar() | Professional dataviz with ggplot2 | R

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 10

  • @ProfBoggs
    @ProfBoggs 3 ปีที่แล้ว +2

    Thank you for posting a technique that divides the number of males in a cohort by TOTAL population, and number of females in a cohort by TOTAL population. I have seen numerous webpages and TH-cam videos who divide male or female cohort by the total male or female population.
    Also, thank you for this coding demonstration. This is exactly what I needed.

  • @joshuadelabruere4262
    @joshuadelabruere4262 4 ปีที่แล้ว +4

    FYI the gather() and spread() from dplyr have been depreciated. Use pivot_longer() and pivot_wider() as these can accomplish the same result, with clearer syntax.

    • @sergiocosta6151
      @sergiocosta6151  4 ปีที่แล้ว +1

      Thanks for the contribution, i accepted your pull request on github.

  • @sandralissete9009
    @sandralissete9009 11 หลายเดือนก่อน

    Hola ami me sale error en scale_fill_manual(name='',values=c('darkred','steelblue'))+ .... Error in `palette()`:
    ! Insufficient values in manual scale. 10 needed but only 2 provided.

  • @jasonrobin7306
    @jasonrobin7306 4 ปีที่แล้ว +1

    I don't understand how the url link works.

  • @Lala-eh7mr
    @Lala-eh7mr 2 ปีที่แล้ว

    how could the propec scale becomes minus 2.5 till positiive 2.5 , i mean it supposed to be percentages so it couldnt be negative, is the propec for male supposed to be *minus 100? ( i asked) because i literally copy your syntax but my plot turned to be basic stack bar plot

    • @sergiocosta6151
      @sergiocosta6151  2 ปีที่แล้ว

      I I mentioned this error in the description of the video and I made available the code that corrects the negative values ​​in the scale. Check te code on my github github.com/sergiocostafh/ggplot2_dataviz/blob/master/Population%20pyramid%20chart%20with%20geom_bar().R

  • @maksim0933
    @maksim0933 4 ปีที่แล้ว +1

    Very nice code! Thanks! However, generally accepted for females - on right, males - on left. But this may vary in different scientific societies.

    • @ProfBoggs
      @ProfBoggs 3 ปีที่แล้ว

      You are correct. At least in English-language demography publications, males are on the left and females are on the right.

    • @mubangansofu7469
      @mubangansofu7469 2 ปีที่แล้ว

      Fantastic video.. please note tidyverse contains ggplot2 library so loading tidyverse is enough.