[R] svytable: How do i create a table informing a third variable?
Juan Ceccarelli Arias
jfca283 at gmail.com
Sun Sep 4 03:23:48 CEST 2016
Your help was everything i needed it.
Please, declare this topic as solved.
And thanks again.
On Sat, Sep 3, 2016 at 10:06 PM, David Winsemius <dwinsemius at comcast.net>
wrote:
>
> > On Sep 2, 2016, at 6:08 PM, Juan Ceccarelli Arias <jfca283 at gmail.com>
> wrote:
> >
> > Thanks a lot. Your code does the trick.
> > One last question:
> > The tabulate produced is showing every cross in just one column.
> > I mean, it presents the region by order and sex=1, and then again the
> > region but by sex==2.
> > Can i list or present as this:
> > sex1 sex2
> > region1 323. 3434..
> > ...
> > regionN 123.. 432..
> >
> > and ignoring the remaining info (standar errors or se in this case)?
> > Again, thanks Anthony. Really.
> >
> (Anthony's probably asleep.)
>
> This doesn't ignore the se's but that could be easily done by omitting
> that column from the data argument:
>
> From the examples on the help page for svymean:
>
> > svyby( ~ mobility , ~ stype + comp.imp , dclus1 , svymean )
> stype comp.imp mobility se
> E.No E No 19.71875 1.347583
> H.No H No 13.14286 0.740017
> M.No M No 14.81818 2.960618
> E.Yes E Yes 17.28571 1.536158
> H.Yes H Yes 35.14286 16.570001
> M.Yes M Yes 13.71429 2.628573
>
> apimeans1 <- svyby( ~ mobility , ~ stype + comp.imp , dclus1 , svymean )
>
> > reshape(apimeans1, idvar='stype', direction="wide", timevar="comp.imp")
> stype mobility.No se.No mobility.Yes se.Yes
> E.No E 19.71875 1.347583 17.28571 1.536158
> H.No H 13.14286 0.740017 35.14286 16.570001
> M.No M 14.81818 2.960618 13.71429 2.628573
>
> --
> David.
>
> >
> >
> >
> >
> > On Fri, Sep 2, 2016 at 8:24 PM, Anthony Damico <ajdamico at gmail.com>
> wrote:
> >
> >> # mean
> >> svymean( ~ income_variable , NN )
> >> svyby( ~ income_variable , ~ age + sex , NN , svymean )
> >>
> >> # median
> >> svyquantile( ~ income_variable , NN )
> >> svyby( ~ income_variable , ~ age + sex , NN , svyquantile , 0.5 )
> >>
> >>
> >>
> >>
> >> On Fri, Sep 2, 2016 at 3:04 PM, Juan Ceccarelli Arias <
> jfca283 at gmail.com>
> >> wrote:
> >>
> >>> Hello
> >>> Im analyzing a survey and i need to obtain some statistics per groups.
> >>> Im able to create a table with sex and age. However, if i want to know
> how
> >>> much income earns the population by sex and age, i can't.
> >>> Im loading the dataset as describe the line below
> >>> NN <- svydesign(ids = ~1, data = encuesta, weights = fact)
> >>> Some simple table i can create
> >>> table(svytable(~age+sex,design=NN))
> >>> But im not able to handle the same tabulate referencing a income
> variable,
> >>> in this case, wage.
> >>> Can you help me?
> >>> Thanks for your replies and time.
> >>>
> >>> [[alternative HTML version deleted]]
> >>>
> >>> ______________________________________________
> >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide http://www.R-project.org/posti
> >>> ng-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>
> >>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list