Hi:

mdf3 <- as.data.frame.table(as.table(mdat))
> mdf3
  Var1 Var2 Freq
1 row1 Col1    1
2 row2 Col1   11
3 row1 Col2    2
4 row2 Col2   12
5 row1 Col3    3
6 row2 Col3   13

HTH,
Dennis

On Mon, May 10, 2010 at 10:38 PM, Yuan Jian <jayuan2...@yahoo.com> wrote:

> Hi R-experts,
>
> I try to find a way to transfer a matrix to a data.frame that is used as
> input of aov.
> can you give me advice for that?
>
> >mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE, dimnames
> = list(c("row1", "row2"), c("Col1", "Col2", "Col3")))
> >mdat
>      Col1 Col2 Col3
> row1    1    2    3
> row2   11   12   13
>
> ===>
>       row   col    dat
> 1    row1  col1  1
> 2    row1  col2  2
> 3    row1  col3  3
> 4    row2  col1  11
>
> 5    row2  col2  12
>
> 6    row2  col3  13
>
>
>
>
>
>
>
>
>        [[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.
>
>

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