autoInclude.fname <- paste( Sys.getenv("R_USER"), "/.Rprofile", sep="" ) autoInclude.fname <- gsub("\\\\", "/", autoInclude.fname) cat( "#script below are automatically executed on starting R ### Change this value to where you want to put the R functions ### ### e.g. change \"C:/\" to \"C:/Program Files/R/\" ### ### Path which includes Japanese characters is not permitted ### ### Use \"/\" (not \"\\\" or \"\\\\\") to separate the directory ### autoInclude.rdir <- \"C:/\" if(substring(autoInclude.rdir,nchar(autoInclude.rdir))!=\"/\") { \tautoInclude.rdir <- paste(autoInclude.rdir, \"/\", sep=\"\") } autoInclude.rnames <- list.files(autoInclude.rdir) autoInclude.n <- nchar(autoInclude.rnames) autoInclude.rnames <- autoInclude.rnames[toupper(substring(autoInclude.rnames, autoInclude.n-1))==\".R\"] if(length(autoInclude.rnames)==0) { \tcat(\"There was no R script file in \", autoInclude.rdir, \"\\n\\n\", sep=\"\") } else { \tinvisible(mapply( FUN=source, paste(autoInclude.rdir, autoInclude.rnames, sep=\"\") )) \tcat(\"These R script files were successfully included.\\n\") \tprint(autoInclude.rnames) \tcat(\"\\n\") } rm(list=paste(\"autoInclude.\", c(\"rdir\",\"rnames\",\"n\"), sep=\"\")) #See http://www7b.biglobe.ne.jp/~homunculus/r/autoInclude.html for detailed instruction in Japanese. #This file was created by autoInclude.R ver.1.00, written by MOCHI, 2009. ", file=autoInclude.fname ) #end of cat cat(" File named <.Rprofile> was successfully created. \t", autoInclude.fname, " In this file, please rewrite the value in the 7th row to where you want to put the R functions. The R script files in that directory will always be included when you start R. ", sep="") rm(list="autoInclude.fname")