Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accident data

    Hello Stata community;

    I have this data:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str14 Moyen_de_Transport int(accidents Tués Blessés)
    "Voiture légére" 3406 560 4937
    "Camion léger"   1460 416 2116
    "Taxi"            593 133 1124
    "Camion lourd"    251 130  366
    "Bus"             109  32  248
    "Train"            20   8   23
    end
    It is about the number of accidents by means of transport and by injuries and deaths.
    My goal is to draw a grapgh for this data showing the number of incidents (accidents, injurues and deaths) by each mean of transport, all in the same graph.
    I'm still deciding wether it would be better to have a bar graph or a pie graph, I guess bars are easier to present and read, aren't they?

    I would love to get the code to the better graph.

    Thanks!

  • #2
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str14 Moyen_de_Transport int(accidents Tués Blessés)
    "Voiture légére" 3406 560 4937
    "Camion léger"   1460 416 2116
    "Taxi"            593 133 1124
    "Camion lourd"    251 130  366
    "Bus"             109  32  248
    "Train"            20   8   23
    end
    
    rename (accidents Tués Blessés) _freq=
    reshape long _freq, i(Moyen_de_Transport) j(which) string
    graph hbar _freq, over(Moyen_de_Transport, sort(1)) over(which, sort(1) lab(angle(vert))) ///
    blab(total) ylab("") ysc(r(0 5500)) ytitle("")
    Res.:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	19.7 KB
ID:	1744792

    Last edited by Andrew Musau; 27 Feb 2024, 11:05.

    Comment


    • #3
      Andrew Musau Thanks for the help, it worked !

      Comment

      Working...
      X