Rolf Turner
2009-Mar-04 20:25 UTC
[R] modifying a built in function from the stats package (fixing arima)
On 4/03/2009, at 10:06 PM, Marc Anonym wrote:> Dear Carlos and Kjetil, > > Thanks for your answer. > >> I do not think that is the way to go. If you believe that your >> algorithm >> is better than the existing one, talk to the author of the package >> and >> discuss the improvement. The whole community will benefit. > > I should be able to *easily* modify it and test it first! > >> Copy the existing function into a new file, edit it and load it via >> source. > >> 3) after downloading the source package (stats) containung arima, >> rename it (my.arima) and then do the changes. > > I obviously saved it with a different name and I was expecting it > to work > out of the box but I get an error that I don't know how to solve: > Error in Delta %+% c(1, rep(0, seasonal$period - 1), -1) : > object "R_TSconv" not found > > Other people have previously discussed this in this list with no > success... > http://www.nabble.com/Foreign-function-call-td21836156.html > > Any other hints or maybe help with the error that I'm getting?If you ***look at the code*** for arima you will see that ``%+%'' is defined in terms of a call to ``.Call()'' which calls ``R_TSconv''. So apparently R_TSconv is a C or Fortran function or subroutine in a ``shared object library'' or dll upon which arima depends. Hence to do anything with it you'll need to get that shared object library and dynamically load it. (E.g. get the code, SHLIB it, and dynamically load the resulting shared object library.) The code is all available from the R source tarball. If this is a challenge for you then the best advice would be not to mess with it. I don't think that ***I'd*** mess with it, and I'm at least partially au fait with this stuff. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
Marc Anonym
2009-Mar-05 09:00 UTC
[R] modifying a built in function from the stats package (fixing arima)
>If you ***look at the code*** for arima you will see that ``%+%'' is >defined >in terms of a call to ``.Call()'' which calls ``R_TSconv''. So >apparently >R_TSconv is a C or Fortran function or subroutine in a ``shared >object library'' >or dll upon which arima depends. Hence to do anything with it you'll >need to get >that shared object library and dynamically load it. (E.g. get the >code, SHLIB it, >and dynamically load the resulting shared object library.)>The code is all available from the R source tarball.>If this is a challenge for you then the best advice would be not to >mess with it.Hi Rolf, It took me some time to come to the same conclusion (I didn't even know what .Call() was) but I've found an easier way to modify the R file without having to understand how to link dlls. I just downloaded the full R package, Rtools and followed the instructions in http://cran.r-project.org/doc/manuals/R-admin.html#Building-the-core-files to build it. Then I can modify C:\R\src\library\stats\R\arima.R and run it. It is quite exagerated that I have to build R in order to modify an R file without messing with dlls, and I think it would be interesting to make this process easier, but for now I'm happy to be productive again. Thank you all for your help, Best, MarC
Apparently Analagous Threads
- modifying a built in function from the stats package (fixing arima)
- modifying a built in function from the stats package (fixing arima)
- modifying a built in function from the stats package (fixing arima)
- Foreign function call
- arima, xreg, and the armax model