[R] Table question
Liaw, Andy
andy_liaw at merck.com
Thu Oct 28 21:22:28 CEST 2004
Here's one way:
> f1 <- factor(rep(1:2, e=10))
> f2 <- factor(rep(1:2, 10))
> tab <- table(f1, f2)
> str(as.data.frame(unclass(tab)))
`data.frame': 2 obs. of 2 variables:
$ 1: int 5 5
$ 2: int 5 5
HTH,
Andy
> From: Sean Davis
>
> I have a table (output from table(factor1,factor2)). I would like to
> use write.table to output that table to a file. However, it
> seems that
> as.data.frame converts such a table to three columns, Var1, Var2, and
> Freq rather than converting to the data.frame with equivalent numbers
> of rows and columns. I can use write.matrix from the MASS
> package, but
> then I get no rownames. Any hints here?
>
> Thanks
> Sean
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list