[R] Vector elements and ratios
Chuck Cleland
ccleland at optonline.net
Fri May 26 12:02:34 CEST 2006
Andrej Kastrin wrote:
> Dear useRs,
>
> I have two different length vectors: one column (1...m) and one row
> vector (1...n):
>
> 20
> 40
> 20
> 60
>
> 5 4 2
>
> Now I have to calculate ratios between column vector elements and each
> row vector elements:
>
> 4 5 10
> 8 10 20
> 4 5 20
> 15 12 30
A <- c(20,40,20,60)
B <- c(5,4,2)
A %*% t(1/B)
[,1] [,2] [,3]
[1,] 4 5 10
[2,] 8 10 20
[3,] 4 5 10
[4,] 12 15 30
> Thank's in advance for any suggestions,
>
> Andrej
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list