R-alpha: R initialization files

Friedrich Leisch (Friedrich.Leisch@ci.tuwien.ac.at)
Tue, 19 Nov 1996 17:35:43 +0100


Date: Tue, 19 Nov 1996 17:35:43 +0100
Message-Id: <199611191635.RAA10047@galadriel.ci.tuwien.ac.at>
From: Friedrich Leisch <Friedrich.Leisch@ci.tuwien.ac.at>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: R initialization files

-----BEGIN PGP SIGNED MESSAGE-----


Hi,

I have patched R such that it sources two alternative init files:

	~/.Rprofile

of if this does not exist

	$RHOME/library/Rprofile


I was simply tired of typing the same library(...) commands all the
time. E.g., my .Rprofile looks like


	options(prompt = "R> ")
	library("mylib1")
	library("mylib2")


Regards,
Fritz

- -- 
=======================================================================
                          Friedrich  Leisch                             
 Institut für Statistik                        Tel: (+43 1) 58801 4541
 Technische Universität Wien          	       Fax: (+43 1)  504 14 98
 Wiedner Hauptstraße 8-10/1071        Friedrich.Leisch@ci.tuwien.ac.at
 A-1040 Wien, Austria               http://www.ci.tuwien.ac.at/~leisch
       PGP public key http://www.ci.tuwien.ac.at/~leisch/pgp.key
=======================================================================

*** src/include/Defn.h.orig	Tue Oct 29 22:29:20 1996
- --- src/include/Defn.h	Tue Nov 19 16:31:04 1996
*************** int nrows(SEXP);
*** 528,533 ****
- --- 528,536 ----
  SEXP nthcdr(SEXP, int);
  void onintr();
  FILE* R_OpenLibraryFile();
+ #ifdef Unix
+ FILE* R_OpenInitFile(void);
+ #endif
  SEXP parse(FILE*, int);
  int pmatch(SEXP, SEXP, int);
  void PrintDefaults(void);
*** src/main/main.c.orig	Tue Oct 29 22:29:52 1996
- --- src/main/main.c	Tue Nov 19 16:30:12 1996
*************** void mainloop()
*** 264,269 ****
- --- 264,283 ----
  		R_Repl(R_GlobalEnv, 0, 0);
  	}
  
+ #ifdef Unix	
+ 		/* This is where we try to load the user's or the */
+ 		/* system-wide init file. */
+ 
+ 	R_Console = 0;
+ 	R_Inputfile = R_OpenInitFile();
+ 	if(R_Inputfile != NULL) {
+ 		setjmp(R_Toplevel.cjmpbuf);
+ 		R_GlobalContext = R_ToplevelContext = &R_Toplevel;
+ 		signal(SIGINT, onintr);
+ 		R_Repl(R_GlobalEnv, 0, 0);
+ 	}	
+ #endif
+ 
  		/* This is where we try to load a user's */
  		/* saved data.  The right thing to do here */
  		/* is very platform dependent.  E.g. Under */
*** src/unix/system.c.orig	Tue Oct 29 22:30:29 1996
- --- src/unix/system.c	Tue Nov 19 16:44:20 1996
*************** FILE *R_OpenLibraryFile(char *file)
*** 151,156 ****
- --- 151,176 ----
  	return fp;
  }
  
+ FILE *R_OpenInitFile(void)
+ {
+ 	char buf[256], *home;
+ 	FILE *fp;
+ 
+ 	fp=NULL;
+ 	
+ 	home = getenv("HOME");
+ 	sprintf(buf, "%s/.Rprofile", home);
+ 	fp = fopen(buf, "r");
+ 
+ 	if(fp==NULL) {
+ 	  home = getenv("RHOME");
+ 	  sprintf(buf, "%s/library/Rprofile", home);
+ 	  fp = fopen(buf,"r");
+ 	}
+ 	
+ 	return fp;
+ }
+ 
  
  	/*--- I n i t i a l i z a t i o n    C o d e ---*/
  

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBMpHhz4oPd9s9srglAQE1ggP8DfViTFF4ReGbF8x7Y298o43FntB4lDJ+
KOZJl2SIFvouP4bDp5SBudEQ++eUvsd2HhLn30GwXr/LINjFZsjZ4QEMYhyH4W1A
7z2tWTVKkirwFuNObRrT4uheJxmjFyW7KfklcGuICWmpik1CQdcV3Y4WcvZ4yj7K
TpiS3Qzdscs=
=FvPT
-----END PGP SIGNATURE-----
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-