[R] Question about functions in R

From: Ivan Kalafatic <ivan.kalafatic_at_gmail.com>
Date: Thu 20 Jul 2006 - 20:34:48 EST


I tried to make the following function:

function(x, y){

   dates<-intersect(x[,1],y[,1])
   m<-matrix(NA,length(dates),3)
   m[,1]<-dates
   j<-1
   k<-1
   for(i in fdax[,1]){

      if(is.element(i,dates)){
         m[j,3]<-as.numeric(fdax[k,2])
         j<-j+1
      }
      k<-k+1

   }
   return(m)
}

When I try to import it into R with edit( file="name.txt", editor="someeditor") I get the response that there is an error on the line where last bracket is.
When I execute this code manualy in R command by command everything works ok. This happened to me before with other functions. Sometimes I can import them and they work perfectly but sometimes I get the error on the last line of code which is alvays the final bracket.

Anyone has any idea why this is happening?



R-help@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 and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 20 20:38:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 04:17:49 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.