[R] functions & paths

Kissell, Robert [EQRE] robert.kissell at citigroup.com
Thu Apr 1 00:28:19 CEST 2004


Hi,
I have a couple of quick questions regarding R.

1) I have a ".First" function that automatically loads the quadprog package into the workspace. The .First function resides in R and is only saved if I save the workspace. The exact function is as follows:

.First<-function() 
{
	library(quadprog)
}

Is there any way that this function can be saved outside of R? That is, is there any procedure that will run specified R commands whenever R is invoked?


2) Is there anyway to specify additional paths for R to search. For example, I have some R script named, myProg.r that is saved in a directory C:\Programs\RLanguage\Rob\. I run the script in the following way:
	source("C:/Programs/RLanguage/Rob/myProg.r")

This works fine, but I was wondering if there is any command that could be entered into the .First function described above that adds the directory C:\Programs\RLanguage\Rob\ to the R path. This way, C:\Programs\RLanguage\Rob\ will always be checked for the code and I could simply run myProg.r as follows:
	source("myProg.r")

3) Is there anyway that I could save functions that I have written outside of R. That is, could I write functions and have them saved in some directory, such as, C:\Programs\RLanguage\RobFunctions\? This way I would be able to copy the functions to other pcs. This is very simple in MatLab. Please let me know.

Thanks for the help.


Rob




More information about the R-help mailing list