[R] table

Jim Lemon drjimlemon at gmail.com
Tue Mar 3 09:06:47 CET 2015


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]]



More information about the R-help mailing list