如何根据值在矩阵上移动行水平
我目前有两个矩阵:
[,1]
[1,] 0
[2,] 5
[3,] 1
并且
[,1] [,2] [,3]
[1,] 0 0 1
[2,] 0 9 9
[3,] 1 1 1
可以在第一个矩阵上的数字逐步向右移动行,并且所有空站点都可以完成0?结果就是这样:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0 0 1 0 0 0 0 0
[2,] 0 0 0 0 0 0 9 9
[3,] 0 1 1 1 0 0 0 0
I currently have two matrix:
[,1]
[1,] 0
[2,] 5
[3,] 1
and
[,1] [,2] [,3]
[1,] 0 0 1
[2,] 0 9 9
[3,] 1 1 1
it is possible to move rows automatically horizontal to the right by step of number on first matrix and all empty site complete 0? The result will be like that:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 0 0 1 0 0 0 0 0
[2,] 0 0 0 0 0 0 9 9
[3,] 0 1 1 1 0 0 0 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
mapply()
append()
:数据
You can use
mapply()
withappend()
:Data