Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个 6x6 矩阵,
1 1 2 1 2 2 1 3 1 1 2 1 0 5 1 1 0 3 0 5 0 2 1 3 4 1 3 3 2 3 2 3 3 0 2 3
我需要找到一种方法来选择所有大于 0 的值,这样我就可以创建一个包含所有大于 0 的元素的向量。有没有简单的方法可以做到这一点?
假设mat是你的矩阵
mat
mat[mat>0] [1] 1 1 4 2 1 3 5 5 1 3 2 1 1 3 3 1 1 1 2 3 2 2 1 2 2 2 1 3 3 3 3