大家好, 我是julia的新手, 在此想请教一个问题:
Julia中如何设置行名和列名, 因为我需要对行名和列名进行过滤筛选.
比如在R中:
> R_test = matrix(1:16,4,4)
> colnames(R_test) = rownames(R_test) = c("A","B","C","D")
> R_test
A B C D
A 1 5 9 13
B 2 6 10 14
C 3 7 11 15
D 4 8 12 16
> id = c("B","C")
> R_test[id,id]
B C
B 6 10
C 7 11
这里, 我生成了一个4*4的矩阵, 行名和列名分别是A,B,C,D,我想根据ID(B和C)提取相应的子矩阵. 在R里面操作如上.
Julia中如何操作?
我的错误的代码:
julia_test = reshape(collect(1:16),4,4)
colnames(julia_test) = rownames(julia_test) =["A","B","C","D"]
julia_test
colnames(julia_test)
id = ["B","C"]
julia_test[id,id]
非常感谢.