On 17-05-2013, at 20:15, masumeh akhgar <akhgar.masu...@gmail.com> wrote:

> Hello,
> 
> I fail to tranfer data from a dataframe to a matrix.
> 
> var is from a dataframe (and belongs still to the class dataframe) and
> should look like m (see below).
> 
>> var
>  vec1 vec3  d1  d2
> 1  172  173 223 356
>> dput (var)
> structure(list(vec1 = 172L, vec3 = 173L, d1 = 223L, d2 = 356L), .Names =
> c("vec1",
> "vec3", "d1", "d2"), row.names = 1L, class = "data.frame")
>> m      #THIS IS THE AIM
>     [,1] [,2]
> [1,]  172  223
> [2,]  173  356
> 
>> dput (m)
> structure(c(172, 173, 223, 356), .Dim = c(2L, 2L))
> 
> How can I transform var to m?
> Thanks
> akhgar


This question appears to be an almost exact copy of this: 
http://r.789695.n4.nabble.com/convert-a-data-frame-to-matrix-td4667256.html

See the answers there.

Spam?

Berend

______________________________________________
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