Hello List, I am trying to obtain a table containing absolute and relative frequencies but it must be done by strata. Each strata have to contain totals and subtotals being the sum of the subtotals equal to the total in upper strata in same column. As this could be some vague I am including an example of such table: data<-data.frame(Provincial=rep(c("Prov1","Prov2","Prov1","Prov3"),10), Municipios=rep(c("Mun1","Mun2","Mun3","Mun4"),10),unit=rep(c("unit1","unit2","unit3","unit4"),10)) Variable N % Province (i) Municipalities (j) Health units (k) ∑i, ∑j, ∑k And so on i = 1 to 16 ∑i, ∑j, ∑k If you could help me to obtain a function to get such table I would appreciate very much. Best and thank you . maicel monzon MD. MSc. ---------------------------------------------------------------- -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/
Hi maicel, This may be completely off the mark, but the brkdnNest function in the plotrix package can produce a nested list of counts which can be transformed into percents (100*count/total). require(plotrix) data$dummy<-1 brkdnNest(dummy~Provincial+Municipios+unit,data,FUN="sum") The counts in your example are mostly NA as most cells are empty. Jim On Tue, Mar 3, 2015 at 7:31 AM, <maicel at infomed.sld.cu> wrote:> Hello List, > > I am trying to obtain a table containing absolute and relative frequencies > but it must be done by strata. Each strata have to contain totals and > subtotals being the sum of the subtotals equal to the total in upper strata > in same column. As this could be some vague I am including an example of > such table: > > > data<-data.frame(Provincial=rep(c("Prov1","Prov2","Prov1","Prov3"),10), > Municipios=rep(c("Mun1","Mun2","Mun3","Mun4"),10),unit=rep( > c("unit1","unit2","unit3","unit4"),10)) > > Variable N % > Province (i) > Municipalities (j) > Health units (k) > ∑i, ∑j, ∑k > And so on ? i = 1 to 16 > > ∑i, ∑j, ∑k > > If you could help me to obtain a function to get such table I would > appreciate very much. > > Best and thank you?. > maicel monzon MD. MSc. > > > > ---------------------------------------------------------------- > > > > > -- > Este mensaje le ha llegado mediante el servicio de correo electronico que > ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema > Nacional de Salud. La persona que envia este correo asume el compromiso de > usar el servicio a tales fines y cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > ______________________________________________ > 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]]
I suspect that the tabular function in the tables package would handle this task. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On March 2, 2015 12:31:50 PM PST, maicel at infomed.sld.cu wrote:>Hello List, > >I am trying to obtain a table containing absolute and relative >frequencies but it must be done by strata. Each strata have to contain > >totals and subtotals being the sum of the subtotals equal to the total > >in upper strata in same column. As this could be some vague I am >including an example of such table: > > >data<-data.frame(Provincial=rep(c("Prov1","Prov2","Prov1","Prov3"),10), > >Municipios=rep(c("Mun1","Mun2","Mun3","Mun4"),10),unit=rep(c("unit1","unit2","unit3","unit4"),10)) > >Variable N % >Province (i) >Municipalities (j) >Health units (k) >∑i, ∑j, ∑k >And so on > i = 1 to 16 > >∑i, ∑j, ∑k > >If you could help me to obtain a function to get such table I would >appreciate very much. > >Best and thank you >. >maicel monzon MD. MSc. > > > >---------------------------------------------------------------- > > > > >-- >Este mensaje le ha llegado mediante el servicio de correo electronico >que ofrece Infomed para respaldar el cumplimiento de las misiones del >Sistema Nacional de Salud. La persona que envia este correo asume el >compromiso de usar el servicio a tales fines y cumplir con las >regulaciones establecidas > >Infomed: http://www.sld.cu/ > >______________________________________________ >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.
Hi Jeff, I don't have that package, but reading the documentation, I think you are right. Plus the tabular function already has the formatting worked out. Jim On Tue, Mar 3, 2015 at 7:26 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> I suspect that the tabular function in the tables package would handle > this task. > --------------------------------------------------------------------------- > Jeff Newmiller The ..... ..... Go Live... > DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live > Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/Batteries O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --------------------------------------------------------------------------- > Sent from my phone. Please excuse my brevity. > > On March 2, 2015 12:31:50 PM PST, maicel at infomed.sld.cu wrote: > >Hello List, > > > >I am trying to obtain a table containing absolute and relative > >frequencies but it must be done by strata. Each strata have to contain > > > >totals and subtotals being the sum of the subtotals equal to the total > > > >in upper strata in same column. As this could be some vague I am > >including an example of such table: > > > > > >data<-data.frame(Provincial=rep(c("Prov1","Prov2","Prov1","Prov3"),10), > > > > >Municipios=rep(c("Mun1","Mun2","Mun3","Mun4"),10),unit=rep(c("unit1","unit2","unit3","unit4"),10)) > > > >Variable N % > >Province (i) > >Municipalities (j) > >Health units (k) > >∑i, ∑j, ∑k > >And so on ?> i = 1 to 16 > > > >∑i, ∑j, ∑k > > > >If you could help me to obtain a function to get such table I would > >appreciate very much. > > > >Best and thank you?>. > >maicel monzon MD. MSc. > > > > > > > >---------------------------------------------------------------- > > > > > > > > > >-- > >Este mensaje le ha llegado mediante el servicio de correo electronico > >que ofrece Infomed para respaldar el cumplimiento de las misiones del > >Sistema Nacional de Salud. La persona que envia este correo asume el > >compromiso de usar el servicio a tales fines y cumplir con las > >regulaciones establecidas > > > >Infomed: http://www.sld.cu/ > > > >______________________________________________ > >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. > > ______________________________________________ > 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]]