由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - R:matrix
相关主题
【R】保留matrix中某些值a R loop question
用R出现怪问题。这个R程序能帮改进一下吗?
R Matrix 初级问题突然对直线拟合的R不明白起来了
请教R Code, 多谢!如何把model fitting statistics 读出来(R)
[R]how to sample all possible continuous subset from ordered data请问现有软件能算多大矩阵的逆矩阵?
求用R做bootstrap的example script请教:关于covariance matrix
求问一个R apply 函数的问题R 两个大矩阵相乘,太慢怎么办呢
R 扫描matrix如何给一个matrix的rownames起个名字name?R问题求教!
相关话题的讨论汇总
话题: matrix话题: false话题: rownames话题: true话题: colnames
进入Statistics版参与讨论
1 (共1页)
f******9
发帖数: 267
1
How to find the numbers which are more than 0.5 in a matrix (and with their
rownames and colnames)?
for example, in this matrix:
[,1] [,2] [,3] [,4] [,5]

[1,] 1.0000000000 0.0320075758 0.1183712121 0.0293040293 0.0083333333
[2,] 0.0320075758 1.0000000000 0.0571428571 0.1668650794 0.0004662005
[3,] 0.1183712121 0.0571428571 1.0000000000 0.0053418803 0.0028846154
[4,] 0.0293040293 0.1668650794 0.0053418803 1.0000000000 0.0426767677
[5,] 0.008333
R*********r
发帖数: 225
2
which(X>0.5)
> X <- matrix(rnorm(25, 0,1),nrow=5)
> X
[,1] [,2] [,3] [,4] [,5]
[1,] 1.1050564 2.3754090 1.3176173 -1.5279143 1.1355724
[2,] 0.4067519 0.2387128 -1.1444963 -0.6691630 -0.8591197
[3,] 0.4040506 0.3869183 0.2218467 -0.3432441 0.9440614
[4,] -0.5409871 0.4164543 1.1699040 -0.2741125 0.5039738
[5,] -0.5846117 1.0009905 -1.9204391 1.0342027 0.1003464
In R, matrix's entries are indexed column by column.
thus
X[1,2] == X[6]
Not recommended but

【在 f******9 的大作中提到】
: How to find the numbers which are more than 0.5 in a matrix (and with their
: rownames and colnames)?
: for example, in this matrix:
: [,1] [,2] [,3] [,4] [,5]
:
: [1,] 1.0000000000 0.0320075758 0.1183712121 0.0293040293 0.0083333333
: [2,] 0.0320075758 1.0000000000 0.0571428571 0.1668650794 0.0004662005
: [3,] 0.1183712121 0.0571428571 1.0000000000 0.0053418803 0.0028846154
: [4,] 0.0293040293 0.1668650794 0.0053418803 1.0000000000 0.0426767677
: [5,] 0.008333

t**i
发帖数: 688
3
> X <- matrix(rnorm(25, 0,1),nrow=5)
> X
[,1] [,2] [,3] [,4] [,5]
[1,] 1.56280941 -1.9127071 -0.626082 -1.0988275 0.5192378
[2,] -0.96582879 1.8160815 -2.319349 0.4177512 -0.2148984
[3,] 0.05563102 0.1863339 1.254996 -0.2122877 -0.4268865
[4,] 0.97439281 -0.1713336 2.012629 -1.3479961 1.8149157
[5,] -1.17377646 1.0095202 1.553646 -1.9188167 -1.4827899
> Y = X>0.5
> Y
[,1] [,2] [,3] [,4] [,5]
[1,] TRUE FALSE FALSE FALSE TRUE
[2,] FALSE T
D******n
发帖数: 2836
4
cbind(which(X>0.5,arr.ind=T),X[X>0.5])
f******9
发帖数: 267
5
很感谢!

【在 R*********r 的大作中提到】
: which(X>0.5)
: > X <- matrix(rnorm(25, 0,1),nrow=5)
: > X
: [,1] [,2] [,3] [,4] [,5]
: [1,] 1.1050564 2.3754090 1.3176173 -1.5279143 1.1355724
: [2,] 0.4067519 0.2387128 -1.1444963 -0.6691630 -0.8591197
: [3,] 0.4040506 0.3869183 0.2218467 -0.3432441 0.9440614
: [4,] -0.5409871 0.4164543 1.1699040 -0.2741125 0.5039738
: [5,] -0.5846117 1.0009905 -1.9204391 1.0342027 0.1003464
: In R, matrix's entries are indexed column by column.

f******9
发帖数: 267
6
Thank tosi!
另外R中这个%是用来干啥的啊?

【在 t**i 的大作中提到】
: > X <- matrix(rnorm(25, 0,1),nrow=5)
: > X
: [,1] [,2] [,3] [,4] [,5]
: [1,] 1.56280941 -1.9127071 -0.626082 -1.0988275 0.5192378
: [2,] -0.96582879 1.8160815 -2.319349 0.4177512 -0.2148984
: [3,] 0.05563102 0.1863339 1.254996 -0.2122877 -0.4268865
: [4,] 0.97439281 -0.1713336 2.012629 -1.3479961 1.8149157
: [5,] -1.17377646 1.0095202 1.553646 -1.9188167 -1.4827899
: > Y = X>0.5
: > Y

f******9
发帖数: 267
7
非常感谢!谢谢啦DaShagen

【在 D******n 的大作中提到】
: cbind(which(X>0.5,arr.ind=T),X[X>0.5])
1 (共1页)
进入Statistics版参与讨论
相关主题
如何给一个matrix的rownames起个名字name?R问题求教![R]how to sample all possible continuous subset from ordered data
关于处理两个csv文件交集和子集的问题求用R做bootstrap的example script
[SQL] just figured out how to loop through all columns in a table求问一个R apply 函数的问题
R helpR 扫描matrix
【R】保留matrix中某些值a R loop question
用R出现怪问题。这个R程序能帮改进一下吗?
R Matrix 初级问题突然对直线拟合的R不明白起来了
请教R Code, 多谢!如何把model fitting statistics 读出来(R)
相关话题的讨论汇总
话题: matrix话题: false话题: rownames话题: true话题: colnames