Test for default stringsAsFactors and complain if TRUE

This commit is contained in:
hyginn 2020-09-18 08:48:19 +10:00
parent 599f8a3f98
commit 89bdd14d1c

View File

@ -1,14 +1,50 @@
# .Rprofile
#
# This script is automatically executed on startup
# ==============================================================================
init <- function() {
source(".init.R")
# Create a local copy of myScript.R if required, and not been done yet.
if (! file.exists("myScript.R") && file.exists(".tmp.R")) {
file.copy(".tmp.R", "myScript.R")
cat("A new file \"myScript.R\" was created. You can use it for\n")
cat("notes and code experiments.\n\n")
}
cat("\n\n")
cat("Please open the file \".myProfile.r\" (click on the file-name in the\n")
cat("\"files\" pane), edit it, and save it into the \"myScripts\" folder.\n\n")
file.edit("ABC-units.R")
return(invisible(NULL))
}
cat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
cat(" =================")
cat("\n\n")
cat(" WELCOME !\n")
cat("\n")
cat(" Type 'init()' to begin\n\n")
cat("\n")
cat(" =================")
cat("\n\n")
if (! file.exists("./myScripts/.myProfile.R")) {
cat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
cat(" =================")
cat("\n\n")
cat(" WELCOME !\n")
cat("\n")
cat(" Type 'init()' to begin\n\n")
cat("\n")
cat(" =================")
cat("\n\n")
} else {
cat("\n\nLoading local functions ...")
source("./myScripts/.myProfile.R")
source(".utilities.R")
cat("... done.\n\n")
}
if (default.stringsAsFactors()) {
cat("WARNING.\n")
cat("========\n")
cat("Your default \"stringsAsFactors\" parameter is set to \"TRUE\".\n")
cat("This will break some of the code.\n")
cat("Please contact your instructor to troubleshoot and fix this issue.\n")
cat("\n")
}
# [END]