由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 问一个R编程问题
相关主题
新手问个R里vectorization的问题Early Performance Report
R:matrix[合集] 真心求教!今天interview被这个最简单的mixed model问题
怎样generate random number matrixplease help for the R code
R Matrix 初级问题another sas question
请问两道sas adv的题..请教一个R的问题,怎么根据Matrix的值画颜色渐变图呢?
请教data mining 的问题,在线等,谢谢![合集] 问excel牛人一个问题
one little SAS questiona probability interview question.
关于R的一个编程问题,怎么存储数据在一个向量?请教什么是fourth-difference matrix operator?
相关话题的讨论汇总
话题: matrix话题: row话题: integers话题: array话题: any
进入Statistics版参与讨论
1 (共1页)
x***x
发帖数: 3401
1
I have a matrix M and a array L. L contains a list of integers.
The integers are the indexes of the row numbers in the matrix M.
I want to make a new matrix N where the ith row corresponds to the L[i]th
row of the M matrix.
Is there an easy way of doing this?
I can only think of a loop with rbind() function. Any other simpler ideas or
functions?
Thanks
x***x
发帖数: 3401
2
举个例子好懂一点
比如L=(3,5,2,7)
那么我需要取M的3, 5, 2, 7行作为N的1, 2, 3, 4行.
谢谢
m****r
发帖数: 237
3
Just use
N=M[L,]
I think that will do it

【在 x***x 的大作中提到】
: 举个例子好懂一点
: 比如L=(3,5,2,7)
: 那么我需要取M的3, 5, 2, 7行作为N的1, 2, 3, 4行.
: 谢谢

m****r
发帖数: 237
4
and r u sure L is an array instead of vector??

or

【在 x***x 的大作中提到】
: I have a matrix M and a array L. L contains a list of integers.
: The integers are the indexes of the row numbers in the matrix M.
: I want to make a new matrix N where the ith row corresponds to the L[i]th
: row of the M matrix.
: Is there an easy way of doing this?
: I can only think of a loop with rbind() function. Any other simpler ideas or
: functions?
: Thanks

x***x
发帖数: 3401
5
oh, right, Thanks!

【在 m****r 的大作中提到】
: Just use
: N=M[L,]
: I think that will do it

1 (共1页)
进入Statistics版参与讨论
相关主题
请教什么是fourth-difference matrix operator?请问两道sas adv的题..
问一下证明请教data mining 的问题,在线等,谢谢!
请问熟悉SAS IML的one little SAS question
r里面如何生成Variance-Covariance Matrix关于R的一个编程问题,怎么存储数据在一个向量?
新手问个R里vectorization的问题Early Performance Report
R:matrix[合集] 真心求教!今天interview被这个最简单的mixed model问题
怎样generate random number matrixplease help for the R code
R Matrix 初级问题another sas question
相关话题的讨论汇总
话题: matrix话题: row话题: integers话题: array话题: any