Re: [R] Overriding contributed package functions
The problem is that tsdiag is a generic (the same in both packages), and package TSA sets methods for it (and methods for classes in package stats which has already registered methods). stats:::tsdiag.Arima(model1) ought to work (it does for me in your example), but please take with up with the maintainer of package TSA. (I would be inclined to copy out of package TSA the parts your want and not load the rest.) On Thu, 5 Mar 2009, Richard Saba wrote: The "tsdiag" function in the TSA package overrides the "tsdiag" function in the "stats" package. There are a few annoying bugs in the TSA's version of the function so I would like to use the "stats" function but still have access to other TSA functions. I have tried using stats::tsdiag( ) but as long as the TSA package is attached the function from the "TSA" package is called. I believe the problem is the result of the TSA package not having a "namespace". The only solution I have found is to detach the TSA package, (detach("package:TSA")) , which results in the loss of all the TSA specific functions. Does anyone have another solution? The following code illustrates the problem: Y1<-arima.sim(n=100,list(ar=c(.95,-0.2))) model1<-arima(Y1,order=c(2,0,0)) tsdiag(model1) library(TSA) tsdiag(model1) stats::tsdiag(model1) detach("package:TSA") tsdiag(model1) R Saba __ R-help@r-project.org 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org 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.
Re: [R] Overriding contributed package functions
Have you tried using the pos argument in the library function to load the TSA package after the stats package? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Richard Saba > Sent: Thursday, March 05, 2009 9:52 AM > To: r-help@r-project.org > Subject: [R] Overriding contributed package functions > > The "tsdiag" function in the TSA package overrides the "tsdiag" > function in > the "stats" package. There are a few annoying bugs in the TSA's version > of > the function so I would like to use the "stats" function but still have > access to other TSA functions. I have tried using stats::tsdiag( ) > but as > long as the TSA package is attached the function from the "TSA" package > is > called. I believe the problem is the result of the TSA package not > having a > "namespace". The only solution I have found is to detach the TSA > package, > (detach("package:TSA")) , which results in the loss of all the TSA > specific > functions. Does anyone have another solution? > The following code illustrates the problem: > > Y1<-arima.sim(n=100,list(ar=c(.95,-0.2))) > model1<-arima(Y1,order=c(2,0,0)) > tsdiag(model1) > library(TSA) > tsdiag(model1) > stats::tsdiag(model1) > detach("package:TSA") > tsdiag(model1) > > R Saba > > __ > R-help@r-project.org 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. __ R-help@r-project.org 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.
[R] Overriding contributed package functions
The "tsdiag" function in the TSA package overrides the "tsdiag" function in the "stats" package. There are a few annoying bugs in the TSA's version of the function so I would like to use the "stats" function but still have access to other TSA functions. I have tried using stats::tsdiag( ) but as long as the TSA package is attached the function from the "TSA" package is called. I believe the problem is the result of the TSA package not having a "namespace". The only solution I have found is to detach the TSA package, (detach("package:TSA")) , which results in the loss of all the TSA specific functions. Does anyone have another solution? The following code illustrates the problem: Y1<-arima.sim(n=100,list(ar=c(.95,-0.2))) model1<-arima(Y1,order=c(2,0,0)) tsdiag(model1) library(TSA) tsdiag(model1) stats::tsdiag(model1) detach("package:TSA") tsdiag(model1) R Saba __ R-help@r-project.org 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.