Altaweel, Mark R. | 20 Aug 00:06
Favicon

matrix question

Hi,

I have a vector and a list, with data I would like to multiply together.

So for instance I have a vector s:

[[1]]
[1] 44308

[[2]]
[1] 4371

Also, I have a list d:

[[1]]
 [1] 1201 6170 2036 2927 1625 1391 2074 1453 3172 3027 4691 3719 1185  320 2071 1027 1046 1186 1403  580 1382  440    8  174

[[2]]
 [1] 6521  688 2678 3409 3033 1608 3618 1461 1836 2104  879 1095 2630 1591 2986  703 2548  913 1426  753  256  869  106

I want to multiply them together and put the results in a matrix.

This is my syntax:

for(i in 1:length(s))
 for(j in 1:length(d))
   m<-d[[j]][j]/s[[i]]  #m is the matrix of dimensions set to X(e.g. 10X10)

However, it seems I only get one result when i get m, which is the last value of d/j, which is m[1]=0.04 in this case.

(Continue reading)

Rolf Turner | 20 Aug 00:43
Favicon

Re: matrix question


On 20/08/2008, at 10:08 AM, Altaweel, Mark R. wrote:

> Hi,
>
> I have a vector and a list, with data I would like to multiply  
> together.

	No you haven't.  You have two ***lists***.  Lists and vectors
	are not the same thing.  If you don't distinguish between them
	you will confuse everyone, including yourself.
>
> So for instance I have a vector s:
>
> [[1]]
> [1] 44308
>
> [[2]]
> [1] 4371
>
> Also, I have a list d:
>
> [[1]]
>  [1] 1201 6170 2036 2927 1625 1391 2074 1453 3172 3027 4691 3719  
> 1185  320 2071 1027 1046 1186 1403  580 1382  440    8  174
>
> [[2]]
>  [1] 6521  688 2678 3409 3033 1608 3618 1461 1836 2104  879 1095  
> 2630 1591 2986  703 2548  913 1426  753  256  869  106
>
(Continue reading)


Gmane