Re: [R] help on data frame and matrix

From: Martin Maechler <>
Date: Mon 18 Sep 2006 - 06:52:55 GMT

>>>>> "John" == John Kane <> >>>>> on Sun, 17 Sep 2006 12:10:19 -0400 (EDT) writes:

    John> --- Finosaur <> wrote:

>> I am given a data frame, which actually contains a
>> matrix. But I need to convert the data frame into a
>> matrix so that I can use the matrix operators. Can
>> anybody help me out? Thanks a lot.
>> Thaleia

    John> d <- as.matrix(data.frame)

It's (almost always) better to use Dimitri's suggestion, data.matrix(), since that also produces a numeric matrix when the data frame contains factors.

Martin mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon Sep 18 16:58:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 18 Sep 2006 - 07:30:05 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.