Store Matrix in DataFrame Cell
1
1
Entering edit mode
Dario Strbenac ★ 1.6k
@dario-strbenac-5916
Last seen 17 hours ago
Australia

How can one store a matrix in a particular column?

> DataFrame(name = "test", value = I(matrix(1:4, ncol = 2)))
DataFrame with 2 rows and 2 columns
         name    value
  <character> <matrix>
1        test      1:3
2        test      2:4

I had hoped that the result would be a DataFrame of one row, with a matrix of two rows and two columns in the first row and second column of the DataFrame.

S4Vectors • 388 views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States

Put it in a list and put the list in a column.

0
Entering edit mode

It does not appear to work.

> DataFrame(name = "test", value = list(matrix(1:4, ncol = 2)))
DataFrame with 2 rows and 3 columns
         name  value.V1  value.V2
  <character> <integer> <integer>
1        test         1         3
2        test         2         4
ADD REPLY

Login before adding your answer.

Traffic: 1125 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6