[R] help
Berend Hasselman
bhh at xs4all.nl
Fri May 17 21:26:48 CEST 2013
On 17-05-2013, at 20:15, masumeh akhgar <akhgar.masumeh at 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
More information about the R-help
mailing list