m <- as.matrix(var) John Kane Kingston ON Canada
> -----Original Message----- > From: akhgar.masu...@gmail.com > Sent: Fri, 17 May 2013 22:45:22 +0430 > To: r-help@r-project.org > Subject: [R] help > > 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 > > ______________________________________________ > 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. ____________________________________________________________ Share photos & screenshots in seconds... TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if1 Works in all emails, instant messengers, blogs, forums and social networks. ______________________________________________ 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.