I'm have a sample of data of newborn siblings weight and sex, and want to plot them on a common 2x2 dot plot in R looking like the following done in Stata: 2x2 plot of birthweight of first compared to second child
The stata code is this
egen sex1sex2=group(sex1st sex2nd),label
scatter weight2nd weight1st,by(sex1sex2) aspect(1) scheme(s1mono)
The structure of the data in R is this:
> str(siblings)
'data.frame': 1000 obs. of 5 variables:
$ sex1st : int 1 1 1 2 1 1 2 1 2 2 ...
$ sex2nd : int 1 2 1 2 2 2 1 2 2 1 ...
$ weight1st: int 3740 3060 3650 3688 3740 3550 3850 3680 2390 3600 ...
$ weight2nd: int 3740 3620 3700 3726 3000 3700 4020 4310 2250 3250 ...
$ difw : int 0 560 50 38 -740 150 170 630 -140 -350 ...
Only 1:4 needs to be taken into account. In sex, the 1=boy and 2=girl. In the original .dta file they are labeled. Thanks so much for any help.
