Re: [R] Matrix Operations

2010-11-27 Thread Wu Gong
Hi Romildo, Merge two table by id2 first, then reshape to the wide format, sum by source at last. Hope it helps. ### Data simulation lsp.text <- " id source destiny id2 caminho order 1 1 2 4 7 0 0 2 2 6 10 4 0 0 3 3 6

[R] Matrix Operations

2010-11-27 Thread Romildo Martins
Hello, Given the matrices LSPs and services, need to generate the matrix (mtraffic) as follows: 1. Browse all lines of LSPs 2. Collect the value of bw (matrix services) in accordance with id2 3. Sum bw in mtraffic (line = source) (column = destiny) Thanks! Romildo Martins ***

Re: [R] Matrix operations

2010-06-28 Thread Dmitrij Kudriavcev
ject.org] > On Behalf Of Dmitrij Kudriavcev > Sent: Tuesday, 29 June 2010 12:29 PM > To: r-help@r-project.org > Subject: [R] Matrix operations > > Hello > > I have a quick question. > > I need to compute matrix in R, like A <- t(X) %*% solve(V) %*% X, where X > is > a v

Re: [R] Matrix operations

2010-06-28 Thread Bill.Venables
Oops. Try A <- sum(X * solve(V, X)) (too fast!) -Original Message- From: Venables, Bill (CMIS, Cleveland) Sent: Tuesday, 29 June 2010 1:05 PM To: 'Dmitrij Kudriavcev'; 'r-help@r-project.org' Subject: RE: [R] Matrix operations Since X is a vector, then A <

Re: [R] Matrix operations

2010-06-28 Thread Bill.Venables
[R] Matrix operations Hello I have a quick question. I need to compute matrix in R, like A <- t(X) %*% solve(V) %*% X, where X is a vector and V is a matrix This code works, but now i want to optimize it. I have try: A <- crossprod(X, solve(V)) %*% X Is there another, better way?

[R] Matrix operations

2010-06-28 Thread Dmitrij Kudriavcev
Hello I have a quick question. I need to compute matrix in R, like A <- t(X) %*% solve(V) %*% X, where X is a vector and V is a matrix This code works, but now i want to optimize it. I have try: A <- crossprod(X, solve(V)) %*% X Is there another, better way? WBR Dima [[alternative HT

Re: [R] matrix operations on grobs and grid units

2009-09-19 Thread baptiste auguie
A few amendments might make this improved code more readable, e = expression(alpha,"testing very large width", hat(beta), integral(f(x)*dx, a, b)) library(grid) rowMax.units <- function(u, nrow){ # rowMax with a fake matrix of units  matrix.indices <- matrix(seq_along(u), nrow=nrow)  do.call(uni

[R] matrix operations on grobs and grid units

2009-09-19 Thread baptiste auguie
Dear list, As a minimal test of a more complex grid layout, I'm trying to find a clean and efficient way to arrange text grobs in a rectangular layout. The labels may be expressions, or text with a fontsize different of the default, which means that the cell sizes should probably be calculated usi