[R] Transform contingency table into data.frame ?

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Wed Mar 17 11:30:36 CET 2010


Hi Carlos,
try
as.data.frame.table(t)
hth.

Carlos Petti schrieb:
> Dear list,
>
> I have a contingency table :
>
> a <- letters[1:3]
> t <- table(a)
>
> I'm looking for a way to transform this table into data frame, as follows :
>
>  Freq
> a    1
> b    1
> c    1
>
> I used :
>
> df <- as.data.frame(t, row.names = names(t))
>
> But, this function do not remove the duplicated column. Do you know the
> solution ?
>
> Thanks in advance,
> Carlos
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>   

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790



More information about the R-help mailing list