Re: [R] Making a data frame into a factor ?

From: Charilaos Skiadas <>
Date: Tue, 15 Apr 2008 22:41:43 -0400

I think you want to look into ?stack. For example:

y<- stack(x)

Then x$values are the values, and x$ind is the factor.

On Apr 15, 2008, at 9:36 PM, Paul Lynch wrote:

> Hi,
> I'm trying to do a linear regression style one-way ANOVA using some
> data in a data frame, and (perhaps because I am still relatively
> unfamiliar with both R and statistics) what I thought I should do was
> to make the data frame into a factor. By that I mean that I have a
> data frame whose column labels are the levels of the factor, and the
> values in the frame are numeric values for the dependent variable.
> I can construct the relevant vectors by hand, if I have to (and I
> guess I will start in that direction) but I am sure there must be 1-3
> line bit of R that could elegantly create the factor and the vector of
> values.
> Thanks in advance,
> --
> Paul Lynch
> Aquilent, Inc.
> National Library of Medicine (Contractor)

Haris Skiadas
Department of Mathematics and Computer Science Hanover College mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 16 Apr 2008 - 02:45:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Apr 2008 - 03:30:29 GMT.

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

list of date sections of archive