[R] transform a table into a matrix

John Fox jfox at mcmaster.ca
Tue Jun 24 14:10:43 CEST 2008

Dear Maria,

On 23-Jun-08, at 11:40 PM, Maria Gavilanez wrote:

> Hi.
> is there a way to transform a table that has numeric and categorical  
> variables into a matrix?

No, because all of the elements of a matrix must be of the same mode,  
but a dataframe is a data structure that can have heterogeneous  
columns. It's unclear from your question where the "table" is located  
-- in a file perhaps? If so, you can use read.table() to read the data  
into a dataframe.

I hope this helps,

John Fox, Professor
Department of Sociology
McMaster University
Hamilton ON Canada L8S 4M4
web: socserv.mcmaster.ca/jfox

> thanks
> Maria Mercedes Gavilanez
> Department of Biological Sciences
> 107 Life Sciences Building
> Louisiana State University
> Baton Rouge, LA 70803
> (225)578-4284
> ______________________________________________
> R-help at 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.

More information about the R-help mailing list