[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] How to do it without for loops?
From: "Gabor Grothendieck" <ggrothendieck () gmail ! com>
Date: 2006-02-28 13:43:15
Message-ID: 971536df0602280543i4c848426v249bd9c74c1897be () mail ! gmail ! com
[Download RAW message or body]
Try:
crossprod(x)
or
t(x) %*% x
On 2/28/06, ronggui <ronggui.huang@gmail.com> wrote:
> This is the code:
>
> x<-matrix(rnorm(20),5)
> y<-list()
> for (i in seq(nrow(x))) y[[i]]<-t(x[i,,drop=F])%*%x[i,,drop=F]
> y[[1]]+y[[2]]+y[[3]]+y[[4]]+y[[5]]
>
> How can I do it without using for loops?
> Thank you in advance!
> --
> ronggui
> Deparment of Sociology
> Fudan University
>
> ______________________________________________
> R-help@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
>
______________________________________________
R-help@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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic