根据代码填充R中的矩阵
我有一个带有这样的代码的文件:
V1 V2
1 1.0000000
2 0.2000000
3 0.5000000
4 0.0000000
一个带有以下代码的矩阵:
1 1 1 1 1 1 1
3 3 3 3 3 3 3
4 2 4 2 4 2 4
1 1 1 1 1 1 1
我想使用循环制作一个新矩阵,其中每个值是代码的值,如下所示:
1.0 1.0 1.0 1.0 1.0 1.0 1.0
0.5 0.5 0.5 0.5 0.5 0.5 0.5
0.0 0.2 0.0 0.2 0.0 0.2 0.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0
有什么想法吗?
I have a file with codes like this:
V1 V2
1 1.0000000
2 0.2000000
3 0.5000000
4 0.0000000
And one matrix with the codes like the following:
1 1 1 1 1 1 1
3 3 3 3 3 3 3
4 2 4 2 4 2 4
1 1 1 1 1 1 1
I would like to use a loop to make a new matrix in which each value is the value of the codes as follows:
1.0 1.0 1.0 1.0 1.0 1.0 1.0
0.5 0.5 0.5 0.5 0.5 0.5 0.5
0.0 0.2 0.0 0.2 0.0 0.2 0.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
由于标签,您可以更轻松地做到这一点,但是通常您可以使用
Match
:数据:解决方案:
解决方案:
Here you can do it somewhat easier because of labels, but in general you can use
match
:data:
solution: