Skip to content
Back to formatted view

Raw Message

Message-ID: <DUB124-W60450242921F2B111DADB80E30@phx.gbl>
Date: 2013-11-23T21:39:07Z
From: Amie Hunter
Subject: Speeding up code

Hello R experts, 

I'm new to R and I'm wanting to know what is the best way to speed up my code. I've read that you can vectorize the code but I'm unsure on how to implement this into my code.


df <- data.frame(31790,31790)

for (i in 1:31790) 
{
? for (j in i:31790) 
? {
??? ken<-cor(cldm[i,3:17],cldm[j,3:17], method="kendall", use="pairwise")
??? dis2<-deg.dist(cldm[i,2],cldm[i,1],cldm[j,2],cldm[j,1])
?? ?
??? df[i,j]<-ifelse(dis2<=500,ken,NA)
??? }
? } 
df

Thanks!