yywan0913 发表于 2014-1-29 22:30 ![](https://bbs-cdn.datacourse.cn/static/image/common/back.gif)
大概是这样子吧,然后再matrix一下 暂时没完全弄出来 ,明再看下,大过年的还在忙呢你们
不知道是不是你的 ...
多谢了,在国外还得悲催的上班啊
我读你的代码 感觉应该可以的 是我的意思。但是我试了一下 估计是我哪里写错了。
> A <- matrix(c(1,2,3,4), nrow=2, ncol=2)
> A
[,1] [,2]
[1,] 1 3
[2,] 2 4
>
> C <- c(1,2,3)
> D <- c(2,3,4)
> E <- c(3,4,5)
> F <- c(4,5,6)
> B <- matrix(list(C,D,E,F), nrow=2, ncol=2)
> B
[,1] [,2]
[1,] Numeric,3 Numeric,3
[2,] Numeric,3 Numeric,3
>
> H <- matrix(function(x,y) list(A[x,y]*unlist(B[x,y])),nrow=nrow(A), ncol=ncol(A))
Error in as.vector(x, mode) :
cannot coerce type 'closure' to vector of type 'any'
> H
Error: object 'H' not found
>