Hi
I have a little vector function that takes a vector A of strictly
positive integers
and outputs a matrix M each of whose columns is the vector, modified in
a complicated combinatorical way.
Now I want to generalize the function so that A can include zeroes.
Given A,
I want to strip out
PROTECTED] On Behalf Of Robin Hankin
Sent: Thursday, July 27, 2006 9:54 AM
To: RHelp
Subject: [R] inserting rows into a matrix
Hi
I have a little vector function that takes a vector A of strictly positive
integers and outputs a matrix M each of whose columns is the vector,
modified
] inserting rows into a matrix
Hi
I have a little vector function that takes a vector A of strictly
positive
integers and outputs a matrix M each of whose columns is the vector,
modified in a complicated combinatorical way.
Now I want to generalize the function so that A can include
]
To: RHelp r-help@stat.math.ethz.ch
Subject: [R] inserting rows into a matrix
Date: Thu, 27 Jul 2006 14:54:02 +0100
Hi
I have a little vector function that takes a vector A of strictly
positive integers
and outputs a matrix M each of whose columns is the vector, modified in
a complicated
Try this where f and A2 are as in your post:
out -f(A2[A20])
replace(matrix(0, length(A2), ncol(out)), A2 0, out)
On 7/27/06, Robin Hankin [EMAIL PROTECTED] wrote:
Hi
I have a little vector function that takes a vector A of strictly
positive integers
and outputs a matrix M each of
-
From: Robin Hankin [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 27, 2006 10:16 AM
To: [EMAIL PROTECTED]
Cc: 'Robin Hankin'; 'RHelp'
Subject: Re: [R] inserting rows into a matrix
Hi Christos
thanks for this, but it won't work because in my application
f(A2) will fail if there are any zeroes
Message-
From: Robin Hankin [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 27, 2006 10:16 AM
To: [EMAIL PROTECTED]
Cc: 'Robin Hankin'; 'RHelp'
Subject: Re: [R] inserting rows into a matrix
Hi Christos
thanks for this, but it won't work because in my application
f(A2) will fail
replace 0 with NA and then back again:
f
function(a){cbind(a,a+1,rev(a)
)}
f(1:5)
a
[1,] 1 2 5
[2,] 2 3 4
[3,] 3 4 3
[4,] 4 5 2
[5,] 5 6 1
x - c(1,0,3,4,0,5)
f(x)
a
[1,] 1 2 5
[2,] 0 1 0
[3,] 3 4 4
[4,] 4 5 3
[5,] 0 1 0
[6,] 5 6 1
x[x==0] - NA
f(x)
a
[1,] 1 2 5
[2,] NA NA