Ask Your Question

b_ron's profile - activity

2016-07-05 09:17:38 -0500 received badge  Popular Question (source)
2016-07-05 09:17:38 -0500 received badge  Notable Question (source)
2012-10-17 18:54:38 -0500 received badge  Scholar (source)
2012-10-17 18:54:38 -0500 marked best answer How to convert sagemath matrix to R matrix?

It looks like you have to put the matrix into a list representing a column vector. Then, you can use the r.matrix command. For example:

m=matrix(3,4,[1,2,3,4,5,6,7,8,9,10,11,12])
r.matrix(m.transpose().list(),nrow=3)

gives the following matrix in R:

     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
2012-10-17 18:54:32 -0500 received badge  Supporter (source)
2012-10-17 18:47:12 -0500 commented answer How to convert sagemath matrix to R matrix?

Ah. I see. That makes sense. By converting the sagemath matrix into a list using its list method, r.matrix() accepts the list as input for the data argument. Also, for others who made read this comment, r.matrix(m.list(), nrow=3, byrow="False") or r.matrix(m.list(),ncol=4,byrow="False") yield the same R matrix as the one above. Thank you very much, calc314!

2012-10-17 17:17:52 -0500 asked a question How to convert sagemath matrix to R matrix?

I have a 5 x 30 matrix, G, created in sagemath. The type is

type 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'.

I want to convert this matrix to a R matrix to perform various manipulations using the R interface.

How can I use sagemath matrix, G, to create a matrix in the R interface?

I tried the following but to no avail.

r.matrix(G)

r.matrix(G,5,30)