Full_Name: Michael Aaron Karsh Version: 2.8.0 OS: Windows XP Submission from: (NULL) (75.61.102.255)
Whenever I try changing a function, it keeps coming up with the same error message. I have the function CN_state_log_sum=function(Tot_log_sum){ #estimate copy number state for the log sum approach if(((Im(Tot_log_sum))!=0)|Re(Tot_log_sum)<=log(1/4)/log(2)) {return(0)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(1/4)/log(2))&&((Re(Tot_log_sum))<log(3/4)/log(2))) {return(1)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>(log(3/4)/log(2)))&&((Re(Tot_log_sum))<log(5/4)/log(2))) {return(2)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(5/4)/log(2))&&((Re(Tot_log_sum))<log(7/4)/log(2))) {return(3)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(7/4)/log(2))) {return(4)} } When I try to run it in the loop: for (j in 1:length(BB_mean_ref)){ # find copy number states (0 for homozygous deletion, 1 for hemizygous deletion, 2 for neutral, 3 for single amplification, 4 for multiple amplification) state_log_sum[j]=CN_state_log_sum(Tot_log_sum[j]) state_sum_log[j]=CN_state_sum_log(Tot_sum_log[j]) } I get the error message: Error in Im(Tot_sum_log) != 0 || Re(Tot_sum_log) <- 2 : could not find function "||<-" Originally, I had defined the function: CN_state_log_sum=function(Tot_log_sum){ #estimate copy number state for the log sum approach if(Im(Tot_log_sum)!=0||Re(Tot_log_sum)<-2) return(0) if(Im(Tot_log_sum)==0&&Re(Tot_log_sum)>-2)&&Re(Tot_log_sum)<-.4150375) return(1) if(Im(Tot_log_sum)==0&&Re(Tot_log_sum)>-.4150375&&Re(Tot_log_sum)<.3219281) return(2) if(Im(Tot_log_sum)==0&&Re(Tot_log_sum)>.3219281&&Re(Tot_log_sum)<.807355) return(3) if(Im(Tot_log_sum)==0&&Re(Tot_log_sum)>.807355) return(4) } When I tried: for (j in 1:length(BB_mean_ref)){ # find copy number states (0 for homozygous deletion, 1 for hemizygous deletion, 2 for neutral, 3 for single amplification, 4 for multiple amplification) state_log_sum[j]=CN_state_log_sum(Tot_log_sum[j]) state_sum_log[j]=CN_state_sum_log(Tot_sum_log[j]) } I get the error message: Error in Im(Tot_sum_log) != 0 || Re(Tot_sum_log) <- 2 : could not find function "||<-" I then tried changing the function to: CN_state_log_sum=function(Tot_log_sum){ #estimate copy number state for the log sum approach if((Im(Tot_log_sum)!=0)||(Re(Tot_log_sum)<-2)) return(0) if((Im(Tot_log_sum)==0)&&(Re(Tot_log_sum)>-2))&&(Re(Tot_log_sum)<-.4150375)) return(1) if((Im(Tot_log_sum)==0)&&(Re(Tot_log_sum)>-.4150375)&&(Re(Tot_log_sum)<.3219281)) return(2) if((Im(Tot_log_sum)==0)&&(Re(Tot_log_sum)>.3219281)&&(Re(Tot_log_sum)<.807355)) return(3) if((Im(Tot_log_sum)==0)&&(Re(Tot_log_sum)>.807355)) return(4) } I got the same error message. I then remembered that <- is used to make assignments, when what I wanted to do was compare one expression to a negative number. I then tried changing the function to: CN_state_log_sum=function(Tot_log_sum){ #estimate copy number state for the log sum approach if(((Im(Tot_log_sum))!=0)|Re(Tot_log_sum)<=log(1/4)/log(2)) {return(0)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(1/4)/log(2))&&((Re(Tot_log_sum))<log(3/4)/log(2))) {return(1)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>(log(3/4)/log(2)))&&((Re(Tot_log_sum))<log(5/4)/log(2))) {return(2)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(5/4)/log(2))&&((Re(Tot_log_sum))<log(7/4)/log(2))) {return(3)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(7/4)/log(2))) {return(4)} } I got the same error message. I then tried removing the function using the command: rm(CN_state_log_sum) and then putting in the function again: CN_state_log_sum=function(Tot_log_sum){ #estimate copy number state for the log sum approach if(((Im(Tot_log_sum))!=0)|Re(Tot_log_sum)<=log(1/4)/log(2)) {return(0)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(1/4)/log(2))&&((Re(Tot_log_sum))<log(3/4)/log(2))) {return(1)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>(log(3/4)/log(2)))&&((Re(Tot_log_sum))<log(5/4)/log(2))) {return(2)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(5/4)/log(2))&&((Re(Tot_log_sum))<log(7/4)/log(2))) {return(3)} if(((Im(Tot_log_sum))==0)&&((Re(Tot_log_sum))>log(7/4)/log(2))) {return(4)} } Same error message. I tried removing the function again, and then tried saving the new workspace and the workspace image when I closed R so that it would remember that that function had been removed when I would open R again. I then opened R again and defined the same function again. Again, when I tried running it, I got the same error message. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel