From: Tony Plate <tplate_at_acm.org>

Date: Fri 13 Jan 2006 - 07:27:30 EST

R-help@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 Received on Fri Jan 13 07:33:46 2006

Date: Fri 13 Jan 2006 - 07:27:30 EST

When I try converting a matrix to a data frame, it works for me:

> x <- matrix(1:6,ncol=2,dimnames=list(LETTERS[1:3],letters[24:25]))
> data.frame(x)

x y

A 1 4

B 2 5

C 3 6

> str(data.frame(x))

`data.frame': 3 obs. of 2 variables:

$ x: int 1 2 3

$ y: int 4 5 6

>

You can also use as.data.frame() to convert a matrix to a data.frame (but note that if colnames are missing form the matrix, as.data.frame() constructs different colnames than does data.frame().

You say "it didn't work" -- it's difficult to help with such a non-specific complaint. Can you explain exactly how it didn't work for you? (e.g., show the exact error message).

- Tony Plate

Chia, Yen Lin wrote:

> Hi all,

*>
**>
**>
**> I wonder how could I convert a matrix A to a dataframe such that
**> whenever I'm running a linear model such lme, I can use A$x1? I tried
**> data.frame(A), it didn't work. Should I initialize A not as a matrix?
**> Thanks.
**>
**>
**>
**> Yen Lin
**>
**>
**> [[alternative HTML version deleted]]
**>
**> ______________________________________________
**> R-help@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
*

>

R-help@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 Received on Fri Jan 13 07:33:46 2006

*
This archive was generated by hypermail 2.1.8
: Fri 13 Jan 2006 - 14:19:40 EST
*