[R] Array multiplication
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Dec 3 10:35:23 CET 2002
Murray Jorgensen <maj at stats.waikato.ac.nz> writes:
> I wanted to do some timings, but system.time() seems not to work on
> compound statements.
>
> system.time({
> for (i in 1:n) {
> for (k in 1:d) {
> for (j in 1:m) {
> lamb.star[i,k] = lamb.star[i,k] + lambda[i,j,k]*zed[i,j]
> }
> }
> }
> )}
>
> gives a syntax error. I suppose there is a much smarter way to do
> this sort of stuff and that somebody will show me?
Ending that with "})" instead should get rid of the syntax error....
There is a "tensor" package on CRAN that would seem to be designed for
these types of operations.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list