From 9603fbede81dc3985c3b4e746238090385640c8f Mon Sep 17 00:00:00 2001 From: hyginn Date: Mon, 4 Oct 2021 22:53:06 +0200 Subject: [PATCH] Add troubleshooting hints via errText[[...]] --- .Rprofile | 35 +++++++++++++++++++++++++++++++++++ BIN-MYSPE.R | 26 ++++++++++++++------------ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/.Rprofile b/.Rprofile index 1412da4..e958186 100644 --- a/.Rprofile +++ b/.Rprofile @@ -91,4 +91,39 @@ if (default.stringsAsFactors()) { cat("\n") } +errText <- list() +errText[["noProfileFile"]] <- ' +Your PROFILE FILE does not exist. This problem must be fixed to continue. + + The code expects the file "./myScripts/.myProfile.R" to exist and to + contain your correct eMail address and student number. Detailed + instructions were given when you first ran the init() command. + + Try running init() again and follow the instructions. Reload youR RStudio + session and start over with this file. + + If this does not fix the problem, ask for help. +' + +errText[["noStudentNumber"]] <- ' +Your STUDENT NUMBER has not been defined. This problem must be fixed to continue. + + The code expects the file "./myScripts/.myProfile.R" to exist and to + contain your correct eMail address and student number. This file gets + sourced when you start a new R-session, but since you see this error + message there was a problem. + + Perhaps you need to restart your R-session. Try closing the RStudio + project and reopening it from the File > Recent Projects menu. + + Perhaps there was a syntax error in your file. Then not all the + instructions in the file are executed. Check the file: is your + email perhpas not defined? Or did you type it without qwuoataion + marks? + + Try fixing problems, and then restart R as described above. + + If none of this fixes the problem, ask for help. +' + # [END] diff --git a/BIN-MYSPE.R b/BIN-MYSPE.R index 4a72d75..7abe397 100644 --- a/BIN-MYSPE.R +++ b/BIN-MYSPE.R @@ -4,11 +4,12 @@ # R code accompanying the BIN-MYSPE unit # # -# Version: 1.3 +# Version: 1.4 # -# Date: 2017-09 - 2021-09 +# Date: 2017-09 - 2021-10 # Author: Boris Steipe (boris.steipe@utoronto.ca) # +# V 1.4 Add troubleshooting hints via errText[[...]] # V 1.3 2021 update of MYSPE mechanics; fix a bug no one had complained about # V 1.2 Reorganized proportional plot section into a "further reading" # section, added nested-box, and sankey plot visualization of @@ -36,14 +37,14 @@ #TOC> #TOC> Section Title Line #TOC> ----------------------------------------------------------------- -#TOC> 1 PREPARATIONS 51 -#TOC> 2 SUITABLE MYSPE SPECIES 63 -#TOC> 3 ADOPT "MYSPE" 87 -#TOC> 4 FURTHER READING: PLOTTING PROPORTIONS 126 -#TOC> 4.1 Percentages 144 -#TOC> 4.2 Visualizing proportions: Pie chart 163 -#TOC> 4.3 Visualizing proportions: Nested squares 241 -#TOC> 4.4 Visualizing proportions: Sankey diagrams 278 +#TOC> 1 PREPARATIONS 52 +#TOC> 2 SUITABLE MYSPE SPECIES 65 +#TOC> 3 ADOPT "MYSPE" 89 +#TOC> 4 FURTHER READING: PLOTTING PROPORTIONS 128 +#TOC> 4.1 Percentages 146 +#TOC> 4.2 Visualizing proportions: Pie chart 165 +#TOC> 4.3 Visualizing proportions: Nested squares 243 +#TOC> 4.4 Visualizing proportions: Sankey diagrams 280 #TOC> #TOC> ========================================================================== @@ -53,10 +54,11 @@ # Execute the two conditionals below: if (! file.exists("./myScripts/.myProfile.R")) { - stop("PANIC: profile file does not exist. Fix problem or ask for help.") + stop(errText[["noProfileFile"]]) # message defined in .Rprofile } + if (! exists("myStudentNumber")) { - stop("PANIC: profile data wasn't loaded. Fix problem or ask for help.") + stop(errText[["noStudentNumber"]]) # message defined in .Rprofile }