[R] ugly loop

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Fri Apr 22 15:14:00 CEST 2005


maybe you want something like this:

x <- c(t(pt$x))


Best,
--D

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Bill Simpson" <William.Simpson at drdc-rddc.gc.ca>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Friday, April 22, 2005 2:58 PM
Subject: [R] ugly loop


> The following code is slow and ugly:
>
> count<-0
> for(i in 1:nrow(ver))
>  for(j in 1:ncol(ver))
>    {
>    count<-count+1
>    x[count]<-pt$x[ver[i,j]]
>    y[count]<-pt$y[ver[i,j]]
>    z[count]<-pt$z[ver[i,j]]
>    }
>
> Please help me make it better.
>
> Thanks!
>
> Bill
>
> ______________________________________________
> 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
>




More information about the R-help mailing list