Hello, I have a R-script, R1, that contains some variables and some R-functions. I want to include/require this script into another R-script, R2, so that I can access the the variables and functions that are inside script R1 in script R2. Is this possible? Script R1 could for example contain information about database connections, paths etc. that would be used in several R scripts. I do not want to change all my R-scripts every time I change the password of my database for example! Regards, Rik -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Rik Bradt wrote:> > Hello, > > I have a R-script, R1, that contains some variables and some R-functions. > I want to include/require this script into another R-script, R2, so that I > can access the the variables and functions that are inside script R1 in > script R2. > > Is this possible? > > Script R1 could for example contain information about database > connections, paths etc. > that would be used in several R scripts. I do not want to change all my > R-scripts > every time I change the password of my database for example!I don't know if I understand your question correctly, but I think source() should do the job. Or maybe better: Make a package of the objects in "R1". Then you can use library(R1) in your script R2. Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Rik Bradt <rik.bradt at cropdesign.com> writes:>Hello, > >I have a R-script, R1, that contains some variables and some R-functions. >I want to include/require this script into another R-script, R2, so that I >can access the the variables and functions that are inside script R1 in >script R2. > >Is this possible?You can use source() to load (e.g.) the R1 script in another script. Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> Hello,<br> <br> thanks for the good suggestion. This is indeed what I was looking for:<br> As an example:<br> <br> R1.R<br> a <- 1:10<br> <br> R2.R<br> source("R2.R")<br> a<br> <br> Gives the result, using my typical self-compiled installation of R 1.4.0:<br> <br> <pre>user@host:~> /opt/R-1.4.0/lib/R/bin/R.bin --vanilla < R2.R<br><br>R : Copyright 2001, The R Development Core Team<br>Version 1.4.0 (2001-12-19)<br>...<br>Type `demo()'' for some demos, `help()'' for on-line help, or<br>`help.start()'' for a HTML browser interface to help.<br>Type `q()'' to quit R.<br><br>> source("R1.R")<br>> a<br> [1] 1 2 3 4 5 6 7 8 9 10<br>><br>user@host:~></pre> Regards,<br> <br> Rik<br> <br> Uwe Ligges wrote:<br> <blockquote type="cite" cite="mid3CB336EA.F28E3835@statistik.uni-dortmund.de"> <pre wrap="">Rik Bradt wrote:<br></pre> <blockquote type="cite"> <pre wrap="">Hello,<br><br>I have a R-script, R1, that contains some variables and some R-functions.<br>I want to include/require this script into another R-script, R2, so that I<br>can access the the variables and functions that are inside script R1 in<br>script R2.<br><br>Is this possible?<br><br>Script R1 could for example contain information about database<br>connections, paths etc.<br>that would be used in several R scripts. I do not want to change all my<br>R-scripts<br>every time I change the password of my database for example!<br></pre> </blockquote> <pre wrap=""><!----><br>I don''t know if I understand your question correctly, but I think<br>source() should do the job.<br><br>Or maybe better: Make a package of the objects in "R1". Then you can use<br>library(R1) in your script R2.<br><br>Uwe Ligges<br></pre> </blockquote> </body> </html> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._