作者:疯务情堂 | 来源:互联网 | 2023-07-18 14:09
Icreatedseveralmatriceswiththeassignfunctionasfollows:我使用assign函数创建了几个矩阵,如下所示:for(iin
I created several matrices with the assign function as follows:
我使用assign函数创建了几个矩阵,如下所示:
for (i in 2:105) { # Loop for creating and filling matrices
(assign(paste("m",i,sep=""),Datos[(x[i-1]+1):x[i],1:14]))
}
This give me several matrices... from m2
to m105
... which is exactly what i wanted because i
can extract and call this matrices with their index like m2[i,j]
or m65[i,j]
etc.
这给了我几个矩阵......从m2到m105 ......这正是我想要的,因为我可以用m2 [i,j]或m65 [i,j]等索引提取和调用这个矩阵。
My problem is that I want to make a loop which include all my "m" matrices, but I don't know what could be the right code to do so because I need something like:
我的问题是我想制作一个包含所有“m”矩阵的循环,但我不知道什么是正确的代码才能这样做,因为我需要类似的东西:
paste("m",i,"[i,j]",sep="")
to return m2[i,j]
...m3[i,j]
...... m105[i,j]
and do the loop over this , but clearly the paste function returns a string and don't recognize m2
.... m105
like matrices..... it returns m2[i,j]
as text.
粘贴(“m”,i,“[i,j]”,sep =“”)返回m2 [i,j] ... m3 [i,j] ...... m105 [i,j]并对此进行循环,但很明显粘贴函数返回一个字符串,并且不识别m2 .... m105就像矩阵一样.....它将m2 [i,j]作为文本返回。
What should I do ?
我该怎么办 ?
Thank you very much ! regards
非常感谢你 !问候
1 个解决方案