Description Usage Arguments Value Author(s) See Also Examples
View source: R/msgpack.matrix.R
Transfer list format to matrix format
1 |
data |
a list format data that is made from unpack function |
matrix format data
Mikiya TANIZAWA 1970mix@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | (mat <- matrix(1:6, 2))
# [,1] [,2] [,3]
#[1,] 1 3 5
#[2,] 2 4 6
(m <- pack(mat))
# [1] 92 93 01 03 05 93 02 04 06
unpack(m)
#[[1]]
#[1] 1 3 5
#
#[[2]]
#[1] 2 4 6
msgpack.matrix(unpack(m))
# [,1] [,2] [,3]
#[1,] 1 3 5
#[2,] 2 4 6
colnames(mat) <- c("A","B","C")
mat
# A B C
#[1,] 1 3 5
#[2,] 2 4 6
(m <- pack(mat)) # <= if data has colname, serialize to "map"
#[1] 92 83 a1 41 01 a1 42 03 a1 43 05 83 a1 41 02 a1 42 04 a1 43 06
unpack(m)
#[[1]]
#A B C
#1 3 5
#
#[[2]]
#A B C
#2 4 6
msgpack.matrix(unpack(m))
# A B C
#[1,] 1 3 5
#[2,] 2 4 6
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.