
Dear Arun,thankyou very much...

> Date: Thu, 10 Jan 2013 12:02:31 -0800
> From: smartpink111@yahoo.com
> Subject: Re: merging command
> To: eliza_botto@hotmail.com
> CC: r-help@r-project.org
> 
> HI Eliza,
> 
> You could do this:
> set.seed(15)
> mat1<-matrix(sample(1:800,124*12,replace=TRUE),nrow=12) # smaller dataset
> #Your codes
>  list1<-list()
>  for(i in 1:ncol(mat1)){
>   list1[[i]]<-t(apply(mat1,1,function(x) x[i]-x))
>   list1}
>  x<-list1   
> x<-matrix(unlist(x),nrow=12)
> x<-abs(x)
>  y<-colSums(x, na.rm=FALSE)
> z<-matrix(y,ncol=10)
>  z<-as.dist(z)
>  z
>  #    1   2   3   4   5   6   7   8   9
> #2  319                                
> #3  459 516                            
> #4  385 504 260                        
> #5  365 282 506 520                    
> #6  318 363 373 305 383                
> #7  382 277 459 457 363 370            
> #8  526 521 431 443 523 472 608        
> #9  329 534 358 374 382 393 467 429    
> #10 364 377 393 365 419 420 346 472 489
> 
> #Modified code
> z1<-as.dist(do.call(cbind,lapply(seq_len(ncol(mat1)),function(i) colSums(abs(t(apply(mat1,1, function(x) x[i]-x))),na.rm=FALSE))))
> z1
> #     1   2   3   4   5   6   7   8   9
> #2  319                                
> #3  459 516                            
> #4  385 504 260                        
> #5  365 282 506 520                    
> #6  318 363 373 305 383                
> #7  382 277 459 457 363 370            
> #8  526 521 431 443 523 472 608        
> #9  329 534 358 374 382 393 467 429    
> #10 364 377 393 365 419 420 346 472 489
> 
> A.K.
> 
> 
> 
> 
> 
> 
> 
> ________________________________
> From: eliza botto <eliza_botto@hotmail.com>
> To: "smartpink111@yahoo.com" <smartpink111@yahoo.com> 
> Sent: Thursday, January 10, 2013 9:13 AM
> Subject: merging command
> 
> 
> 
> Dear Arun,
> i need you expertise to merge the following commands in to one step command.
> 
> mat1<-m
> list1<-list()
> for(i in 1:ncol(mat1)){
>  list1[[i]]<-t(apply(mat1,1,function(x) x[i]-x))
>  list1}
> x<-list1  
> 
> x<-matrix(unlist(x),nrow=12)
> 
> x<-abs(x)
> 
> y<-colSums(x,
> na.rm=FALSE)
> 
> z<-matrix(y,
> ncol=124)
> 
> z<-as.dist(z)
> 
> i needed that distance to be executed in one command by merging all these commands.
> is it possible??
> 
> thanks in advance
> 
> elisa                         
 		 	   		  
	[[alternative HTML version deleted]]


