-
-
Save anonymous/333f4a42fa4af5d77b92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
sysuse auto | |
set more off | |
set autotabgraph on | |
drop if rep78==. | |
bysort foreign: gen count=_N | |
gen freq=count/_N | |
preserve | |
collapse (mean) price count freq rep78, by(foreign) | |
twoway bar price foreign, barwidth(0.5) xlabel(-0.5 " " 0 1 1.5 " " , noticks valuelabel) /// | |
|| scatter price foreign, ms(none) mlabel(count) mlabpos(12) legend(off) ytitle("Average price of car", margin(right)) /// | |
caption("Note: The number of observations in each car type is shown on top of each bar", size(vsmall) margin(top)) /// | |
ylabel(6000(50)6200) name(gr1, replace) | |
twoway bar freq foreign, barwidth(0.5) base(0) xlabel(-0.5 " " 0 1 1.5 " " , noticks valuelabel) /// | |
|| scatter freq foreign, ms(none) mlabel(rep78) mlabpos(12) legend(off) ytitle("Frequency of car type", margin(right)) ylabel(0(0.2)0.8) /// | |
caption("Note: Average number of repairs (in 1978) for each car type is shown on top of each bar", size(vsmall) margin(top)) /// | |
name(gr2, replace) | |
restore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment