Dear All, I am new to R and can see it is a very powerful and versatile system for programming and statistical analysis. Say I have written a simple function and want to use it on a regular basis. I have the file as a text file say 'c:\R-funcs\func.txt' how do I get R to find it on the hard disc or alternatively where is the default location for looking up functions where I can place this file. eg where are functions such as var(), mean() etc stored? At the moment I'm pasting the text of the function into the GUI prompt, not very satisfactory if it is to be used in a programme. Please forgive any naivety on my part as I am just starting out Many thanks in advance Guy ---------------------------------------------------------------------- Guy J. Forrester Phone: 01453 860777 CSL Research Unit Fax: 01453 860132 Woodchester Park e-mail: g.forrester at csl.gov.uk Nymsfield Stonehouse Gloucestershire GL10 3UJ http://www.csl.gov.uk ---------------------------------------------------------------------- Disclaimer The information contained in this message may include privileged, proprietary or confidential information. Please treat it with the same respect that you would expect for your own information. If you have received it in error, we apologise, and ask that you contact the CSL sender immediately and erase it from your computer. Thank you for your co-operation. Further information on confidentiality of our communications, can be found at http://www.csl.gov.uk/email.htm -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 27 May 2002, Guy Forrester wrote: %Dear All, % %I am new to R and can see it is a very powerful and versatile system for %programming and statistical analysis. % %Say I have written a simple function and want to use it on a regular %basis. I have the file as a text file say 'c:\R-funcs\func.txt' how do I %get R to find it on the hard disc or alternatively where is the default %location for looking up functions where I can place this file. eg where %are functions such as var(), mean() etc stored? % %At the moment I'm pasting the text of the function into the GUI prompt, %not very satisfactory if it is to be used in a programme. maybe R>source("path/to/text/file") does the trick? % %Please forgive any naivety on my part as I am just starting out % %Many thanks in advance % %Guy % % %---------------------------------------------------------------------- %Guy J. Forrester Phone: 01453 860777 %CSL Research Unit Fax: 01453 860132 %Woodchester Park e-mail: g.forrester at csl.gov.uk %Nymsfield %Stonehouse %Gloucestershire %GL10 3UJ http://www.csl.gov.uk %---------------------------------------------------------------------- % %Disclaimer %The information contained in this message may include privileged, %proprietary or confidential information. Please treat it with the same %respect that you would expect for your own information. If you have %received it in error, we apologise, and ask that you contact the CSL %sender immediately and erase it from your computer. Thank you for your %co-operation. % %Further information on confidentiality of our communications, can be %found at http://www.csl.gov.uk/email.htm %-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- %r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html %Send "info", "help", or "[un]subscribe" %(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch %_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ % *********************************************************************** Jens Nieschulze Institute for Forest Biometrics & Phone: ++49-551-39-12107 Applied Computer Science Fax : ++49-551-39-3465 Buesgenweg 4 37077 Goettingen E-mail: jniesch at uni-forst.gwdg.de GERMANY http://www.uni-forst.gwdg.de/~jniesch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 27 May 2002, Guy Forrester wrote:> Dear All, > > I am new to R and can see it is a very powerful and versatile system for > programming and statistical analysis. > > Say I have written a simple function and want to use it on a regular > basis. I have the file as a text file say 'c:\R-funcs\func.txt' how do I > get R to find it on the hard discsource("c:\\R-funcs\\func.txt") (or replace \\ by /).> or alternatively where is the default > location for looking up functions where I can place this file. eg where > are functions such as var(), mean() etc stored?In packages, and the best way of all would be to create a small package containing your functions. They you can use library(mypackage) to make them available. But creating a package on Windows is not for absolute beginners.> At the moment I'm pasting the text of the function into the GUI prompt, > not very satisfactory if it is to be used in a programme. > > Please forgive any naivety on my part as I am just starting out > > Many thanks in advance > > Guy > > > ---------------------------------------------------------------------- > Guy J. Forrester Phone: 01453 860777 > CSL Research Unit Fax: 01453 860132 > Woodchester Park e-mail: g.forrester at csl.gov.uk > Nymsfield > Stonehouse > Gloucestershire > GL10 3UJ http://www.csl.gov.uk > ---------------------------------------------------------------------- > > Disclaimer > The information contained in this message may include privileged, > proprietary or confidential information. Please treat it with the same > respect that you would expect for your own information. If you have > received it in error, we apologise, and ask that you contact the CSL > sender immediately and erase it from your computer. Thank you for your > co-operation. > > Further information on confidentiality of our communications, can be > found at http://www.csl.gov.uk/email.htm > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> maybe > R>source("path/to/text/file") > does the trick?Yes, and if you want to make this automatic, then put the command in your .Rprofile file. Ole -- Ole F. Christensen Department of Mathematics and Statistics Fylde College, Lancaster University Lancaster, LA1 4YF, England -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._