s A&M University
> College Station, TX 77840-4352
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller
> Sent: Wednesday, December 16, 2015 7:01 PM
> To: Matteo Richiardi; r-help@r-project.org
> Subject: Re: [R]
f Newmiller
Sent: Wednesday, December 16, 2015 7:01 PM
To: Matteo Richiardi; r-help@r-project.org
Subject: Re: [R] Applying a function to a matrix using indexes as arguments
Would
outer( A, B, `*` ) / C
do the trick for you?
--
Sent from my phone. Please excuse my brevity.
On December 16,
Hi David,
that's a great answer, thanks so much. I imagined apply() was involved in
the solution, but I was unable to find how myself. Thanks again.
Matteo
On 17 December 2015 at 01:37, David Winsemius
wrote:
>
> > On Dec 16, 2015, at 5:34 PM, David Winsemius
> wrote:
> >
> >
> >> On Dec 16, 20
> On Dec 16, 2015, at 5:34 PM, David Winsemius wrote:
>
>
>> On Dec 16, 2015, at 4:18 PM, Matteo Richiardi
>> wrote:
>>
>> I have to evolve each element of a matrix W
>>
>> W <- matrix(0,2,3)
>>
>> according to some function which uses the indices of the matrix [i,j] as
>> arguments:
>> w.
> On Dec 16, 2015, at 4:18 PM, Matteo Richiardi
> wrote:
>
> I have to evolve each element of a matrix W
>
> W <- matrix(0,2,3)
>
> according to some function which uses the indices of the matrix [i,j] as
> arguments:
> w.fun = function(i,j) {
> return A[i]*B[j]/(C[i,j])
> }
>
> where
> A<-
Would
outer( A, B, `*` ) / C
do the trick for you?
--
Sent from my phone. Please excuse my brevity.
On December 16, 2015 4:41:13 PM PST, Matteo Richiardi
wrote:
>My problem is of course more complicated, and is obviously not a
>homework.
>I just wanted to provide a minimal working example. Y
My problem is of course more complicated, and is obviously not a homework.
I just wanted to provide a minimal working example. You can replace the
matrix C with a matrix containing any number, for what matters. Btw,
because numbers are extracted from a Gaussian distribution, the likelihood
that you
This calculation divides by values centered around zero. The only context that
I can think of that would require such silliness is a homework problem, and
this list has a no-homework policy. If not, then mentioning the theory you are
applying might help someone point you at an existing function
I have to evolve each element of a matrix W
W <- matrix(0,2,3)
according to some function which uses the indices of the matrix [i,j] as
arguments:
w.fun = function(i,j) {
return A[i]*B[j]/(C[i,j])
}
where
A<-c(100,100)
B<-c(200,200,200)
C <- matrix( rnorm(6,mean=0,sd=1), 2, 3)
How can I do it
9 matches
Mail list logo