Can someone please give me a pointer here.
I have two matrices
matA
A B C
1 5 2 4
2 2 4 3
3 1 2 4
matB
A B C
1 TRUEFALSE TRUE
2 FALSE TRUETRUE
3 FALSE FALSE FALSE
how
Try this:
matA[c(matB)]
In fact even this works for your example although in general it
couldbe problematic since a two column matrix index has
special meaning:
matA[matB]
On 3/15/06, tom wright [EMAIL PROTECTED] wrote:
Can someone please give me a pointer here.
I have two matrices
matA
On Wed, 2006-03-15 at 06:03 -0500, tom wright wrote:
Can someone please give me a pointer here.
I have two matrices
matA
A B C
1 5 2 4
2 2 4 3
3 1 2 4
matB
A B C
1 TRUEFALSE TRUE
2
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of tom wright
Sent: Wednesday, March 15, 2006 6:04 AM
To: R-Stat Help
Subject: [R] matrix indexing
Can someone please give me a pointer here.
I have two matrices
matA
A B C
1
://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: tom wright [EMAIL PROTECTED]
To: R-Stat Help R-help@stat.math.ethz.ch
Sent: Wednesday, March 15, 2006 12:03 PM
Subject: [R] matrix indexing
Can someone please give me a pointer here.
I have two matrices
matA
This is really elementary indexing in S language:
matA[matB]
Best,
Philippe Grosjean
tom wright wrote:
Can someone please give me a pointer here.
I have two matrices
matA
A B C
1 5 2 4
2 2 4 3
3 1 2 4
matB
A
Dear tom,
is the following what you are looking for?
a=matrix(runif(9),3,3)
a
[,1] [,2] [,3]
[1,] 0.9484247 0.9765431 0.6169739
[2,] 0.8423545 0.3137295 0.4031847
[3,] 0.6724235 0.1076373 0.2356923
b-matrix(sample(c(TRUE,FALSE),size=9,replace=TRUE),3,3)
b
[,1]
Thanks everyone.
Obvious when you think about it, and you check that both the matrices
your trying it with are actually matrices... instead of one being a
list.
On Wed, 2006-15-03 at 06:03 -0500, tom wright wrote:
Can someone please give me a pointer here.
I have two matrices
matA
A
, Jason
Sent: Friday, February 17, 2006 1:36 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Matrix indexing in a loop
How do you specify matrix location a[i,j] (or a[i-1,j], etc.) in a for
loop?
I am looking for a flexible method of indexing neighbors over a series of lags
(1,2,3...) and I may
Dear R-users,
I was wondering for the following:
Let 'x' be a matrix and 'ind' and indicator matrix,
i.e.,
x - array(1:20, dim = c(4, 5))
ind - array(c(1:3, 3:1), dim = c(3, 2))
I'd like to get (as a vector) the elements of 'x'
which are not indexed by 'ind'. Since negative indices
are not
Hi,
you might not consider this more elegant, but how about this
x[-apply(ind, 1, function(i) (i[1]-1)*nrow(x) + i[2])]
Ben
On 8/18/05, toka tokas [EMAIL PROTECTED] wrote:
Dear R-users,
I was wondering for the following:
Let 'x' be a matrix and 'ind' and indicator matrix,
i.e.,
x -
x - array(1:20, dim = c(4, 5))
ind - array(c(1:3, 3:1), dim = c(3, 2))
# instead of using ind (pairs of coordinates) for
getting the items in the matrix, you can convert it to
a list of single coordinates to point to the item in
the matrix:
# t = transpose
# nrow = get the number of rows
indices
Hi,
I have the following problem.
In a csv file I have under column A, the date, and column B, the prices.
Thus, for example, the file looks something like this -
1/31/04 2.5
2/1/042.6
...
4/12/04 3.5
Basically, I use the function inputframe = read.csv( )
which reads the csv
Kim Fai Wong gokim19 at hotmail.com writes:
:
: Hi,
:
: I have the following problem.
: In a csv file I have under column A, the date, and column B, the prices.
: Thus, for example, the file looks something like this -
:
: 1/31/04 2.5
: 2/1/042.6
: ...
: 4/12/04 3.5
:
:
14 matches
Mail list logo