주어 foo
와 mock
,이 할 수있는 방법이 foo
클래스로 matrix
대신은 array
?
호출 as.matrix()
은 foo
잘못된 구조로 들어갑니다. 나는 두 개가 아닌 한 행 foo
으로 matrix
, 하고 싶습니다 .
foo = structure(c(0.729504668890744, 0.190464932275543, 0.0800303988337127),
.Dim = c(1L, 3L, 1L),
.Dimnames = list(NULL, c("A", "B",
"C"), "NA"))
class(foo[, , 1L])
#> [1] "numeric"
print(foo[, , 1L])
#> A B C
#> 0.7295047 0.1904649 0.0800304
mock = structure(c(0.550876469322338, 0.729504668890744, 0.342833178276825,
0.190464932275543, 0.106290352400837, 0.0800303988337127),
.Dim = c(2L,
3L, 1L),
.Dimnames = list(NULL, c("A", "B", "C"),
"NA"))
class(mock[, , 1L])
#> [1] "matrix"
print(mock[, , 1L])
#> A B C
#> [1,] 0.5508765 0.3428332 0.1062904
#> [2,] 0.7295047 0.1904649 0.0800304
# matrix conversion does not result in desired structure
as.matrix(foo[, , 1L])
#> [,1]
#> A 0.7295047
#> B 0.1904649
#> C 0.0800304
2019-11-04에 reprex 패키지 (v0.3.0)로 생성됨
다음은 옵션입니다. array
array(c(foo), dim(foo)[-3], dimnames = dimnames(foo)[1:2])
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다