On 12-02-13 5:46 PM, R. Michael Weylandt wrote:
which(x>0)
or
which(x>0, arr.ind=TRUE)
depending on your application.
Or even x>0 if you want a matrix of TRUE/FALSE values. You can use
x[x>0] to get the values, but they won't be in matrix form.
Duncan Murdoch
Michael
On Feb 13, 201
which(x>0)
or
which(x>0, arr.ind=TRUE)
depending on your application.
Michael
On Feb 13, 2012, at 5:38 PM, Sam Steingold wrote:
> if I have a vector, I can find the indexes which satisfy a condition:
> x <- rnorm(10)
> [1] 0.4751132 -0.5442322 -0.1979854 -0.2455521 0.8349336 -0.4283345
>
if I have a vector, I can find the indexes which satisfy a condition:
x <- rnorm(10)
[1] 0.4751132 -0.5442322 -0.1979854 -0.2455521 0.8349336 -0.4283345
[7] 0.6108130 2.0576160 1.1251716 -1.3933637
x[x>0]
[1] 0.4751132 0.8349336 0.6108130 2.0576160 1.1251716
(1:10)[x>0]
[1] 1 5 7 8 9
how ab
Hi,
this is what I want to do and what I found prior to ask there, but I wanted
to do that with a vector of several hundreds or thounsands of names. Because
I will have to use different vectors of very big size, my main concern was
how to import this vector from a textfile (so I just have to chang
> tmp <- matrix(1:24, 6, 4, dimnames=list(letters[1:6], LETTERS[1:4]))
> tmp
A B C D
a 1 7 13 19
b 2 8 14 20
c 3 9 15 21
d 4 10 16 22
e 5 11 17 23
f 6 12 18 24
> tmp[c("a", "c", "d", "f"), ]
A B C D
a 1 7 13 19
c 3 9 15 21
d 4 10 16 22
f 6 12 18 24
>
See
?`[`
for discussion.
Hi,
I have a large matrix containing 1 rows and 60 columns. I would like to
subset this matrix by using a list of several hundred row names. I tried to
find how to do that, eg with %in% or subset commands, but I never succeed
and I do not find the proper method on internet. How to proceed ?
Th
On Jul 16, 2009, at 6:41 PM, Ross Boylan wrote:
If m is a matrix and s is a logical matrix of the same dimensions, I'd
like to be able to update m with
m[s] <- 0
If m2 is another matrix, I'd also like to be able to do
m[s] <- m2
where elements of m for which s is TRUE get the corresponding
el
If m is a matrix and s is a logical matrix of the same dimensions, I'd
like to be able to update m with
m[s] <- 0
If m2 is another matrix, I'd also like to be able to do
m[s] <- m2
where elements of m for which s is TRUE get the corresponding element of
m2.
However, this doesn't work in R 2.7.1.
8 matches
Mail list logo