[R] Problems with data.matrix
John Fox
jfox at mcmaster.ca
Fri Mar 28 18:18:37 CET 2003
Dear Laura,
I believe that matrix(unlist(lev2.list), ncol=2, byrow=TRUE) will do what
you want, assuming that each of the elements of the list composes one row
of the matrix. If the list elements are columns, then
data.matrix(as.data.frame(lev2.list)) or matrix(unlist(lev2.list), nrow=2)
should do the trick.
John
At 04:44 PM 3/28/2003 +0000, Laura Gross wrote:
>I have what is probably a simple problem that I just can't seem to
>solve.
>
>I have a data list which is in the form: lev2.list
>
>[[1]]
> 1 2
> number number
>[[2]]
> 3 4
> number number
>
>etc down to [[1100]]
>
>I'm wanting to convert this to a data.matrix so I can plot the values,
>however, when I use new<-data.matrix(lev2.list), I get a data matrix
>that reads:
>
>[1, ] Numeric, 2
>[2, ] Numeric, 2
>
>with every line down to [1100, ] reading 'Numeric,2'
>
>Why am I getting this output? Why will R not display the numbers in a
>data.matrix?
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------
More information about the R-help
mailing list