Select matrix column (resp. row) as Nx1 (resp. 1xD) matrix, as opposed to vector

后端 未结 1 1327
孤独总比滥情好
孤独总比滥情好 2021-01-24 20:00

Let X be an N by D matrix. Selecting a submatrix of size n by d returns a matrix of those dimensions unl

相关标签:
1条回答
  • 2021-01-24 20:08

    If you don't want to simplify matrix subsets to vectors just tell [ not to drop dimensions:

    > dim(X[1:2,1, drop=FALSE])
    [1] 2 1
    > dim(X[1,1:2, drop=FALSE])
    [1] 1 2
    

    See ?"[" for details.

    0 讨论(0)
提交回复
热议问题