简体   繁体   中英

R scripts load automatically

I have gotten an old package from CRAN that contains some R scripts, the question that I have is how I can load those scripts automatically without the need to open and run them line by line, is there any way possible? The package was called knnflex and it was deprecated from CRAN. There is a zip available for R for windows in:

http://cran.uvigo.es/web/packages/knnflex/index.html

but when one installs the package, it occurs a problem with the namespace, due to lack of compatibility (I dont put the problem or the solution here, because it was solved before in a thread in SO). I have included the namespace in the zip file with a trick that I found in this page, but some functions like predict are not recognized at all.

One turnaround that I make it was to download the tar.gz file, uncompress it and inside the R folder there are the scripts that make it possible to work. So actually I am loading those scripts one by one and then make it run separately line by line and it works.

So that is why I was asking if there is a way to call those scripts automatically.

Long story, but I think it can be helpful to other people also. Thanks

I haven't cleaned it up much but I moved those source files into my github repo so if you have the devtools package installed you can install knnflex with the following commands...

library(devtools)
install_github("knnflex", "Dasonk")

But really if you just want to load Rscripts then source is what you should be using.

If you want something to run when you load R then you should put it in your .Rprofile file. You can learn more in ?Startup

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM