rge(allret,idret[[as.character(i)]],all=TRUE)
}
> -Original Message-
> From: Gilbert Wu [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 24, 2005 12:36 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Make matrix from SQL query result
>
>
> Hi,
>
>
uot;)
date returns.1 returns.2
1 20050619 0.12 0.03
3 20050620 -0.01 0.01
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gilbert Wu
Sent: June 24, 2005 12:36 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Make matrix from SQL query
Gilbert,
This is untested, but something like:
function(x) {
uniq.col <- unique(x[,1])
uniq.row <- unique(x[,2])
ans <- array(NA, c(length(uniq.row), length(uniq.col)),
list(uniq.row, uniq.col))
ans[cbind(match(x[,2], uniq.row), match(x[,1], uniq.col))] <- x[,3]
ans
}
Pat
Hi,
I am trying to form a matrix from a SQL query result.
The SQL query result looks like this:
equity_id date returns
1 20050619 0.12
2 20050619 0.03
1 20050620 -0.01
2 20050620