Re: [R] Distance calculation

2013-05-25 Thread arun
=0]<-seq(max(x)+1,nrow(mat1),1);sum(abs(mat1[,1]-mat1[x,2]))})) #[1] 40.93609 A.K. - Original Message - From: eliza botto To: "r-help@r-project.org" Cc: Sent: Thursday, May 23, 2013 4:29 PM Subject: [R] Distance calculation Dear useRs, i have the following data arranged in three

[R] Distance calculation

2013-05-23 Thread eliza botto
Dear useRs, i have the following data arranged in three columns structure(c(0.492096635764151, 0.42688044914, 0.521585941816778, 1.66472272302545, 2.61878329527404, 2.19154489521664, 0.493876245329722, 0.4915787202584, 0.889477365620806, 0.609135860199222, 0.739201878930367, 0.8546637505195

Re: [R] Distance calculation

2013-03-27 Thread arun
HI, Try this: dat1<- read.csv("DQP.csv",sep="\t") res<- do.call(cbind,lapply(seq_len(nrow(dat1)),function(i) do.call(rbind,lapply(split(rbind(dat1[i,],dat1[-i,]),1:nrow(rbind(dat1[i,],dat1[-i,]))), function(x) {x1<-rbind(dat1[i,],x);colnames(x1)<-gsub("[.]","",colnames(x1));  if({indx<- colSums

Re: [R] Distance calculation

2013-03-26 Thread arun
HI, I am not sure about the error.  I modified the script and added 12 (hopefully all the locations) and didn't had any problems. dat1<- read.csv("rate.csv",sep=",") res<- do.call(cbind,lapply(seq_len(nrow(dat1)),function(i) do.call(rbind,lapply(split(rbind(dat1[i,],dat1[-i,]),1:nrow(rbind(dat1

Re: [R] Distance calculation

2013-03-25 Thread arun
Hi Elisa, Based on the formula you gave, this is what I got: dat1<- read.csv("rate.csv",sep=",") res<- do.call(cbind,lapply(seq_len(nrow(dat1)),function(i) do.call(rbind,lapply(split(rbind(dat1[i,],dat1[-i,]),1:nrow(rbind(dat1[i,],dat1[-i,]))), function(x) {x1<-rbind(dat1[i,],x);colnames(x1)<-

Re: [R] Distance calculation

2013-03-22 Thread arun
Hi Elisa, I hope this is what you wanted. dat1<-read.csv("peaks.csv",sep=",") #Subset dat2<-dat1[1:5,] res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x); abs((x