Try this:

data.frame(count = colSums(x == 1), percentage = colSums(x == 1) / nrow(x))


On Tue, Mar 15, 2011 at 11:13 AM, Orvalho Augusto <orvaq...@gmail.com>wrote:

> I have a dataset like this:
>
>   q25_1 q25_2 q25_3 q25_4 q25_5 q25_6 q25_7 q25_8 q25_9 q25_10 q25_11
> q25_12
> 1      2     2     1     1     2     1     2     1     1      2      1
>  3
> 2      2     2     2     1     2     1     2     1     1      2      1
>  2
> 3      2     1     1     1     2     1     2     1     2      2      1
>  2
> 4      2     2     1     1     2     2     2     1     1      1      2
>  2
> 5      2     2     1     1     2     3     2     1     2      2      2
>  2
> 6      2     2     1     1     2     2     2     1     1      1      2
>  2
> 7      2     2     1     1     2     3     2     1     2      2      3
>  2
> 8      2     2     1     1     1     1     2     1     1      1      2
>  2
> 9      2     2     1     1     2     2     2     1     2      2      2
>  2
> 10     2     2     1     1     2     2     2     1     2      1      2
>  2
>
> where those q25_ variables are answers (coded 1 for Yes 2 for No). Now I
> need a way to table counting the ones foreach variables like
>
> var        count    percentage
> q25_1     20          80
> q25_2     34          85
> ...
>
> Is it possible ir R?
>
> For who used stata might use mrtab.
>
> Thank you
> Orvalho
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to