├── inst ├── references.bib ├── Templates │ ├── EmptyChunk.Rmd │ ├── nNonMissing.R │ ├── GetLibs.Rmd │ ├── packages.R │ ├── GetData.Rmd │ ├── ResidualAnalysis.Rmd │ ├── Quade.Rmd │ ├── Dotplots.Rmd │ ├── simpleYAMLHeader.Rmd │ ├── DurbinWatson.Rmd │ ├── Boxplots.Rmd │ ├── Jarque.Rmd │ ├── YAMLHeader.Rmd │ ├── StandardSetupChunk.Rmd │ ├── Crossover2x2.R │ ├── DTGroupSummary.R │ ├── Manova.R │ ├── Anscombe.Rmd │ ├── Bonett.Rmd │ ├── Brewsch.Rmd │ ├── Agostino.Rmd │ ├── press.R │ ├── Bartlett.Rmd │ ├── Fligner.Rmd │ ├── CrossoverWith1Carry.R │ ├── TwoWay.Rmd │ ├── Levene.Rmd │ ├── ThreeWay.Rmd │ ├── CohensKappa.Rmd │ ├── GroupSummary.Rmd │ ├── ScatterPlot.Rmd │ ├── FittedLinePlot.Rmd │ ├── LatinSquare.Rmd │ ├── OneWayLM.Rmd │ ├── RCB.Rmd │ ├── RandomBlock.Rmd │ ├── EMMeans.Rmd │ ├── SplitPlot.Rmd │ ├── SerialCorrelation.Rmd │ ├── Linearity.Rmd │ ├── BasicSummaryStats.R │ ├── NonNested.Rmd │ ├── Heterogeneity.Rmd │ ├── Kruskal.Rmd │ ├── Friedman.Rmd │ ├── SimpleRegression.Rmd │ ├── PolyReg.Rmd │ ├── TukeyHSD.Rmd │ ├── Dunnett.Rmd │ ├── MDS.Rmd │ ├── ancova.Rmd │ ├── OneWayTest.Rmd │ ├── NormalityTests.Rmd │ └── PCA.Rmd ├── Sound │ └── Pips.wav ├── fonts │ ├── BRAILLE1.ttf │ └── BRAILLE1.txt ├── scripts │ └── UpdatePackages.R ├── Python │ ├── WriteR │ │ ├── nope.wav │ │ ├── __pycache__ │ │ │ ├── MyConsole.cpython-311.pyc │ │ │ ├── MyConsole.cpython-38.pyc │ │ │ ├── MathInserts.cpython-311.pyc │ │ │ ├── MathInserts.cpython-38.pyc │ │ │ ├── EditMenuEvents.cpython-311.pyc │ │ │ ├── EditMenuEvents.cpython-38.pyc │ │ │ ├── HelpMenuEvents.cpython-311.pyc │ │ │ ├── HelpMenuEvents.cpython-38.pyc │ │ │ ├── RMarkdownEvents.cpython-38.pyc │ │ │ └── RMarkdownEvents.cpython-311.pyc │ │ ├── Basics.Rmd │ │ ├── HelpMenuEvents.py │ │ ├── EditMenuEvents.py │ │ └── MyConsole.py │ ├── python38 │ │ ├── readme.txt │ │ ├── google.py │ │ ├── crlf.py │ │ ├── lfcr.py │ │ └── untabify.py │ ├── TestWX.py │ ├── FixLineBreaks.py │ └── RemoveTabs.py ├── whisker │ ├── Describe │ │ ├── Describedefault.txt │ │ ├── generics.txt │ │ └── baseR.txt │ └── SVG │ │ └── ViewSVG.html └── MyBrailleR │ ├── WriteROptions │ ├── foo.pandoc │ ├── AutoSpellList.csv │ ├── BrailleROptions │ └── css │ └── JGSlides.css ├── .github ├── .gitignore └── workflows │ ├── pkgdown.yaml │ └── R-CMD-check.yaml ├── .gitignore ├── R ├── Quarto.R ├── nNonMissing.R ├── Require.R ├── WhichFile.R ├── RemoveBOM.R ├── WhatIs.R ├── PandocAll.R ├── MakeAllFormats.R ├── NonMethodFunctions.R ├── AutoSpellCheck.R ├── MakeRprofile.R ├── FindReplace.R ├── GetWriteR.R ├── PrepareWriteR.R ├── CleanCSV.R ├── history.R ├── latest.R ├── JoinBlindRUG.R ├── Premier100.R ├── R2txtExtraJG.R ├── ProcessAll.R ├── Rnw2Rmd.R ├── NewFunction.R ├── WinGet.R ├── MaskedFunctions.R ├── ViewSVG.R ├── notepad.R ├── GetExampleText.R ├── DataViewer.R ├── BRLThis.R ├── WriteR.R ├── UpdateGraph.R ├── BrailleRUsefulLinks.R ├── MakeQmdFiles.R ├── MakeRmdFiles.R ├── Callback.R ├── GettingStarted.R ├── SpellCheckFiles.R ├── BaseGraphics.R ├── TSPlot.R ├── WhereXY.R ├── MakeAccessibleSVGMethod.R ├── Stop.R ├── zzz.R ├── dotplots.R ├── UseTemplate.R ├── MakeReadable.R ├── TextStrings.R ├── GetPython.R └── BrowseSVG.R ├── tests └── spelling.R ├── .Rbuildignore ├── man ├── Require.Rd ├── WTF.Rd ├── CleanCSV.Rd ├── Internal.Rd ├── AutoSpellCheck.Rd ├── MakeReadable.Rd ├── SetupBrailleR.Rd ├── MakeRprofile.Rd ├── Deprecated.Rd ├── SpellCheck.Rd ├── PandocAll.Rd ├── notepad.Rd ├── MakeAllFormats.Rd ├── Embossers.Rd ├── NewFunction.Rd ├── sort.VIgraph.Rd ├── pdf2html.Rd ├── JoinBlindRUG.Rd ├── SessionLog.Rd ├── GetGoing.Rd ├── AugmentMethod.Rd ├── BRLThis.Rd ├── WhichFile.Rd ├── WhatIs.Rd ├── BrailleRUsefulLinks.Rd ├── BrailleR-package.Rd ├── history.Rd ├── summary.recordedplot.Rd ├── Options.Rd ├── WhereXY.Rd ├── unfinished.Rd ├── dotplot.Rd ├── GetWriteR.Rd ├── grep.VIgraph.Rd ├── FindReplace.Rd ├── UpdateGraph.Rd ├── GetExampleText.Rd ├── SpellCheckFiles.Rd ├── PrepareWriteR.Rd ├── MakeRmdFiles.Rd ├── ViewSVG.Rd ├── DataViewer.Rd ├── hist.Rd ├── AddXMLMethod.Rd ├── ThreeFactors.Rd ├── BrowseSVG.Rd ├── Describe.Rd ├── OnePredictor.Rd ├── ScatterPlot.Rd ├── TwoFactors.Rd └── boxplot.Rd ├── po └── R-BrailleR.pot ├── cran-comments.md ├── vignettes ├── Ex2BasicNumerical.rmd ├── Ex4SingleResponseOneGroupingFactor.rmd └── Ex3UnivariateDescription.rmd ├── _pkgdown.yml └── .pre-commit-config.yaml /inst/references.bib: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /inst/Templates/EmptyChunk.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| label = "ChunkName" 3 | ... 4 | ``` 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | docs 3 | .Rhistory 4 | .RData 5 | BrailleR.Rproj 6 | .Rproj.user 7 | -------------------------------------------------------------------------------- /inst/Sound/Pips.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Sound/Pips.wav -------------------------------------------------------------------------------- /inst/fonts/BRAILLE1.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/fonts/BRAILLE1.ttf -------------------------------------------------------------------------------- /R/Quarto.R: -------------------------------------------------------------------------------- 1 | 2 | # add commands to launch QuartoWriter 3 | 4 | # add commands to create Qmd batch files 5 | -------------------------------------------------------------------------------- /inst/scripts/UpdatePackages.R: -------------------------------------------------------------------------------- 1 | chooseCRANmirror(ind=1) 2 | update.packages(ask=FALSE, binary=TRUE) 3 | 4 | -------------------------------------------------------------------------------- /inst/Python/WriteR/nope.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/nope.wav -------------------------------------------------------------------------------- /inst/Python/python38/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/python38/readme.txt -------------------------------------------------------------------------------- /R/nNonMissing.R: -------------------------------------------------------------------------------- 1 | 2 | nNonMissing = function(x){ 3 | length(na.omit(x)) # because length() alone would include NAs 4 | } 5 | -------------------------------------------------------------------------------- /inst/Templates/nNonMissing.R: -------------------------------------------------------------------------------- 1 | nNonMissing = function(x){ 2 | length(na.omit(x)) # because length() alone would include NAs 3 | } 4 | -------------------------------------------------------------------------------- /inst/whisker/Describe/Describedefault.txt: -------------------------------------------------------------------------------- 1 | {{title}} 2 | 3 | General Description: 4 | {{general}} 5 | 6 | R hints: 7 | {{RHints}} 8 | -------------------------------------------------------------------------------- /inst/MyBrailleR/WriteROptions: -------------------------------------------------------------------------------- 1 | lastdir: . 2 | newText: Use WriteR to edit your R markdown files, perhaps by starting from a template file 3 | -------------------------------------------------------------------------------- /inst/Templates/GetLibs.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| label = "getLibs", 3 | #| include = FALSE 4 | library(tidyverse) 5 | library({{PkgName}}) 6 | ``` 7 | 8 | -------------------------------------------------------------------------------- /inst/Templates/packages.R: -------------------------------------------------------------------------------- 1 | for(pkg in pkgList){ 2 | if(!do.call(require, list(pkg))) install.packages(pkg) 3 | do.call(library, list(pkg)) 4 | } 5 | -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/MyConsole.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/MyConsole.cpython-311.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/MyConsole.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/MyConsole.cpython-38.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/MathInserts.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/MathInserts.cpython-311.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/MathInserts.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/MathInserts.cpython-38.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/EditMenuEvents.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/EditMenuEvents.cpython-311.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/EditMenuEvents.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/EditMenuEvents.cpython-38.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/HelpMenuEvents.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/HelpMenuEvents.cpython-311.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/HelpMenuEvents.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/HelpMenuEvents.cpython-38.pyc -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/RMarkdownEvents.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/RMarkdownEvents.cpython-38.pyc -------------------------------------------------------------------------------- /inst/Templates/GetData.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "get{{DataName}}" 4 | {{DataName}} = read.csv("{{FileName}}", stringsAsFactors = TRUE) |> mutate() |> glimpse() 5 | ``` 6 | -------------------------------------------------------------------------------- /inst/Python/WriteR/__pycache__/RMarkdownEvents.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajrgodfrey/BrailleR/HEAD/inst/Python/WriteR/__pycache__/RMarkdownEvents.cpython-311.pyc -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if(requireNamespace('spelling', quietly = TRUE)) 2 | spelling::spell_check_test(vignettes = TRUE, error = FALSE, 3 | skip_on_cran = TRUE) 4 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^CONDUCT\.md$ 3 | ^\.Rproj\.user$ 4 | ^\.github$ 5 | ^\.pre-commit-config\.yaml$ 6 | ^_pkgdown\.yml$ 7 | ^cran-comments\.md$ 8 | ^docs$ 9 | ^pkgdown$ 10 | ^readme.md$ 11 | -------------------------------------------------------------------------------- /inst/Python/TestWX.py: -------------------------------------------------------------------------------- 1 | import wx 2 | app = wx.App(False) 3 | frame = wx.Frame(None, wx.ID_ANY, "It looks like the WX module is available. Close this window and start WriteR") 4 | frame.Show(True) 5 | app.MainLoop() 6 | -------------------------------------------------------------------------------- /inst/Templates/ResidualAnalysis.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "plot{{ModelName}}", 4 | #| fig.cap = "Residual analysis for {{ModelName}}." 5 | library(ggfortify) 6 | {{ModelName}} |> autoplot() 7 | ``` 8 | 9 | 10 | -------------------------------------------------------------------------------- /inst/Templates/Quade.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Quade test with unreplicated blocked data 3 | 4 | ```{r} 5 | #| label = "{{DataName}}.qt" 6 | {{DataName}}.qt = quade.test({{ResponseName}} ~ {{FactorName}} | {{BlockingName}}, data = {{DataName}}) 7 | ``` 8 | 9 | -------------------------------------------------------------------------------- /inst/Templates/Dotplots.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}Dotplots", 4 | #| fig.cap = "Plots for {{ResponseName}} grouped by {{FactorName}}." 5 | {{DataName}} |> ggplot(aes(y={{ResponseName}}, x={{FactorName)}}) + geom_point() 6 | ``` 7 | -------------------------------------------------------------------------------- /inst/Templates/simpleYAMLHeader.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "" 3 | author: "" 4 | date: "" 5 | output: 6 | html_document: 7 | toc: false 8 | number_sections: false 9 | fig_height: 5 10 | fig_width: 7 11 | --- 12 | -------------------------------------------------------------------------------- /inst/Templates/DurbinWatson.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Durbin-Watson Test 3 | 4 | 5 | ```{r} 6 | #| label = "GetLMTestPkg" 7 | library(lmtest) 8 | ``` 9 | 10 | ```{r} 11 | #| label = "{{DataName}}.dw" 12 | {{DataName}}.dw = {{DataName}}.lm |> dwtest() 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /inst/Templates/Boxplots.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}Boxplots", 4 | #| fig.cap = "Comparative boxplots for {{ResponseName}} grouped by 5 | #| {{FactorName}}." 6 | {{DataName}} |> ggplot(aes(y={{ResponseName}}, x={{FactorName}})) + geom_boxplot() 7 | ``` 8 | -------------------------------------------------------------------------------- /inst/Templates/Jarque.Rmd: -------------------------------------------------------------------------------- 1 | ## Jarque-Bera test for normality 2 | 3 | ```{r} 4 | #| label = "GetMomentsPkg" 5 | library(moments) 6 | ``` 7 | 8 | ```{r} 9 | #| label = "{{ResponseName}}.jbt" 10 | {{ResponseName}}.jbt = {{ResponseName}} |> jarque.test() 11 | ``` 12 | -------------------------------------------------------------------------------- /inst/Templates/YAMLHeader.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "" 3 | author: "" 4 | date: "" 5 | output: 6 | html_document: 7 | toc: false 8 | number_sections: false 9 | css: my_style.css 10 | fig_height: 7 11 | fig_width: 7 12 | --- 13 | -------------------------------------------------------------------------------- /inst/Templates/StandardSetupChunk.Rmd: -------------------------------------------------------------------------------- 1 | ```{r} 2 | #| label = "setup", 3 | #| purl = FALSE, 4 | #| include = FALSE 5 | library(knitr) 6 | opts_chunk$set(dev=c("png", "pdf", "postscript", "svg")) 7 | opts_chunk$set(comment="", echo=FALSE, fig.path="FolderName/FileStem", fig.width=7) 8 | ``` 9 | -------------------------------------------------------------------------------- /inst/Templates/Crossover2x2.R: -------------------------------------------------------------------------------- 1 | DataName.aov1 <- aov(ResponseName ~ SubjectName + PeriodName + TreatmentName, data=DataName) 2 | summary(DataName.aov <- aov(ResponseName ~ GroupName + PeriodName + TreatmentName + Error(SubjectName), data=DataName)) 3 | par(mfrow=c(2,2)) 4 | plot(DataName.aov1) 5 | -------------------------------------------------------------------------------- /inst/Templates/DTGroupSummary.R: -------------------------------------------------------------------------------- 1 | require(data.table) 2 | DataSummary = as.data.table(DataName)[, list(Mean = mean(ResponseName, na.rm=T), StdDev = sd(ResponseName, na.rm=T), N=sum(!is.na(ResponseName)) ), FactorSet] 3 | DataSummary$"Standard Error" = DataSummary$StdDev/sqrt(DataSummary$N) 4 | 5 | -------------------------------------------------------------------------------- /inst/Templates/Manova.R: -------------------------------------------------------------------------------- 1 | DataName.maov <- manova(ResponseMatrix ~ FactorNames, data=DataName) 2 | summary(DataName.maov, test="Wilks") 3 | summary(DataName.maov, test="Roy") 4 | summary(DataName.maov, test="Hotelling-Lawley") 5 | summary(DataName.maov, test="Pillai") 6 | summary.aov(DataName.maov) 7 | -------------------------------------------------------------------------------- /inst/Templates/Anscombe.Rmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Anscombe-Glynn test of kurtosis for normal samples 4 | 5 | ```{r} 6 | #| label = "GetMomentsPkg" 7 | library(moments) 8 | ``` 9 | 10 | ```{r} 11 | #| label = "{{ResponseName}}.agt" 12 | {{ResponseName}}.agt = {{ResponseName}} |> anscombe.test() 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /inst/MyBrailleR/foo.pandoc: -------------------------------------------------------------------------------- 1 | s: 2 | number-sections: 3 | bibliography: foo.bib 4 | toc: 5 | 6 | t: html5 7 | mathjax: 8 | o: foo_MathJax.html 9 | 10 | t: html 11 | webtex: 12 | o: foo_WebTeX.html 13 | 14 | t: latex 15 | no-tex-ligatures: 16 | o: foo.pdf 17 | 18 | t: docx 19 | mathml: 20 | o: foo.docx 21 | -------------------------------------------------------------------------------- /inst/Templates/Bonett.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Bonett-Seier test of Geary's measure of kurtosis for normally distributed data. 3 | 4 | ```{r} 5 | #| label = "GetMomentsPkg" 6 | library(moments) 7 | ``` 8 | 9 | ```{r} 10 | #| label = "{{ResponseName}}.bt" 11 | {{ResponseName}}.bt = {{ResponseName}} |> bonet.test() 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /inst/Templates/Brewsch.Rmd: -------------------------------------------------------------------------------- 1 | ## Breusch-Godfrey Test 2 | 3 | Description: Tests for higher-order serial correlation. 4 | 5 | 6 | ```{r} 7 | #| label = "GetLibLMTestPkg" 8 | library(lmtest) 9 | ``` 10 | 11 | ```{r} 12 | #| label = "{{DataName}}.bg" 13 | {{DataName}}.bg = {{DataName}}.lm |> bgtest() 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /inst/Templates/Agostino.Rmd: -------------------------------------------------------------------------------- 1 | ## D'Agostino test for skewness in normally distributed data. 2 | 3 | ```{r} 4 | #| label = "GetMomentsPkg" 5 | library(moments) 6 | ``` 7 | 8 | ```{r} 9 | #| label = "{{ResponseName}}.at" 10 | {{ResponseName}}.at = {{ResponseName}} |> agostino.test() 11 | {{ResponseName}}.at 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /inst/Templates/press.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PRESS <- function(LinearModel) { 5 | return(sum((residuals(LinearModel)/(1 - lm.influence(LinearModel)$hat))^2)) 6 | } 7 | 8 | 9 | 10 | PredRSquared <- function(LinearModel) { 11 | TSS <- sum(anova(LinearModel)$"Sum Sq") 12 | return(1 - PRESS(LinearModel)/TSS) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /inst/Templates/Bartlett.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Bartlett Test of Homogeneity of Variances 3 | 4 | Description: Performs Bartlett's test of the null hypothesis that the variances in each of the groups (samples) are the same. 5 | 6 | ```{r} 7 | #| label = "{{DataName}}BartlettTest" 8 | bartlett.test({{ResponseName}} ~ {{FactorName}}, data = {{DataName}}) 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /R/Require.R: -------------------------------------------------------------------------------- 1 | 2 | Require = function(pkg){ 3 | pkg = as.character(substitute(pkg)) 4 | if(!suppressPackageStartupMessages(base::require(pkg, character.only=TRUE, warn.conflicts=FALSE))){ 5 | utils::chooseCRANmirror(ind=1) 6 | utils::install.packages(pkg) 7 | } 8 | suppressPackageStartupMessages(base::require(pkg, character.only=TRUE, warn.conflicts=FALSE)) 9 | } 10 | -------------------------------------------------------------------------------- /inst/Python/WriteR/Basics.Rmd: -------------------------------------------------------------------------------- 1 | # this is a heading 2 | 3 | ## this is a level two heading 4 | 5 | Now it's time for some R 6 | ```{r no1} 7 | x=1:10 8 | mean(x) 9 | ``` 10 | 11 | 12 | We can also ask for stuff in line such as `r mean(x)` into our sentence. 13 | 14 | ```{r AHistogram, fig.cap="My first histogram"} 15 | hist(rnorm(1000)) 16 | ``` 17 | 18 | 19 | -------------------------------------------------------------------------------- /inst/Templates/Fligner.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Fligner-Killeen Test of Homogeneity of Variances 3 | 4 | Description: Performs a Fligner-Killeen (median) test of the null that the variances in each of the groups (samples) are the same. 5 | 6 | ```{r} 7 | #| label = "{{DataName}}.FlignerTest" 8 | fligner.test({{ResponseName}} ~ {{FactorName}}, data = {{DataName}}) 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /inst/Templates/CrossoverWith1Carry.R: -------------------------------------------------------------------------------- 1 | with(DataName, tapply(ResponseName, list(PeriodName, GroupName), mean)) 2 | 3 | summary(ResponseName.aov <- aov(ResponseName ~ GroupName + PeriodName + TreatName + Carry1Name + Error(SubjectName), data=DataName)) 4 | summary(ResponseName.aov <- aov(ResponseName ~ GroupName + PeriodName + Carry1Name + TreatName + Error(SubjectName), data=DataName)) 5 | -------------------------------------------------------------------------------- /inst/Templates/TwoWay.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lm" 4 | {{DataName}}.lm = lm({{ResponseName}} ~ {{Factor1Name}}*{{Factor2Name}}, data = {{DataName}}) 5 | {{DataName}}.lm |> anova() 6 | ``` 7 | 8 | 9 | ```{r} 10 | #| label = "plot{{DataName}}.lm", 11 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 12 | library(ggfortify) 13 | {{DataName}}.lm |> autoplot() 14 | ``` 15 | -------------------------------------------------------------------------------- /R/WhichFile.R: -------------------------------------------------------------------------------- 1 | 2 | WhichFile = function(String, Folder, fixed=TRUE, DoesExist=TRUE){ 3 | 4 | Files=list.files(path=Folder, recursive =TRUE, full.names =TRUE) 5 | Out="" 6 | for(i in Files){ 7 | 8 | Text = readLines(i) 9 | if(DoesExist){ 10 | if(any(grep(String, Text, fixed=fixed))) Out=c(Out,i)} 11 | else{ 12 | if(!any(grep(String, Text, fixed=fixed))) Out=c(Out,i)} 13 | } 14 | return(Out) 15 | } 16 | -------------------------------------------------------------------------------- /inst/Templates/Levene.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Levene's Test 3 | 4 | ```{r} 5 | #| label = "GetRStatixPkg" 6 | library(rstatix) 7 | ``` 8 | 9 | ```{r} 10 | #| label = "{{DataName}}.lt" 11 | {{DataName}}.lt = {{DataName}} |> levene_test({{ResponseName}} ~ {{FactorName}}) 12 | {{DataName}}.lt |> kable(caption="Levene's test for homogeneity of variance of {{ResponseName}} grouped by {{FactorName}}.") 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /inst/Templates/ThreeWay.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lm" 4 | {{DataName}}.lm = lm({{ResponseName}} ~ {{Factor1Name}}*{{Factor2Name}}*{{Factor3Name}}, data = {{DataName}}) 5 | {{DataName}}.lm |> anova() 6 | ``` 7 | 8 | 9 | ```{r} 10 | #| label = "plot{{DataName}}.lm", 11 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 12 | library(ggfortify) 13 | {{DataName}}.lm |> autoplot() 14 | ``` 15 | -------------------------------------------------------------------------------- /R/RemoveBOM.R: -------------------------------------------------------------------------------- 1 | RemoveBOM = function(file){ 2 | if (interactive()) { 3 | FileLines = readLines(file) 4 | Line1 = FileLines[1] 5 | 6 | if(nchar(Line1)==6 & nchar(strsplit(Line1,"---")) ==3){ 7 | FileLines[1] = "---" 8 | writeLines(FileLines, con=file) 9 | .Done() 10 | return(invisible(TRUE)) 11 | } 12 | } else { 13 | .InteractiveOnly() 14 | } 15 | return(invisible(TRUE)) 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /R/WhatIs.R: -------------------------------------------------------------------------------- 1 | ## N.B. The first function was created before glimpse() was working nicely for a screen reader user; 2 | ## it is somewhat redundant now, but kept for backwards compatibility 3 | 4 | check_it = CheckIt = function(x, ...){ 5 | dplyr::glimpse(x) 6 | return(x) 7 | } 8 | 9 | 10 | what_is = WhatIs = function(x, ...){ 11 | cat("\n") 12 | VI(x, ...) 13 | cat("\n") 14 | return( invisible(x)) 15 | } 16 | -------------------------------------------------------------------------------- /inst/Templates/CohensKappa.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Cohen's Kappa 3 | 4 | Description: calculates weighted and unweighted kappa statistics and their 95% confidence intervals. 5 | 6 | 7 | ```{r} 8 | #! label="GetVCDPkg" 9 | library(vcd) 10 | ``` 11 | 12 | 13 | ```{r} 14 | #! label = "{{DataName}}.K" 15 | {{DataName}}.K <- Kappa({{DataName}}) 16 | summary({{DataName}}.K) 17 | print({{DataName}}.K, CI = TRUE) 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /inst/MyBrailleR/AutoSpellList.csv: -------------------------------------------------------------------------------- 1 | OldString,NewString,Notes 2 | hte , the ,common typo 3 | t he , the ,dangerous 4 | ot , to ,common typo 5 | fi , if ,common typo 6 | os , so ,common typo 7 | si , is ,common typo 8 | oudl ,ould ,not an entire word 9 | htis , this ,common typo 10 | fo , of ,common typo 11 | nad , and ,common typo 12 | iwth,with,common typo 13 | htat , that ,common typo 14 | wnat , want ,common typo -------------------------------------------------------------------------------- /inst/Templates/GroupSummary.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "Desc{{DataName}}" 4 | {{DataName}} |> 5 | drop_na({{ResponseName}}) |> 6 | group_by({{FactorSet}}) |> 7 | summarise( 8 | Mean = mean({{ResponseName}}), 9 | StDev = sd({{ResponseName}}), 10 | Count = n() 11 | ) |> 12 | mutate(StdErr = StDev/sqrt(Count)) |> 13 | kable(caption="Descriptive statistics for {{ResponseName}} disaggregated by {{FactorSet}}.") 14 | ``` 15 | -------------------------------------------------------------------------------- /inst/Templates/ScatterPlot.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}Plot", 4 | #| fig.cap = "Plot of {{ResponseName}} versus {{PredictorName}} with smoother 5 | #| added." 6 | library(ggplot2) 7 | {{DataName}} |> select({{ResponseName}}, {{PredictorName}}) |> filter(!is.na({{ResponseName}}), !is.na({{PredictorName}})) |> 8 | ggplot(aes(y={{ResponseName}}, x={{PredictorName}})) + geom_point() + geom_smooth() 9 | ``` 10 | 11 | 12 | -------------------------------------------------------------------------------- /inst/Templates/FittedLinePlot.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}FittedLinePlot", 4 | #| fig.cap = "Plot of {{ResponseName}} versus {{PredictorName}} with fitted 5 | #| line added." 6 | library(ggplot2) 7 | {{DataName}} |> select({{ResponseName}}, {{PredictorName}}) |> filter(!is.na({{ResponseName}}), !is.na({{PredictorName}})) |> 8 | ggplot(aes(y={{ResponseName}}, x={{PredictorName}})) + geom_point() + geom_smooth(method="lm") 9 | ``` 10 | 11 | 12 | -------------------------------------------------------------------------------- /inst/MyBrailleR/BrailleROptions: -------------------------------------------------------------------------------- 1 | BrailleR.Author: BrailleR 2 | BrailleR.VI: TRUE 3 | BrailleR.Latex: TRUE 4 | BrailleR.Style: BrailleR.css 5 | BrailleR.SlideStyle: JGSlides.css 6 | BrailleR.SigLevel: 0.05 7 | BrailleR.PValDigits: 4 8 | BrailleR.DotplotBins: 6 9 | BrailleR.BRLFont: 10 | BrailleR.BRLPointSize: 29 11 | BrailleR.BRLFontInstalled: FALSE 12 | BrailleR.Embosser: none 13 | BrailleR.PaperWidth: 10 14 | BrailleR.PaperHeight: 10 15 | BrailleR.MakeUpper: TRUE 16 | -------------------------------------------------------------------------------- /R/PandocAll.R: -------------------------------------------------------------------------------- 1 | PandocAll = function(intype="docx", outtype="html"){ 2 | 3 | FileList=list.files(pattern=paste0(".",intype)) 4 | 5 | for(i in FileList){ 6 | Outfile = sub(paste0(".", intype), paste0(".", outtype), i) 7 | if(file.mtime(i) > file.mtime(Outfile)| !file.exists(Outfile)) { 8 | shell(paste0('pandoc -s "', i, '" -o "', Outfile, '"')) 9 | .FileUpdated(file=Outfile, where="in your current working directory.") 10 | } 11 | } 12 | return(invisible(TRUE)) 13 | } 14 | -------------------------------------------------------------------------------- /R/MakeAllFormats.R: -------------------------------------------------------------------------------- 1 | 2 | MakeAllFormats = 3 | function(RmdFile, BibFile = "") { 4 | Settings = readLines(system.file("Foo.pandoc", package = "BrailleR")) 5 | 6 | FullFile = unlist(strsplit(RmdFile, split = ".", fixed = TRUE))[1] 7 | # switch foo.bib to BibFile 8 | Settings = gsub("foo.bib", BibFile, Settings) 9 | 10 | # switch all Foo to RmdFile stem 11 | Settings = gsub("foo", FullFile, Settings) 12 | writeLines(Settings, con = paste0(FullFile, ".pandoc")) 13 | } 14 | -------------------------------------------------------------------------------- /inst/Templates/LatinSquare.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lm" 4 | {{DataName}}.lm = lm({{ResponseName}} ~ {{RowFactor}}+{{ColFactor}}+{{FactorName}}, data = {{DataName}}) 5 | {{DataName}}.lm |> anova() 6 | ``` 7 | 8 | 9 | ```{r} 10 | #| label = "plot{{DataName}}.lm", 11 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 12 | library(ggfortify) 13 | {{DataName}}.lm |> autoplot() 14 | ``` 15 | 16 | 17 | ```{GetMeans} 18 | library(emmeans) 19 | emmeans({{DataName}}.lm, pairwise ~{{FactorName}}) 20 | ``` 21 | -------------------------------------------------------------------------------- /inst/Templates/OneWayLM.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lm" 4 | {{DataName}}.lm = lm({{ResponseName}} ~ {{FactorName}}, data=DataName) 5 | library(broom) 6 | {{DataName}}.lm |> augment() 7 | {{DataName}}.lm |> anova() 8 | ``` 9 | 10 | ```{r} 11 | #| label = "glance{{DataName}}.lm" 12 | {{DataName}}.lm |> glance() |> kable() 13 | ``` 14 | 15 | ```{r} 16 | #| label = "plot{{DataName}}.lm", 17 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 18 | library(ggfortify) 19 | {{DataName}}.lm |> autoplot() 20 | ``` 21 | -------------------------------------------------------------------------------- /inst/Templates/RCB.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lm" 4 | {{DataName}}.lm = lm({{ResponseName}} ~ {{BlockingName}}+{{FactorName}}, data = {{DataName}}) 5 | library(broom) 6 | augment({{DataName}}.lm) 7 | anova({{DataName}}.lm) 8 | ``` 9 | 10 | ```{r} 11 | #| label = "glance{{DataName}}.lm" 12 | {{DataName}}.lm |> glance() |> kable() 13 | ``` 14 | 15 | ```{r} 16 | #| label = "plot{{DataName}}.lm", 17 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 18 | library(ggfortify) 19 | autoplot({{DataName}}.lm) 20 | ``` 21 | -------------------------------------------------------------------------------- /R/NonMethodFunctions.R: -------------------------------------------------------------------------------- 1 | 2 | VI.hist = 3 | function(...) { 4 | args = list(...) 5 | VI(hist(...)) 6 | if (!is.null(args$xlab)) { 7 | cat(paste("N.B. The default text for the x axis has been replaced by: ", 8 | args$xlab, "\n", sep = "")) 9 | cat("\n") 10 | } 11 | if (!is.null(args$ylab)) { 12 | cat(paste("N.B. The default text for the y axis has been replaced by: ", 13 | args$ylab, "\n", sep = "")) 14 | cat("\n") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /R/AutoSpellCheck.R: -------------------------------------------------------------------------------- 1 | 2 | AutoSpellCheck = 3 | function(file) { 4 | if (interactive()) { 5 | if (require(BrailleR)) { 6 | ChangeList = read.csv(paste0(getOption("BrailleR.Folder"), 7 | "AutoSpellList.csv")) 8 | for (i in 1:length(ChangeList$OldString)) { 9 | FindReplace(file, ChangeList$OldString[i], ChangeList$NewString[i]) 10 | } 11 | } 12 | } else { 13 | .InteractiveOnly() 14 | } 15 | return(invisible(NULL)) 16 | } 17 | -------------------------------------------------------------------------------- /inst/Templates/RandomBlock.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lme" 4 | library(nlme) 5 | {{DataName}}.lme = lme({{ResponseName}} ~ {{FactorName}}, random=1|{{BlockingName}}, data = {{DataName}}) 6 | library(broom) 7 | augment({{DataName}}.lme) 8 | anova({{DataName}}.lme) 9 | ``` 10 | 11 | ```{r} 12 | #| label = "glance{{DataName}}.lme" 13 | {{DataName}}.lme |> glance() |> kable() 14 | ``` 15 | 16 | ```{r} 17 | #| label = "plot{{DataName}}.lme", 18 | #| fig.cap = "Residual analysis for {{DataName}}.lme" 19 | library(ggfortify) 20 | autoplot({{DataName}}.lme) 21 | ``` 22 | -------------------------------------------------------------------------------- /inst/Templates/EMMeans.Rmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | ```{r} 4 | #| label = "GetEMMEansPkg" 5 | library(emmeans) 6 | ``` 7 | 8 | ```{r} 9 | #| label = "{{DataName}}.lm.emmeans" 10 | emmeans({{DataName}}.lm, "{{FactorName}}") |> kable(caption="Estimated marginal means for {{ResponseName}}, grouped by {{FactorName}}.") 11 | ``` 12 | 13 | 14 | ```{r} 15 | #| label = "{{DataName}}.lm.emmeansPlotted", 16 | #| fig.cap = "plot of confidence intervals for estimated marginal means 17 | #| for {{ResponseName}} grouped by {{FactorName}}." 18 | emmeans({{DataName}}.lm, "{{FactorName}}") |> plot() 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /man/Require.Rd: -------------------------------------------------------------------------------- 1 | \name{Require} 2 | \alias{Require} 3 | \title{Load a package by installing it if necessary} 4 | \usage{ 5 | Require(pkg) 6 | } 7 | \arguments{ 8 | \item{pkg}{the package to be loaded/installed.} 9 | } 10 | \value{ 11 | logical: to say that the package has been successfully loaded (invisible) 12 | } 13 | \description{ 14 | It is easier to run a script if we know the packages will be installed if this additional step is necessary. 15 | Installation uses the RStudio mirror of CRAN. 16 | } 17 | \seealso{ 18 | require from the base package 19 | } 20 | \author{ 21 | A. Jonathan R. Godfrey 22 | } 23 | -------------------------------------------------------------------------------- /inst/Templates/SplitPlot.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}.lme" 4 | library(nlme) 5 | {{DataName}}.lme = lme({{ResponseName}} ~ {{BlockingName}}+{{Factor1Name}}*{{Factor2Name}}, random=~1|{{MainPlotID}}, data = {{DataName}}) 6 | library(broom) 7 | {{DataName}}.lme |> augment() 8 | {{DataName}}.lme |> anova() 9 | ``` 10 | 11 | ```{r} 12 | #| label = "glance{{DataName}}.lme" 13 | {{DataName}}.lme |> glance() |> kable() 14 | ``` 15 | 16 | ```{r} 17 | #| label = "plot{{DataName}}.lme", 18 | #| fig.cap = "Residual analysis for {{DataName}}.lme" 19 | library(ggfortify) 20 | {{DataName}}.lme |> autoplot() 21 | ``` 22 | -------------------------------------------------------------------------------- /man/WTF.Rd: -------------------------------------------------------------------------------- 1 | \name{WTF} 2 | \alias{WTF} 3 | \alias{wtf} 4 | \title{What's this figure?} 5 | \usage{ 6 | WTF() 7 | wtf() 8 | } 9 | \description{ 10 | Determine what the current graphics device has on it so the blind user can be sure they have something they want, or find out what it might be that is contained in a graphics device. 11 | } 12 | \examples{ 13 | attach(airquality) 14 | hist(Ozone) 15 | WTF() 16 | plot(Ozone~Wind) 17 | WTF() 18 | detach(airquality) 19 | } 20 | \author{ 21 | A. Jonathan R. Godfrey and Paul Murrell. 22 | } 23 | \value{Text describing what BrailleR was able to detect in the graphics window.} 24 | 25 | -------------------------------------------------------------------------------- /R/MakeRprofile.R: -------------------------------------------------------------------------------- 1 | MakeRprofile = 2 | function(Overwrite = FALSE) { 3 | if (interactive()) { 4 | if (!file.exists(".Rprofile")) Overwrite = TRUE 5 | 6 | if (Overwrite) { 7 | cat('.First=function(){\n .First.sys()\n library(BrailleR)\n}\n', 8 | file = ".Rprofile") 9 | 10 | .FileCreated(".Rprofile", "in the current working directory.") 11 | .AutoLoadBrailleR() 12 | } else { 13 | .FileExists(file=".Rprofile") 14 | .OverWriteNeeded() 15 | } 16 | } else { 17 | .InteractiveOnly() 18 | } 19 | return(invisible(NULL)) 20 | } 21 | -------------------------------------------------------------------------------- /man/CleanCSV.Rd: -------------------------------------------------------------------------------- 1 | \name{CleanCSV} 2 | \alias{CleanCSV} 3 | \title{clean out unwanted white space from a csv file} 4 | \usage{ 5 | CleanCSV(file) 6 | } 7 | \arguments{ 8 | \item{file}{A vector of files to be checked} 9 | } 10 | \value{ 11 | NULL. This function only affects external files. 12 | } 13 | \description{ 14 | A blind user may not see the white space characters surrounding text or numbers in a csv file. These corrupt analyses and are annoying to fix. 15 | } 16 | \details{ 17 | Spits out the csv file in clean form, as well as a back up copy of the original file. 18 | } 19 | \author{ 20 | A. Jonathan R. Godfrey 21 | } 22 | 23 | -------------------------------------------------------------------------------- /inst/Python/python38/google.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | """Script to search with Google 4 | 5 | Usage: 6 | python3 google.py [search terms] 7 | """ 8 | 9 | import sys 10 | import urllib.parse 11 | import webbrowser 12 | 13 | 14 | def main(args): 15 | def quote(arg): 16 | if ' ' in arg: 17 | arg = '"%s"' % arg 18 | return urllib.parse.quote_plus(arg) 19 | 20 | qstring = '+'.join(quote(arg) for arg in args) 21 | url = urllib.parse.urljoin('https://www.google.com/search', '?q=' + qstring) 22 | webbrowser.open(url) 23 | 24 | if __name__ == '__main__': 25 | main(sys.argv[1:]) 26 | -------------------------------------------------------------------------------- /inst/Templates/SerialCorrelation.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Durbin-Watson Test 3 | 4 | Description: Performs the Durbin-Watson test for autocorrelation of disturbances. 5 | 6 | ```{r} 7 | #| label = "GetLibLMTestPkg" 8 | library(lmtest) 9 | ``` 10 | 11 | ```{r} 12 | #| label = "{{DataName}}.dw" 13 | {{DataName}}.dw = {{DataName}}.lm |> dwtest() 14 | {{DataName}}.dw 15 | ``` 16 | 17 | 18 | ## Breusch-Godfrey Test 19 | 20 | Description: performs the Breusch-Godfrey test for higher-order serial correlation. 21 | 22 | ```{r} 23 | #| label = "{{DataName}}.bg" 24 | {{DataName}}.bg = {{DataName}}.lm |> bgtest(order=10) 25 | {{DataName}}.bg 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /inst/Templates/Linearity.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Harvey-Collier Test 3 | 4 | Description: Harvey-Collier test for linearity. 5 | 6 | 7 | ```{r} 8 | #| label = "GetLibLMTestPkg" 9 | library(lmtest) 10 | ``` 11 | 12 | ```{r} 13 | #| label = "{{DataName}}.harv" 14 | {{DataName}}.harv = {{DataName}}.lm |> harvtest() 15 | ``` 16 | 17 | ## Ramsey's RESET test for functional form. 18 | 19 | ```{r} 20 | #| label = "{{DataName}}.reset" 21 | {{DataName}}.reset = {{DataName}}.lm |> resettest() 22 | ``` 23 | 24 | ## Rainbow test for linearity. 25 | 26 | ```{r} 27 | #| label = "{{DataName}}.rain" 28 | {{DataName}}.rain = {{DataName}}.lm |> raintest() 29 | ``` 30 | -------------------------------------------------------------------------------- /man/Internal.Rd: -------------------------------------------------------------------------------- 1 | \name{Internal} 2 | \alias{FindCSSFile} 3 | \alias{InQuotes} 4 | \alias{nNonMissing} 5 | \title{Internal functions for the BrailleR package} 6 | \description{Some functions that probably weren't really necessary, but proved useful at some stage.} 7 | \usage{ 8 | FindCSSFile(file) 9 | 10 | 11 | 12 | InQuotes(x) 13 | 14 | nNonMissing(x) 15 | } 16 | \arguments{ 17 | \item{x}{an object that is of the form needed by the internal function concerned.} 18 | \item{file}{a filename to look for in the user's css folder or locally.} 19 | } 20 | \value{These should be fairly obvious from the name of the function} 21 | \author{A. Jonathan R. Godfrey} 22 | -------------------------------------------------------------------------------- /R/FindReplace.R: -------------------------------------------------------------------------------- 1 | FindReplace = 2 | function(file, find, replace) { 3 | if (file.exists(file)) { 4 | cat("\n", file = file, append = TRUE) # otherwise problems on 5 | # readLines() below 6 | OldText <- readLines(con = file) 7 | NoLines = length(OldText) 8 | if (NoLines > 2) { 9 | if (all(OldText[c(NoLines - 1, NoLines)] == "\n")) { 10 | NoLines = NoLines - 1 11 | } 12 | } 13 | writeLines(gsub(find, replace, OldText, fixed=TRUE)[1:NoLines], con = file) 14 | } else { 15 | .FileDoesNotExist() 16 | } 17 | return(invisible(NULL)) 18 | } 19 | -------------------------------------------------------------------------------- /inst/Python/WriteR/HelpMenuEvents.py: -------------------------------------------------------------------------------- 1 | import wx 2 | def OnAbout(self, event): 3 | dialog = wx.MessageDialog(self, "WriteR is a first attempt at developing an R Markdown editor\n" 4 | "using wxPython. Development started by Jonathan Godfrey\n" 5 | "and James Curtis in 2015.\nContinued development assisted by Timothy Bilton in 2016.\nMarshall Flax started helping out in May 2018.\nSend all feedback to Jonathan Godfrey at a.j.godfrey@massey.ac.nz\nVersion: 2022.1 (or later)", 6 | "About this R Markdown Editor", wx.OK) 7 | dialog.ShowModal() 8 | dialog.Destroy() 9 | 10 | -------------------------------------------------------------------------------- /man/AutoSpellCheck.Rd: -------------------------------------------------------------------------------- 1 | \name{AutoSpellCheck} 2 | \alias{AutoSpellCheck} 3 | \title{Automatic fixing of typos} 4 | \usage{ 5 | AutoSpellCheck(file) 6 | } 7 | \arguments{ 8 | \item{file}{A vector of files to be checked} 9 | } 10 | \value{ 11 | NULL. This function only affects external files. 12 | } 13 | \description{ 14 | Fix up all those annoying typos that come up far too often. 15 | } 16 | \details{ 17 | The word list of typos and their corrections is called \file{AutoSpellList.csv} and is stored in the user's MyBrailleR folder. The file can be updated to meet the user's specific needs. It should not be over-written by a new installation of BrailleR. 18 | } 19 | 20 | \author{ 21 | A. Jonathan R. Godfrey 22 | } 23 | -------------------------------------------------------------------------------- /inst/Python/FixLineBreaks.py: -------------------------------------------------------------------------------- 1 | 2 | "Replace LF with CRLF in argument files. Print names of changed files." 3 | 4 | import sys, re, os 5 | 6 | def main(): 7 | for filename in sys.argv[1:]: 8 | if os.path.isdir(filename): 9 | print(filename, "Directory!") 10 | continue 11 | data = open(filename, "rb").read() 12 | if '\0' in data: 13 | print(filename, "Binary!") 14 | continue 15 | newdata = re.sub("\r?\n", "\r\n", data) 16 | if newdata != data: 17 | print(filename) 18 | f = open(filename, "wb") 19 | f.write(newdata) 20 | f.close() 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /R/GetWriteR.R: -------------------------------------------------------------------------------- 1 | 2 | GetWriteR = 3 | function() { 4 | if (interactive()) { 5 | if (.Platform$OS.type == "windows") { 6 | .DownloadAFile() 7 | download.file( 8 | "https://R-Resources.massey.ac.nz/writer/WriteRInstaller.exe", 9 | "WriteRInstaller.exe") 10 | file.rename("WriteRInstaller.exe", 11 | paste0(getOption("BrailleR.Folder"), "WriteRInstaller.exe")) 12 | .Added2MyBrailleR() 13 | .DeleteAnytime() 14 | } else { 15 | .WindowsOnly 16 | } 17 | } else { 18 | .InteractiveOnly() 19 | } 20 | return(invisible(NULL)) 21 | } 22 | 23 | -------------------------------------------------------------------------------- /R/PrepareWriteR.R: -------------------------------------------------------------------------------- 1 | # Getting started with the WriteR application 2 | # only for Windows users at present. 3 | ## preparing for deprecation 4 | ## substituted with temporarily unavailable while testing the impact of removal 5 | 6 | PrepareWriteR = 7 | function(Author = getOption("BrailleR.Author")) { 8 | if (interactive()) { 9 | if (.Platform$OS.type == "windows") { 10 | 11 | 12 | } else { 13 | .WindowsOnly() 14 | } 15 | } else { 16 | .InteractiveOnly() 17 | } 18 | return(invisible(NULL)) 19 | } 20 | 21 | 22 | PrepareWriteR = 23 | function(Author = getOption("BrailleR.Author")) { 24 | .TempUnavailable() 25 | return(invisible(NULL)) 26 | } 27 | -------------------------------------------------------------------------------- /inst/Templates/BasicSummaryStats.R: -------------------------------------------------------------------------------- 1 | ResponseName.count = length(ResponseName) 2 | ResponseName.unique = length(unique(ResponseName)) 3 | ResponseName.Nobs = sum(!is.na(ResponseName)) 4 | ResponseName.Nmiss = sum(is.na(ResponseName)) 5 | ResponseName.mean = mean(ResponseName, na.rm = TRUE) 6 | ResponseName.tmean5 = mean(ResponseName, trim =0.025, na.rm = TRUE) 7 | ResponseName.tmean10 = mean(ResponseName, trim =0.05, na.rm = TRUE) 8 | ResponseName.IQR = IQR(ResponseName, na.rm = TRUE) 9 | ResponseName.sd = sd(ResponseName, na.rm = TRUE) 10 | ResponseName.var = var(ResponseName, na.rm = TRUE) 11 | ResponseName.skew = moments::skewness(ResponseName, na.rm = TRUE) 12 | ResponseName.kurt = moments::kurtosis(ResponseName, na.rm = TRUE) 13 | -------------------------------------------------------------------------------- /R/CleanCSV.R: -------------------------------------------------------------------------------- 1 | CleanCSV = 2 | function(file) { 3 | if (interactive()) { 4 | for (ThisFile in file) { 5 | cat(paste0(ThisFile, ": ")) 6 | if (file.exists(ThisFile)) { 7 | file.copy(ThisFile, paste0(ThisFile, ".bak")) 8 | for (FixString in c(", ", " ,", "\t,", ",\t")) { 9 | FindReplace(ThisFile, FixString, ",") 10 | } 11 | .Done() 12 | } # end ThisFile exists condition 13 | else { 14 | .FileDoesNotExist() 15 | } 16 | } # end for loop for files 17 | } # end interactive ondition 18 | else { 19 | .InteractiveOnly() 20 | } 21 | return(invisible(NULL)) 22 | } 23 | -------------------------------------------------------------------------------- /inst/Python/python38/crlf.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | "Replace CRLF with LF in argument files. Print names of changed files." 3 | 4 | import sys, os 5 | 6 | def main(): 7 | for filename in sys.argv[1:]: 8 | if os.path.isdir(filename): 9 | print(filename, "Directory!") 10 | continue 11 | with open(filename, "rb") as f: 12 | data = f.read() 13 | if b'\0' in data: 14 | print(filename, "Binary!") 15 | continue 16 | newdata = data.replace(b"\r\n", b"\n") 17 | if newdata != data: 18 | print(filename) 19 | with open(filename, "wb") as f: 20 | f.write(newdata) 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /R/history.R: -------------------------------------------------------------------------------- 1 | # as supplied by Duncan Murdoch 2 | # is pretty much the utils::history with use of file.edit() at the end. 3 | 4 | history = 5 | function(max.show = 25, reverse = FALSE, pattern, ...) { 6 | file1 <- tempfile("Rrawhist") 7 | savehistory(file1) 8 | rawhist <- readLines(file1) 9 | unlink(file1) 10 | if (!missing(pattern)) 11 | rawhist <- unique(grep(pattern, rawhist, value = TRUE, ...)) 12 | nlines <- length(rawhist) 13 | if (nlines) { 14 | inds <- max(1, nlines - max.show):nlines 15 | if (reverse) inds <- rev(inds) 16 | } else 17 | inds <- integer() 18 | file2 <- tempfile("hist") 19 | writeLines(rawhist[inds], file2) 20 | file.edit(file2) 21 | } 22 | -------------------------------------------------------------------------------- /inst/Python/python38/lfcr.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | "Replace LF with CRLF in argument files. Print names of changed files." 4 | 5 | import sys, re, os 6 | 7 | def main(): 8 | for filename in sys.argv[1:]: 9 | if os.path.isdir(filename): 10 | print(filename, "Directory!") 11 | continue 12 | with open(filename, "rb") as f: 13 | data = f.read() 14 | if b'\0' in data: 15 | print(filename, "Binary!") 16 | continue 17 | newdata = re.sub(b"\r?\n", b"\r\n", data) 18 | if newdata != data: 19 | print(filename) 20 | with open(filename, "wb") as f: 21 | f.write(newdata) 22 | 23 | if __name__ == '__main__': 24 | main() 25 | -------------------------------------------------------------------------------- /man/MakeReadable.Rd: -------------------------------------------------------------------------------- 1 | \name{MakeReadable} 2 | \alias{MakeReadable} 3 | \title{Convert line breaks in vignette documentation} 4 | \usage{ 5 | MakeReadable(pkg) 6 | } 7 | \arguments{ 8 | \item{pkg}{The package to investigate for vignette source files.} 9 | } 10 | \value{ 11 | Nothing in the workspace. All files are stored in a vignettes folder within MyBrailleR. 12 | } 13 | \description{ 14 | The Rnw files used for vignettes use Linux style line breaks that make reading vignette source files difficult for Windows users. A Python script is called which converts the line breaks and saves the vignette source in the user's MyBrailleR folder. 15 | } 16 | \details{ 17 | Must have Python 3.8 installed for this function to work. 18 | } 19 | \author{ 20 | A. Jonathan R. Godfrey 21 | } 22 | 23 | -------------------------------------------------------------------------------- /man/SetupBrailleR.Rd: -------------------------------------------------------------------------------- 1 | 2 | \name{SetupBrailleR} 3 | \alias{SetupBrailleR} 4 | \alias{MyBrailleR} 5 | \title{Establish or open the BrailleR folder for the user} 6 | \usage{ 7 | SetupBrailleR() 8 | 9 | MyBrailleR() 10 | } 11 | \value{ 12 | The path to the folder is returned invisibly. 13 | } 14 | \description{ 15 | Creates a permanent folder called MyBrailleR if the user agrees. Windows users can open this file easily using MyBrailleR(). 16 | } 17 | \details{ 18 | The user can establish a permanent MyBrailleR folder if the BrailleR package is loaded in an interactive session. If only used in batch mode, the user will only be able to use the default BrailleR settings. 19 | } 20 | \author{ 21 | A. Jonathan R. Godfrey with suggestions from Henrik Bengtsson and Brian Ripley. 22 | } 23 | 24 | -------------------------------------------------------------------------------- /man/MakeRprofile.Rd: -------------------------------------------------------------------------------- 1 | \name{MakeRprofile} 2 | \alias{MakeRprofile} 3 | \title{Load BrailleR on Startup in Current Working Directory} 4 | \usage{ 5 | MakeRprofile(Overwrite = FALSE) 6 | } 7 | \arguments{ 8 | \item{Overwrite}{Logical: Should an existing .Rprofile file be overwritten?} 9 | } 10 | \value{ 11 | Nothing. This function is used for its side effect of creation of a file in the current working directory. A warning message is created if the file exists and Overwrite=FALSE. 12 | } 13 | \description{ 14 | Writes the single command \dQuote{library(BrailleR)} to a .First() function in .Rprofile in the current working directory. This forces the BrailleR package to be automatically loaded when R is opened in this working directory. 15 | } 16 | \author{ 17 | A. Jonathan R. Godfrey. 18 | } 19 | 20 | -------------------------------------------------------------------------------- /inst/Templates/NonNested.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Cox Test for Comparing Non-Nested Models 3 | 4 | 5 | ```{r} 6 | #| label = "GetLMTestPkg" 7 | library(lmtest) 8 | ``` 9 | 10 | ```{r} 11 | #| label = "{{DataName}}.cox" 12 | {{DataName}}.cox = coxtest({{DataName}}.lm1,{{DataName}}.lm2) 13 | {{DataName}}.cox 14 | ``` 15 | 16 | ## The encompassing test of Davidson & MacKinnon for comparing non-nested models. 17 | 18 | 19 | 20 | ```{r} 21 | #| label = "{{DataName}}.encomp" 22 | {{DataName}}.encomp = encomptest({{DataName}}.lm1,{{DataName}}.lm2) 23 | {{DataName}}.encomp 24 | ``` 25 | 26 | 27 | 28 | ## The Davidson-MacKinnon J test for comparing non-nested models 29 | 30 | ```{r} 31 | #| label = "{{DataName}}.j" 32 | {{DataName}}.j = jtest({{DataName}}.lm1,{{DataName}}.lm2) 33 | {{DataName}}.j 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /man/Deprecated.Rd: -------------------------------------------------------------------------------- 1 | \name{Deprecated} 2 | \alias{GetPython27} 3 | \alias{GetWxPython27} 4 | \alias{MakeSlideShow} 5 | \alias{MakeSlidy} 6 | \alias{MakeAllInOneSlide} 7 | \title{Deprecated functions} 8 | \usage{ 9 | GetPython27(...) 10 | GetWxPython27(...) 11 | 12 | MakeAllInOneSlide(...) 13 | MakeSlidy(...) 14 | MakeSlideShow(...) 15 | } 16 | \arguments{ 17 | \item{...}{cover for unnecessary arguments going to deprecated functions.} 18 | } 19 | \details{ These functions are redundant. 20 | 21 | 22 | A message is printed to inform the user if they are called.} 23 | \value{ 24 | NULL. 25 | } 26 | \description{ 27 | Functions that have become redundant courtesy of development outside the BrailleR package. 28 | } 29 | \author{ 30 | A. Jonathan R. Godfrey, is responsible for the deprecation. 31 | } 32 | 33 | -------------------------------------------------------------------------------- /inst/Templates/Heterogeneity.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Breusch-Pagan Test 3 | 4 | Description: Performs the Breusch-Pagan test against heteroskedasticity. 5 | 6 | 7 | ```{r} 8 | #| label = "GetLMTestPkg" 9 | library(lmtest) 10 | ``` 11 | 12 | ```{r} 13 | #| label = "{{DataName}}.lm.bp" 14 | {{DataName}}.lm.bp = {{DataName}}.lm |> bptest() 15 | ``` 16 | 17 | ## Harrison-McCabe test 18 | 19 | Description: Harrison-McCabe test for heteroskedasticity. 20 | 21 | 22 | 23 | ```{r} 24 | #| label = "{{DataName}}.lm.hmc" 25 | {{DataName}}.lm.hmc = {{DataName}}.lm |> hmctest() 26 | ``` 27 | 28 | 29 | ## Goldfeld-Quandt Test 30 | 31 | Description: Goldfeld-Quandt test against heteroskedasticity. 32 | 33 | ```{r} 34 | #| label = "{{DataName}}.lm.gq" 35 | {{DataName}}.lm.gq = {{DataName}}.lm |> gqtest() 36 | ``` 37 | 38 | 39 | -------------------------------------------------------------------------------- /man/SpellCheck.Rd: -------------------------------------------------------------------------------- 1 | \name{SpellCheck} 2 | \alias{SpellCheck} 3 | \title{A spell checking interface} 4 | \usage{ 5 | SpellCheck(file) 6 | } 7 | \arguments{ 8 | \item{file}{A vector of files to be checked} 9 | } 10 | \value{ 11 | NULL. This function is intended to affect only external files. 12 | } 13 | \description{ 14 | An terminal-based interface for dealing with words that appear to be misspelled in the specified files. Files for lists of words to ignore at local and global levels are augmented, or replacement text can be supplied. 15 | } 16 | \details{ 17 | A backup file is created before any changes are made. This file is not overwritten each time the spell checking is done so it may end up becoming out of date. Users can delete the backup file anytime. 18 | } 19 | \author{ 20 | A. Jonathan R. Godfrey 21 | } 22 | 23 | -------------------------------------------------------------------------------- /inst/Templates/Kruskal.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Kruskal-Wallis Rank Sum Test 3 | 4 | ```{r} 5 | #| label = "GetRStatixPkg" 6 | library(rstatix) 7 | ``` 8 | 9 | ```{r} 10 | #| label = "{{DataName}}.kt" 11 | {{DataName}}.kt = {{DataName}} |> kruskal_test({{ResponseName}} ~ {{FactorName}}) 12 | {{DataName}}.kt |> kable(caption="Kruskal-Wallace nonparametric one-way test for differences in {{ResponseName}} grouped by {{FactorName}}.") 13 | ``` 14 | 15 | 16 | ```{r} 17 | #| label = "DunnTest" 18 | {{DataName}}.dt = {{DataName}} |> dunn_test({{ResponseName}} ~ {{FactorName}}) 19 | {{DataName}}.dt |> kable(caption="Dunn's multiple comparison test for {{ResponseName}} disaggregated by {{FactorName}}.") 20 | ``` 21 | 22 | ```{r} 23 | #| label = "getMeans" 24 | {{DataName}}.dt |> get_emmeans() |> kable(caption="Means of {{ResponseName}} disaggregated by {{FactorName}}.") 25 | ``` 26 | -------------------------------------------------------------------------------- /man/PandocAll.Rd: -------------------------------------------------------------------------------- 1 | \name{PandocAll} 2 | \alias{PandocAll} 3 | \title{Convert files using pandoc.} 4 | \description{Convert all files in the current working directory of one type into another type using Pandoc.} 5 | \usage{ 6 | PandocAll(intype = "docx", outtype = "html") 7 | } 8 | \arguments{ 9 | \item{intype,outtype}{File formats denoted using the standard extensions.} 10 | } 11 | \details{ 12 | This will over-write existing files. It was intended to take MS Word files and convert to HTML, but other conversions are possible. See the pandoc documentation for full details. 13 | } 14 | \value{Files will be created in the current working directory. CRAN policy says you must have been informed that this is happening. This help file is your warning.} 15 | \references{ 16 | Extensive guidance on using pandoc is available 17 | } 18 | \author{A. Jonathan R. Godfrey} 19 | -------------------------------------------------------------------------------- /po/R-BrailleR.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: BrailleR 0.9\n" 4 | "POT-Creation-Date: 2013-09-24 16:31\n" 5 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 6 | "Last-Translator: FULL NAME \n" 7 | "Language-Team: LANGUAGE \n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=CHARSET\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | 12 | 13 | msgid "Please enter a filename and press . \nPressing alone will generate a default filename \nbased on the current date and time." 14 | msgstr "" 15 | 16 | msgid "file must be a character string or connection" 17 | msgstr "" 18 | 19 | msgid "If y is not supplied, x must have two numeric columns" 20 | msgstr "" 21 | 22 | msgid "This function will fail because y is not numeric" 23 | msgstr "" 24 | 25 | msgid "This function will fail because x is not numeric" 26 | msgstr "" 27 | -------------------------------------------------------------------------------- /inst/whisker/SVG/ViewSVG.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | View your accessible svg webpages 5 | 6 | 7 |
8 |
9 |
10 |

Accessible Statistics Diagrams

11 |

Important note: SVG files are not rendered properly in all browsers, notably Internet Explorer. We recommend use of Firefox or Google Chrome if you are working in Windows.

12 |

Please click on one of the examples below to get to the demo: 13 | {{#files}} 14 | {{file}} 15 | {{/files}} 16 |

17 |
18 |
19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /inst/Templates/Friedman.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Friedman Rank Sum Test 3 | 4 | Description: Performs a Friedman rank sum test with unreplicated blocked data. 5 | friedman.test can be used for analyzing unreplicated complete block designs (i.e., there is exactly one observation in y for each combination of levels of groups and blocks) where the normality assumption may be violated. 6 | 7 | The null hypothesis is that apart from an effect of blocks, the location parameter of y is the same in each of the groups. 8 | 9 | 10 | ```{r} 11 | #| label = "GetRStatixPkg" 12 | library(rstatix) 13 | ``` 14 | 15 | 16 | ```{r} 17 | #| label = "{{DataName}}.ft" 18 | {{DataName}}.ft = {{DataName}} |> friedman_test({{ResponseName}} ~ {{FactorName}} | {{BlockingName}}) 19 | {{DataName}}.ft |> kable(caption="Friedman test for {{ResponseName}} disaggregated by {{FactorName}}, and adjusting for {{BlockingName}}.") 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /inst/Templates/SimpleRegression.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "DataNamePlot", 4 | #| fig.cap = "Plot of {{ResponseName}} versus {{PredictorName}} with fitted 5 | #| line added." 6 | library(ggplot2) 7 | {{DataName}} |> ggplot(aes(y=ResponseName, x=PredictorName)) + geom.point() + geom_smooth(method="lm") 8 | ``` 9 | 10 | ```{r} 11 | #| label = "{{DataName}}.lm" 12 | {{DataName}}.lm = lm({{ResponseName}} ~ {{PredictorName}}, data={{DataName}}) 13 | library(broom) 14 | {{DataName}}.lm.aug = {{DataName}}.lm |> augment() 15 | {{DataName}}.lm |> summary() 16 | ``` 17 | 18 | 19 | ```{r} 20 | #| label = "glance{{DataName}}.lm" 21 | {{DataName}}.lm |> glance() |> kable(caption="Summary statistics for {{DataName}}.lm.") 22 | ``` 23 | 24 | ```{r} 25 | #| label = "plot{{DataName}}.lm", 26 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 27 | library(ggfortify) 28 | {{DataName}}.lm |> autoplot() 29 | ``` 30 | -------------------------------------------------------------------------------- /man/notepad.Rd: -------------------------------------------------------------------------------- 1 | \name{Notepad} 2 | \alias{Notepad} 3 | \alias{notepad} 4 | \alias{Explorer} 5 | \alias{explorer} 6 | \alias{cmd} 7 | \alias{CMD} 8 | \title{Open standard Windows tools quickly} 9 | \usage{ 10 | Notepad(file = "") 11 | } 12 | \arguments{ 13 | \item{file}{A character string for the file to be opened; it will be created if it does not yet exist.} 14 | } 15 | \value{ 16 | NULL. The functions are for their external effects only. Control is still available in the R console/terminal. 17 | } 18 | \description{ 19 | Many standard Windows tools can be opened from the Run dialogue, but this starts them in the standard locations, when R users may want them opened or saved in the current working directory. 20 | } 21 | \details{ 22 | If a file specified does not yet exist in the current folder, the standard notepad editor asks the user if a new file is wanted. 23 | } 24 | \author{ 25 | A. Jonathan R. Godfrey 26 | } 27 | -------------------------------------------------------------------------------- /man/MakeAllFormats.Rd: -------------------------------------------------------------------------------- 1 | \name{MakeAllFormats} 2 | \alias{MakeAllFormats} 3 | \title{Prepare the options for conversion of an R markdown file.} 4 | \usage{ 5 | MakeAllFormats(RmdFile, BibFile = "") 6 | } 7 | \arguments{ 8 | \item{RmdFile}{The name of the R markdown file to be converted.} 9 | 10 | \item{BibFile}{Name of the bibtex database file to include.} 11 | } 12 | \value{ 13 | Nothing in the R console/terminal. The function is used for its side effects in the working directory. 14 | } 15 | \description{ 16 | Make a pandoc options file for use with a named R markdown file. 17 | } 18 | \details{ 19 | The options are based on the current best set of possible outcomes. The two html file options use different representations of any mathematical equations. The Microsoft Word file uses the native equation format which is not accessible for blind people using screen readers. 20 | } 21 | \author{ 22 | A. Jonathan R. Godfrey. 23 | } 24 | -------------------------------------------------------------------------------- /inst/whisker/Describe/generics.txt: -------------------------------------------------------------------------------- 1 | name,text 2 | BaseAxisStyleText," 3 | As with most graphs created by the base graphics package, the axes do not join at the bottom left corner and are separated from the area where the data are being plotted." 4 | CommonTickMarkText," 5 | Tick marks are automatically chosen for the data, and the axes may not extend past the ends of variables being plotted." 6 | CommonAspectRatioText," 7 | R normally plots a graph in a square window. This can be altered; the way this is done depends heavily on the method being used to create the graph. See the help on win.graph() or x11() for the graphs made in an interactive session or part of an R script; png(), pdf() or postscript() for specific file formats being created; or, use fig.height and fig.width arguments in your R markdown documents." 8 | CommonScatterplotGen," 9 | A scatter plot shows the relationship between two variables by plotting a symbol for each observation at the coordinates for the two variables." 10 | -------------------------------------------------------------------------------- /man/Embossers.Rd: -------------------------------------------------------------------------------- 1 | \name{Embossers} 2 | \alias{Embossers} 3 | \alias{Premier100} 4 | \title{Prepare BrailleR settings for specific braille embossers} 5 | \usage{ 6 | Premier100() 7 | } 8 | \value{ 9 | Nothing. The functions are only used to set package options. 10 | } 11 | \description{ 12 | Convenience functions for setting package options based on experimentation using specific embossers. 13 | } 14 | \details{ 15 | These functions are only relevant for owners of the specified embossers. Ownership of these models means the user has access to fonts that are licenced to the user. 16 | 17 | The Premier 100 embosser uses standard 11 by 11.5 inch fanfold braille paper. Printing in landscape or portrait is possible. 18 | } 19 | \examples{ 20 | \donttest{ 21 | #Premier100() # Specify use of the Premier 100 embosser. 22 | #ChooseEmbosser() # reset to default: using no embosser. 23 | } 24 | } 25 | \author{ 26 | A. Jonathan R. Godfrey. 27 | } 28 | \seealso{ 29 | \code{\link{ChooseEmbosser}} 30 | } 31 | 32 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | This package was archived due to one of its depndencies also being archived. When the dependency was fixed, BrailleR remained archived. I had hoped to find time to do more than fix the dependency, but alas... 2 | 3 | 4 | So, i think there is nothing to note (I hope) except: 5 | 6 | * package ExtraFonts has been removed from dependencies. All functions making use of that package have been overwritten by functions which post a message to inform users of the changes. 7 | * NOTE re run time for examples. I get these sporadically. If pain persists, I will need to remove the examples. CRAN servers and Win-builder seem to have adequate grunt to avoid this issue. 8 | * Any functions relying on package 'installr' (which was originally created for Windows only and listed as Suggests), only try to make use of installr::foo() within sufficient OS checking if() statements and requireNamespace(). 9 | * Any use of the shell() command do so with OS conditioning and interactive mode protection 10 | -------------------------------------------------------------------------------- /R/latest.R: -------------------------------------------------------------------------------- 1 | ## Constructs the center of the scatterplot 2 | .AddXMLAddScatterCenter = function(root, sp=NULL) { 3 | annotation = .AddXMLAddAnnotation(root, position=4, id="center", kind="grouped") 4 | gs = sp$GroupSummaries 5 | len = length(gs$N) 6 | XML::addAttributes( 7 | annotation$root, speech="Scatter Plot", 8 | speech2=paste("Scatter Plot divided into", 9 | len, "sub intervals of equal width"), 10 | type="Center") 11 | annotations <- list() 12 | for (i in 1:len) { 13 | annotations[[i]] = .AddXMLtimeseriesSegment( 14 | root, position=i, mean=gs$MeanY[i], median=gs$MedianY[i], sd=gs$SDY[i], n=gs$N[i]) 15 | } 16 | annotations[[i + 1]] = .AddXMLAddAnnotation( 17 | root, position=0, id=.AddXMLmakeId("box", "1.1.1"), kind="passive") 18 | .AddXMLAddComponents(annotation, annotations) 19 | .AddXMLAddChildren(annotation, annotations) 20 | .AddXMLAddParents(annotation, annotations) 21 | return(invisible(annotation)) 22 | } 23 | -------------------------------------------------------------------------------- /man/NewFunction.Rd: -------------------------------------------------------------------------------- 1 | \name{NewFunction} 2 | \alias{NewFunction} 3 | \title{Create a template for a new function} 4 | \description{ 5 | An R script for a new function is created in the working directory. It includes Roxygen commented lines for the documentation with sensible defaults where possible. 6 | } 7 | \usage{ 8 | NewFunction(FunctionName, args = NULL, NArgs = 0) 9 | } 10 | \arguments{ 11 | \item{FunctionName}{The name of the function and file to create.} 12 | \item{args}{a vector of argument names} 13 | \item{NArgs}{an integer number of arguments to assign to the function.} 14 | } 15 | \details{ 16 | A file is saved in the current working directory that has a template for a function with a set of arguments (if supplied). The file still needs serious editing before insertion into a package. 17 | } 18 | \value{ 19 | No objects are created in the workspace. The only outcome is the template file and a message to let the user know the job was completed. 20 | } 21 | \author{ 22 | A. Jonathan R. Godfrey. 23 | } 24 | -------------------------------------------------------------------------------- /inst/Templates/PolyReg.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "Plot{{DataName}}", 4 | #| fig.cap = "" 5 | {{DataName}} |> ggplot(aes(y={{ResponseName}}, x={{PredictorName}})) + geom_point() + geom_smooth() 6 | ``` 7 | 8 | 9 | 10 | 11 | ```{r} 12 | #| label = "{{DataName}}.poly" 13 | {{DataName}}.poly1 <- lm({{ResponseName}} ~ {{PredictorName}}, data = DataName) 14 | {{DataName}}.poly2 <- lm({{ResponseName}} ~ poly({{PredictorName}}, 2, raw=TRUE), data = DataName) 15 | {{DataName}}.poly3 <- lm({{ResponseName}} ~ poly({{PredictorName}}, 3, raw=TRUE), data = DataName) 16 | {{DataName}}.poly4 <- lm({{ResponseName}} ~ poly({{PredictorName}}, 4, raw=TRUE), data = DataName) 17 | anova({{DataName}}.poly1, {{DataName}}.poly2, {{DataName}}.poly3, {{DataName}}.poly4) 18 | ``` 19 | 20 | 21 | ```{r} 22 | #| label = "plot{{DataName}}.lm", 23 | #| fig.cap = "Residual analysis for {{DataName}}.poly" 24 | library(ggfortify) 25 | # should really change the following to the preferred model 26 | {{DataName}}.poly4 |> autoplot() 27 | ``` 28 | -------------------------------------------------------------------------------- /man/sort.VIgraph.Rd: -------------------------------------------------------------------------------- 1 | \name{sort.VIgraph} 2 | \alias{sort.VIgraph} 3 | \title{ 4 | Sort VI.ggplot points list 5 | } 6 | \description{ 7 | Allows the list of data points listed by VI.ggplot to be sorted by x or y values, ascending or descending. Currently only implemented for geom_points. This function is experimental and has not been extensively tested. 8 | } 9 | \usage{ 10 | \method{sort}{VIgraph}(x, decreasing = FALSE, by = "x", \dots) 11 | } 12 | \arguments{ 13 | \item{x}{object returned by \code{VI.ggplot}} 14 | \item{decreasing}{logical: should the sort be decreasing} 15 | \item{by}{value on which to sort, "x" or "y"} 16 | \item{\dots}{further arguments passed to \code{base::sort}} 17 | } 18 | \value{ 19 | Returns a new object of the same type as that returned by VI.ggplot, but with data re-ordered. 20 | } 21 | \author{ 22 | Debra Warren and Paul Murrell 23 | } 24 | 25 | \examples{ 26 | if (require(ggplot2)) { 27 | sort(VI(qplot(x=1:5, y=c(2,5,1,4,3))), decreasing=TRUE, by="y") 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /inst/Templates/TukeyHSD.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "getLibs" 4 | library(multcomp) 5 | library(tidyverse) 6 | library(knitr) 7 | library(broom) 8 | ``` 9 | 10 | ## Tukey's Honestly sinificant difference 11 | 12 | ```{r} 13 | #| label = "{{DataName}}.hsd" 14 | {{DataName}}.hsd = glht({{DataName}}.lm, linfct = mcp({{FactorName}} = "Tukey")) 15 | {{DataName}}.hsd |> tidy() |> kable(caption="Tukey's Honestly Significant Differences for the {{DataName}} data.) 16 | ``` 17 | 18 | ```{r} 19 | #| label = "getSummary" 20 | {{DataName}}.hsd |> summary() |> tidy() |> kable(caption="Summary of Tukey's Honestly Significant Differences for the {{DataName}} data.) 21 | ``` 22 | 23 | ```{r} 24 | #| label = "getCLD" 25 | {{DataName}}.hsd |> cld() |> tidy() |> kable(caption="Compact letter display for Tukey's Honestly Significant Differences for the {{DataName}} data.) 26 | ``` 27 | 28 | ```{r} 29 | #| label = "plot{{DataName}}.hsd", 30 | #| fig.cap = "Plot of Tukey's HSD for {{ResponseName}} grouped by 31 | #| {{FactorName}}." 32 | {{DataName}}.hsd |> plot() 33 | ``` 34 | -------------------------------------------------------------------------------- /R/JoinBlindRUG.R: -------------------------------------------------------------------------------- 1 | 2 | ThankYou = 3 | function() { 4 | if (interactive()) { 5 | create.post( 6 | address = "a.j.godfrey@massey.ac.nz", 7 | subject = "Thank you for BrailleR", 8 | instructions = "Hello Jonathan,\n\n", 9 | info = "Please let me know a little about yourself, where you are working or studying, and how you learned about BrailleR.\n") 10 | } else { 11 | .InteractiveOnly() 12 | } 13 | return(invisible(NULL)) 14 | } 15 | 16 | JoinBlindRUG = 17 | function() { 18 | if (interactive()) { 19 | create.post( 20 | address = "BlindRUG-request@nfbnet.org", subject = "subscribe", 21 | instructions = "end", 22 | info = "Just send this message without altering it in any way; wait for an automated reply from the mail server. Just press reply to that message and send it back. You will be joined to BlindRUG very soon afterwards.\n") 23 | } else { 24 | .InteractiveOnly() 25 | } 26 | return(invisible(NULL)) 27 | } 28 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | tags: ['*'] 7 | 8 | name: pkgdown 9 | 10 | jobs: 11 | pkgdown: 12 | runs-on: ubuntu-latest 13 | env: 14 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 15 | steps: 16 | - uses: actions/checkout@v3 17 | 18 | - uses: r-lib/actions/setup-pandoc@v2 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - uses: r-lib/actions/setup-r-dependencies@v2 25 | with: 26 | extra-packages: any::pkgdown, any::XML, local::. 27 | needs: website 28 | 29 | - name: Deploy package 30 | run: | 31 | git config --local user.name "$GITHUB_ACTOR" 32 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 33 | Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' 34 | -------------------------------------------------------------------------------- /inst/Python/WriteR/EditMenuEvents.py: -------------------------------------------------------------------------------- 1 | import wx 2 | import wx.stc # needed for word count and go to line 3 | 4 | def OnGoToLine(self, event): 5 | (x, y) = self.editor.PositionToXY(self.editor.GetInsertionPoint()) 6 | maxLine=self.editor.GetNumberOfLines() 7 | dialog = wx.NumberEntryDialog(self, caption="GoToLine", message="Go to line",prompt="Line",value=y,min=0,max=maxLine) 8 | if dialog.ShowModal() == wx.ID_OK: 9 | line=dialog.GetValue() 10 | line=max(0,min(self.editor.GetNumberOfLines(),line)) 11 | self.editor.SetInsertionPoint(self.editor.XYToPosition(0, dialog.GetValue())) 12 | dialog.Destroy() 13 | 14 | def OnCut(self, event): 15 | self.editor.Cut() 16 | 17 | def OnCopy(self, event): 18 | self.editor.Copy() 19 | 20 | def OnPaste(self, event): 21 | self.editor.Paste() 22 | 23 | def OnDelete(self, event): 24 | frm, to = self.editor.GetSelection() 25 | self.editor.Remove(frm, to) 26 | 27 | def OnSelectAll(self, event): 28 | self.editor.SelectAll() 29 | 30 | 31 | -------------------------------------------------------------------------------- /man/pdf2html.Rd: -------------------------------------------------------------------------------- 1 | \name{pdf2html} 2 | \alias{pdf2html} 3 | \title{Convert a pdf file to html} 4 | \usage{ 5 | pdf2html(pdffile, htmlfile=sub(".pdf", ".html", pdffile), HeadingLevels=4, PageTag="h6") 6 | } 7 | \arguments{ 8 | \item{pdffile}{A pdf file to be converted.} 9 | \item{htmlfile}{The filename for the resulting html; default is to change the file extension.} 10 | \item{HeadingLevels}{The depth of heading level to include; tags h1, h2, h3... are used.} 11 | \item{PageTag}{Which tag to use for replacing page numbers; default is h6, but any tag could be used.} 12 | } 13 | \value{ 14 | Logical: Has the conversion completed. Note that this does not mean the result is totally useful as this will depend on the quality of the input file. 15 | } 16 | \description{ 17 | A blind user often has difficulty reading the content provided in pdf files. This tool is quite experimental at this stage. 18 | } 19 | \details{ 20 | A Python 2.7 module is the basis for the conversion. Some post-processing can be done to further enhance the readability of the resulting html file.} 21 | \author{A. Jonathan R. Godfrey} 22 | 23 | -------------------------------------------------------------------------------- /inst/Python/WriteR/MyConsole.py: -------------------------------------------------------------------------------- 1 | from wx.aui import AuiManager, AuiPaneInfo 2 | 3 | class MyConsole: 4 | def __init__(self, parent): 5 | self.console = parent.CreateTextCtrl("") 6 | self.console.SetEditable(True) 7 | self.parent = parent 8 | parent._mgr.AddPane(self.console, AuiPaneInfo().Name("console") 9 | .Caption("Console").Bottom().Layer(1).Position(1).CloseButton(True) 10 | .MinimizeButton(True)) 11 | # parent._mgr.GetPane("console").Bottom().Layer(0).Row(0).Position(0) 12 | self.console.SetValue('') 13 | self.console.write('Render output goes here') 14 | 15 | def Reset(self): 16 | self.console.SetValue('') 17 | 18 | def write(self, text): 19 | self.console.write(text) 20 | 21 | def CreateWriteText(self, text): 22 | self.console.write(text) 23 | 24 | def SetFocus(self): 25 | self.console.SetFocus() 26 | 27 | def DoneFunc(self, retcode): 28 | self.console.write("Done {}".format(retcode)) 29 | self.parent.SetFocusConsole(True) 30 | -------------------------------------------------------------------------------- /inst/Templates/Dunnett.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "getLibs" 4 | library(multcomp) 5 | library(tidyverse) 6 | library(knitr) 7 | library(broom) 8 | ``` 9 | 10 | ## Dunnett's procedure for comparing all treatments with a control 11 | 12 | ```{r} 13 | #| label = "{{DataName}}.Dunnett" 14 | {{DataName}}.Dunnett = glht({{DataName}}.lm, linfct = mcp({{FactorName}} = "Dunnett")) 15 | {{DataName}}.Dunnett |> tidy() |> kable(caption="Dunnett's multiple comparison procedure for the {{DataName}} data.) 16 | ``` 17 | 18 | ```{r} 19 | #| label = "getSummary" 20 | {{DataName}}.Dunnett|> summary() |> tidy() |> kable(caption="Summary of Dunnett's multiple comparison procedure for the {{DataName}} data.) 21 | ``` 22 | 23 | ```{r} 24 | #| label = "getCLD" 25 | {{DataName}}.Dunnett|> cld() |> tidy() |> kable(caption="Compact letter display of Dunnett's multiple comparison procedure for the {{DataName}} data.) 26 | ``` 27 | 28 | ```{r} 29 | #| label = "plot{{DataName}}.Dunnett", 30 | #| fig.cap = "Plot of Dunnett's procedure for {{ResponseName}} grouped by 31 | #| {{FactorName}}." 32 | plot({{DataName}}.Dunnett) 33 | ``` 34 | -------------------------------------------------------------------------------- /R/Premier100.R: -------------------------------------------------------------------------------- 1 | # @rdname Embossers 2 | # @title Prepare BrailleR settings for specific braille embossers 3 | # @aliases Premier100 4 | # @description Convenience functions for setting package options based on experimentation using specific embossers. 5 | # @details These functions are only relevant for owners of the specified embossers. Ownership of these models means the user has access to fonts that are licenced to the user. 6 | # 7 | # The Premier 100 embosser uses standard 11 by 11.5 inch fanfold braille paper. Printing in landscape or portrait is possible. 8 | # @return Nothing. The functions are only used to set package options. 9 | # @seealso \code{\link{ChooseEmbosser}} 10 | # @author A. Jonathan R. Godfrey. 11 | # @examples 12 | # Premier100() # Specify use of the Premier 100 embosser. 13 | # ChooseEmbosser() # reset to default: using no embosser. 14 | 15 | # @export Premier100 16 | 17 | Premier100 = 18 | function() { 19 | ChooseEmbosser("Premier100") 20 | SetPaperWidth(10, TRUE) 21 | SetPaperHeight(10, TRUE) 22 | SetBRLPointSize(29, TRUE) 23 | return(invisible(NULL)) 24 | } 25 | -------------------------------------------------------------------------------- /man/JoinBlindRUG.Rd: -------------------------------------------------------------------------------- 1 | \name{JoinBlindRUG} 2 | \alias{JoinBlindRUG} 3 | \alias{ThankYou} 4 | \title{Send an email based on a template} 5 | 6 | \usage{ 7 | JoinBlindRUG() 8 | 9 | ThankYou() 10 | } 11 | \description{ 12 | Template email messages have been created to help you send feedback to the package creator or to join the Blind R Users Group email list. The BlindRUG email list is a forum where we can discuss issues about using R as a blind person. List traffic is light. You can join and leave as you see fit. 13 | } 14 | \details{ 15 | You will get an email prepared in your selected email client. If you're wanting to join the BlindRUG list, just press send without editing that message at all. Pretty soon, the server will send you a message that you will need to reply to in order to finalise the subscription. Once you have joined the list you will be sent an initial welcome message. 16 | 17 | 18 | If you are sending in feedback, then please do tell me how you heard about BrailleR and where you are studying or working.} 19 | \author{A. Jonathan R. Godfrey} 20 | \value{NULL. These functions are intended for their side effects.} 21 | 22 | -------------------------------------------------------------------------------- /man/SessionLog.Rd: -------------------------------------------------------------------------------- 1 | \name{SessionLog} 2 | \alias{SessionLog} 3 | \alias{GrabLast} 4 | \alias{ShowMe} 5 | \title{Retrieve a copy of the console input/output} 6 | \description{ 7 | Retrieve the output from the last n top level calls, or the hole current session. These functions are designed to cater for situations where the output scrolls off the screen and is no longer accessible to a screen reader user.} 8 | \usage{ 9 | GrabLast(file = "", n=1) 10 | 11 | SessionLog(file = "", n=NULL) 12 | 13 | ShowMe(file = NULL, n=1) 14 | } 15 | \arguments{ 16 | \item{file}{a filename; if left unspecified, the output is printed in the console} 17 | \item{n}{the number of calls to retrieve} 18 | } 19 | \details{ 20 | A stack of top level calls and the resulting output is stored, courtesy of a setting established on package load. These functions retrieve elements from that stack. The ShowMe() function automatically opens the file created for immediate viewing.} 21 | \value{NULL, invisibly; not the output which is either printed to the console or the file specified} 22 | \author{Gabe Becker and some very minor edits from A. Jonathan R. Godfrey} 23 | 24 | -------------------------------------------------------------------------------- /man/GetGoing.Rd: -------------------------------------------------------------------------------- 1 | \name{GetGoing} 2 | \alias{GetGoing} 3 | \alias{GetingStarted} 4 | \title{Set options for using BrailleR} 5 | \description{An interactive question-and-answer interface suitable for blind users wanting to set the options for using the BrailleR package.} 6 | \usage{ 7 | GetGoing() 8 | } 9 | \details{Defaults are offered for all questions so that pressing means no changes are made. Users answer yes/no questions as TRUE or FALSE respectively; the short form T or F is also allowed. 10 | 11 | The user can also choose to perform various setup tasks using this interface.} 12 | \value{NULL. This function is a tool for executing other functions that will set options and setup the package according to the user's wants.} 13 | \author{A. Jonathan R. Godfrey} 14 | \seealso{All options being set through this function have specific functions that achieve the same ends. For example, see \code{\link{GoSighted}} for the options that are binary settings, or \code{\link{SetAuthor}} for options requiring a specific character or numeric value to be chosen. 15 | 16 | The setup functionality can be reviewed at \code{\link{MakeBatch}}. } 17 | -------------------------------------------------------------------------------- /man/AugmentMethod.Rd: -------------------------------------------------------------------------------- 1 | \name{AugmentMethod} 2 | \alias{Augment} 3 | \alias{Augment.default} 4 | \alias{Augment.Augmented} 5 | \alias{Augment.boxplot} 6 | \alias{Augment.dotplot} 7 | \alias{Augment.eulerr} 8 | \alias{Augment.gg} 9 | \alias{Augment.ggplot} 10 | \alias{Augment.histogram} 11 | \alias{Augment.scatterplot} 12 | \alias{Augment.tsplot} 13 | \alias{.Augment} 14 | \alias{.AugmentGrid} 15 | 16 | \title{add additional detail to the stored object for a graph} 17 | \description{Creates the necessary details that feed into the text descriptions in the VI() function and into the descriptions used in the accessible online versions of the graphs.} 18 | \usage{ 19 | Augment(x) 20 | } 21 | \arguments{ 22 | \item{x}{a graph object for which a method exists, or the current graphics device if set to NULL.} 23 | } 24 | \details{ 25 | Ought to be treated as an internal function and not used interactively. 26 | } 27 | \value{The input object is returned with additions to the object. This does not break the S3 class.} 28 | \author{A. Jonathan R. Godfrey and Volker Sorge} 29 | \examples{ 30 | x=rnorm(1000) 31 | MyHist=Augment(hist(x)) 32 | MyHist 33 | } 34 | -------------------------------------------------------------------------------- /R/R2txtExtraJG.R: -------------------------------------------------------------------------------- 1 | txtOut = 2 | function(Filename = NULL) { 3 | if (is.null(Filename)) { 4 | message( 5 | "Please enter a filename and press . \nPressing alone will generate a default filename \nbased on the current date and time.\n") 6 | Filename = scan(, what = character(0), quiet = TRUE) 7 | FullFilename = paste0(Filename[1], ".txt") 8 | CommandSet = paste0(Filename[1], ".R") 9 | } else { 10 | FullFilename = paste(sub(".txt", "", Filename), "txt", sep = ".") 11 | CommandSet = paste(sub(".txt", "", Filename), "R", sep = ".") 12 | } 13 | if (is.na(Filename[1])) { 14 | Now = date() 15 | Year = substr(Now, 21, 24) 16 | Month = substr(Now, 5, 7) 17 | Day = substr(Now, 9, 10) 18 | Hour = substr(Now, 12, 13) 19 | Minute = substr(Now, 15, 16) 20 | FullFilename = 21 | paste0("Term", Year, Month, Day, "-", Hour, Minute, ".txt") 22 | CommandSet = paste0("Hist", Year, Month, Day, "-", Hour, Minute, ".R") 23 | } 24 | txtStart(file = FullFilename, cmdfile = CommandSet) 25 | } 26 | -------------------------------------------------------------------------------- /man/BRLThis.Rd: -------------------------------------------------------------------------------- 1 | \name{BRLThis} 2 | \alias{BRLThis} 3 | \title{Convert a graph to a pdf ready for embossing} 4 | \usage{ 5 | BRLThis(x, file) 6 | } 7 | \arguments{ 8 | \item{x}{the call to create a graph} 9 | 10 | \item{file}{A character string giving the filename where the image is to be saved.} 11 | } 12 | \value{ 13 | Nothing within the R session, but a pdf file will be created in the user's working directory. 14 | } 15 | \description{ 16 | DEPRECATED. Do not use this function. 17 | The first argument to this function must be a call to create a graph, such as a histogram. Instead of opening a new graphics device, the graph will be created in a pdf file, with all text being presented using a braille font. The function is somewhat experimental as the best braille font is not yet confirmed, and a number of examples need to be tested on a variety of embossers before full confidence in the function is given. 18 | } 19 | \details{ 20 | The user's chosen braille font must be installed. This might include the default font shipped as part of the package. 21 | } 22 | \author{ 23 | A. Jonathan R. Godfrey. with contributions from JooYoung Seo and TK Lee. 24 | } 25 | 26 | -------------------------------------------------------------------------------- /man/WhichFile.Rd: -------------------------------------------------------------------------------- 1 | \name{WhichFile} 2 | \alias{WhichFile} 3 | \title{Find a text string in files} 4 | \description{Which files in a folder (and its subfolders) include/exclude a given text string} 5 | \usage{ 6 | WhichFile(String, Folder, fixed = TRUE, DoesExist = TRUE) 7 | } 8 | \arguments{ 9 | \item{String}{The text string or regular expression being sought.} 10 | \item{Folder}{The head folder to start searching in.} 11 | \item{fixed}{Fixed text string or if FALSE, a regular expression that will be passed to grep().} 12 | \item{DoesExist}{If TRUE, it shows the files that do include the text string of interest; if FALSE, files that lack the search string are returned.} 13 | } 14 | \details{ 15 | Finding a given search string in a pile of text files is time-consuming. Finding which files lack that search string is even harder.} 16 | \value{A vector of filenames returned as character strings.} 17 | \author{A. Jonathan R. Godfrey in response to a request from CRAN to add missing text to help documentation.} 18 | \note{ 19 | This search uses readLines() which throws plenty of warnings if the files being searched across do not all end in a blank line.} 20 | 21 | -------------------------------------------------------------------------------- /R/ProcessAll.R: -------------------------------------------------------------------------------- 1 | ProcessAllRmd = function(dir =".", method = "render"){ 2 | if (dir.exists(dir)) { 3 | FileSet = list.files(dir, pattern="\\.Rmd$", full.names=TRUE) 4 | } 5 | else {.MissingFolder()} 6 | .ProcessAll(dir = dir, method = method, FileSet, Extension=".Rmd") 7 | return(invisible(NULL)) 8 | } 9 | 10 | ProcessAllMd = function(dir ="."){ 11 | if (dir.exists(dir)) { 12 | FileSet = list.files(dir, pattern="\\.md$", full.names=TRUE) 13 | } 14 | else {.MissingFolder()} 15 | .ProcessAll(dir = dir, FileSet = FileSet, Extension=".md") 16 | return(invisible(NULL)) 17 | } 18 | 19 | .ProcessAll = function(dir =".", method = "render", FileSet, Extension=".Rmd") { 20 | for(i in FileSet){ 21 | Outfile = sub(Extension, ".html", i) 22 | if(file.mtime(i) > file.mtime(Outfile)| !file.exists(Outfile)) { 23 | RemoveBOM(i) 24 | if(method=="render"){ 25 | rmarkdown::render(i, output_format = "all") 26 | } 27 | else if(method=="knit2html"){ 28 | knitr::knit2html(i) 29 | } 30 | else{.MissingMethod()} 31 | } 32 | } 33 | return(invisible(NULL)) 34 | } 35 | -------------------------------------------------------------------------------- /R/Rnw2Rmd.R: -------------------------------------------------------------------------------- 1 | Rnw2Rmd = function(file){ 2 | if (interactive()) { 3 | FindReplace(file, "<<>>=", "```{r}") 4 | FindReplace(file, "<<", "```{r ") 5 | FindReplace(file, "@", "```") 6 | FindReplace(file, ">>=", "}") 7 | FindReplace(file, "\\Sexpr{", "`{r ") 8 | FindReplace(file, "results=hide", 'results="hide"') 9 | FindReplace(file, "\\title{", "# ") 10 | FindReplace(file, "\\author{", "### ") 11 | FindReplace(file, "\\section{", "## ") 12 | FindReplace(file, "\\subsection{", "### ") 13 | FindReplace(file, "\\maketitle", "") 14 | FindReplace(file, "\\begin{document}", "") 15 | FindReplace(file, "\\ ", " ") 16 | FindReplace(file, "\\end{document}", "") 17 | FindReplace(file, "\\begin{equation}", "\n$$") 18 | FindReplace(file, "\\end{equation}", "$$\n") 19 | FindReplace(file, "\\today", "") 20 | FindReplace(file, "\\date{}", "") 21 | FindReplace(file, "\\cite{", "@") 22 | # clean out excessive blank lines from the end. 23 | Txt = readLines(file) 24 | NoLines=length(Txt) 25 | while(all(Txt[(NoLines-1):NoLines] == "")) {NoLines=NoLines-1} 26 | writeLines(Txt[1:NoLines], con=file) 27 | } else { 28 | .InteractiveOnly() 29 | } 30 | return(invisible(NULL)) 31 | } 32 | 33 | -------------------------------------------------------------------------------- /inst/Templates/MDS.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "getLibs" 4 | library(tidyverse) 5 | library(broom) 6 | library(knitr) 7 | ``` 8 | 9 | ```{r} 10 | #| label = "getDistMat" 11 | ## add commands here to make 12 | # DistMat 13 | ``` 14 | 15 | ```{r} 16 | #| label = "{{DataName}}.mds" 17 | {{DataName}}.mds = DistMat |> 18 | cmdscale() 19 | colnames({{DataName}}.mds) = c("x", "y") 20 | ``` 21 | 22 | ```{r} 23 | #| label = "{{DataName}}.kmeans" 24 | {{DataName}}.kmeans = kmeans({{DataName}}.mds , NClust) 25 | {{DataName}}.kmeans |> tidy() |> kable(caption="Cluster details fort he {{DataName}} data.") 26 | ``` 27 | 28 | ```{r} 29 | #| label = "addClusters" 30 | {{DataName}}.mds = {{DataName}}.mds |> 31 | as_tibble() |> 32 | mutate(Labels = labels(DistMat), Cluster = as.factor({{DataName}}.kmeans$cluster)) 33 | ``` 34 | 35 | 36 | ```{r} 37 | #| label = "plot{{DataName}}.mds", 38 | #| fig.cap = "Multidimensional scaling of the {{DataName}} data." 39 | {{DataName}}.mds |>ggplot(aes(x=x, y=y, groups=Cluster)) + geom_point() 40 | ``` 41 | 42 | ```{r} 43 | #| label = "getClusters" 44 | {{DataName}}.mds |> arrange(Cluster) |> kable(caption="Cluster memberships for the {{DataName}} data.") 45 | ``` 46 | -------------------------------------------------------------------------------- /man/WhatIs.Rd: -------------------------------------------------------------------------------- 1 | \name{CheckIt} 2 | \alias{CheckIt} 3 | \alias{WhatIs} 4 | \alias{what_is} 5 | \alias{check_it} 6 | \title{Investigate data objects} 7 | \usage{ 8 | CheckIt(x, ...) 9 | check_it(x, ...) 10 | 11 | what_is(x, ...) 12 | WhatIs(x, ...) 13 | } 14 | \arguments{ 15 | \item{x}{The object to be investigated and passed out again.} 16 | 17 | \item{...}{extra parameters to be passed on.} 18 | } 19 | \value{ 20 | These functions intentionally return (invisibly of course) the original input object so that they can be used within a pipe chain, as is commonly used by the Tidyverse. 21 | } 22 | \description{ 23 | Investigate an object, especially useful at any stage in a pipe chain. 24 | } 25 | \details{ 26 | The VI() functionality returns a character vector and is not useful inside a pipe chain. In effect, WhatIs() just adds the pipe chain convenience to the VI() tool, while CheckIt() looks at the structure of the data object. The latter is perhaps more useful if you are uncertain that the pipe chain is delivering what you hoped for. 27 | } 28 | \examples{ 29 | require(dplyr) 30 | airquality \%>\% CheckIt() \%>\% arrange(Ozone) \%>\% head() 31 | 32 | } 33 | \author{ 34 | A. Jonathan R. Godfrey 35 | } 36 | -------------------------------------------------------------------------------- /inst/Templates/ancova.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "{{DataName}}Plot", 4 | #| fig.cap = "Plot of {{ResponseName}} versus {{Covariate}} with fitted lines 5 | #| added for each {{FactorName}}." 6 | library(ggplot2) 7 | {{DataName}} |> ggplot(aes(y = {{ResponseName}}, x = {{Covariate}}, group = {{FactorName}})) + geom.point() + geom_smooth(method="lm") 8 | ``` 9 | 10 | ```{r} 11 | #| label = "{{DataName}}.lm" 12 | {{DataName}}.lm1 = lm({{ResponseName}} ~ {{FactorName}}, data = {{DataName}}) 13 | {{DataName}}.lm2 = lm({{ResponseName}} ~ {{FactorName}}+{{Covariate}}, data = {{DataName}}) 14 | {{DataName}}.lm3 = lm({{ResponseName}} ~ {{FactorName}}*{{Covariate}}, data = {{DataName}}) 15 | anova({{DataName}}.lm1, {{DataName}}.lm2, {{DataName}}.lm3) 16 | ``` 17 | 18 | 19 | ```{r} 20 | #| label = "glance{{DataName}}.lm" 21 | library(broom) 22 | glance({{DataName}}.lm1, {{DataName}}.lm2, {{DataName}}.lm3) |> kable(caption=Comparison of three models relating to ANCOVA of {{ResponseName}} using {{FactorName}} for groups and the {{covariate}} Covariate.") 23 | ``` 24 | 25 | 26 | ```{r} 27 | #| label = "plot{{DataName}}.lm", 28 | #| fig.cap = "Residual analysis for {{DataName}}.lm" 29 | library(ggfortify) 30 | {{DataName}}.lm3 |> autoplot() 31 | ``` 32 | -------------------------------------------------------------------------------- /R/NewFunction.R: -------------------------------------------------------------------------------- 1 | 2 | NewFunction = 3 | function(FunctionName, args = NULL, NArgs = 0) { 4 | if (is.numeric(args[1])) { 5 | NArgs = args[1] 6 | args = NULL 7 | } 8 | if (is.null(args)) { 9 | args = rep("", NArgs) 10 | } else { 11 | NArgs = length(args) 12 | } 13 | Filename = paste0(FunctionName, ".R") 14 | cat(paste0( 15 | "#' @rdname ", FunctionName, "\n#' @title 16 | \n#' @aliases ", 17 | FunctionName, 18 | " 19 | \n#' @description 20 | \n#' @details 21 | \n#' @return 22 | \n#' @seealso 23 | \n#' @author ", 24 | getOption("BrailleR.Author"), 25 | " 26 | \n#' @references 27 | \n#' @examples 28 | \n#' @export ", FunctionName, 29 | " 30 | 31 | "), file = Filename, append = FALSE) 32 | if (NArgs > 0) { 33 | cat(paste("#' @param", args, "\n"), file = Filename, append = TRUE) 34 | } 35 | 36 | cat(paste0("\n", FunctionName, "= function(", 37 | paste(args, collapse = ", "), "){ 38 | 39 | } 40 | "), file = Filename, 41 | append = TRUE) 42 | .FileCreated(Filename, "in the current working directory.") 43 | return(invisible(NULL)) 44 | } 45 | -------------------------------------------------------------------------------- /inst/Templates/OneWayTest.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## Welch Test for Equal Means in a One-Way Layout 3 | 4 | Description: Test whether two or more samples from normal distributions have the same means. The variances are not necessarily assumed to be equal. 5 | 6 | ```{r} 7 | #| label = "GetRStatixPkg" 8 | library(rstatix) 9 | ``` 10 | 11 | 12 | ```{r} 13 | #| label = "{{DataName}}.wt" 14 | {{DataName}}.wt = {{DataName}} |> welch_anova_test({{ResponseName}} ~ {{FactorName}}) 15 | {{DataName}}.wt |> kable(caption="Welch's one-way hypothesis test for {{ResponseName}} grouped by {{FactorName}}.") 16 | ``` 17 | 18 | ## Games Howell Post-hoc Tests 19 | 20 | Description: Performs Games-Howell test, which is used to compare all possible combinations of group differences when the assumption of homogeneity of variances is violated. This post hoc test provides confidence intervals for the differences between group means and shows whether the differences are statistically significant. 21 | 22 | 23 | ```{r} 24 | #| label = "{{DataName}}.ght" 25 | {{DataName}}.ght = {{DataName}} |> games_howell_test({{ResponseName}} ~ {{FactorName}}) 26 | {{DataName}}.ght |> kable((caption="Games-Howell multiple comparison test for {{ResponseName}} disaggregated by {{FactorName}}.") 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /R/WinGet.R: -------------------------------------------------------------------------------- 1 | ## These commands can only be called from functions that have done OS checking 2 | ## They are left as internal commands for this reason 3 | ## the first function is the wrapper for the command line tool, and nothing more 4 | 5 | 6 | ## once working, look to update GetPython.R GetSoftware.R and installPython.R 7 | 8 | .winget = function(what, action=c("upgrade", "install", "show", "uninstall")){ 9 | Out = shell(paste("winget", action, what), intern=TRUE) 10 | return(Out) 11 | } 12 | 13 | 14 | 15 | # possibly create .winget7Zip .wingetMaxima and/or .wingetOctave 16 | 17 | .wingetPandoc = function(){ 18 | action = .ifelse(rmarkdown::pandoc_available(), "upgrade", "install") 19 | return(.winget("pandoc", action)) 20 | } 21 | 22 | # possibly create .wingetPython but need to wait for wxPython to be 3.10 compliant 23 | 24 | .wingetQuarto = function(){ 25 | action = .ifelse(is.null(quarto::quarto_path()), "install", "upgrade") 26 | return(.winget("Quarto", action)) 27 | } 28 | 29 | 30 | ## N.B. there is no "upgrade" of R, just installation of the latest version 31 | .wingetR=function(){ 32 | return(.winget("RProject.R", "install")) 33 | } 34 | 35 | # possibly create .wingetRStudio 36 | 37 | # possibly create .wingetRTools 38 | -------------------------------------------------------------------------------- /inst/MyBrailleR/css/JGSlides.css: -------------------------------------------------------------------------------- 1 | body,p{background-color: black; 2 | color: white; 3 | font-size: 18pt; 4 | line-height: 24pt; 5 | padding: 10pt; 6 | } 7 | 8 | tt, code, pre { 9 | font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace; 10 | } 11 | 12 | a:visited { 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | pre, img { 17 | max-width: 100%; 18 | } 19 | pre { 20 | overflow-x: auto; 21 | } 22 | pre code { 23 | display: block; padding: 0.5em; 24 | } 25 | 26 | code { 27 | font-size: 92%; 28 | border: 1px solid orange; 29 | } 30 | 31 | h1,h2{font-weight: bold; margin-bottom: 15pt; text-align: center;} 32 | 33 | h1{color: yellow; font-size: 28pt;} 34 | h2{color: lightblue;font-size: 24pt;} 35 | 36 | table { 37 | max-width: 95%; 38 | margin-top: 10pt; 39 | margin-bottom: 15pt; 40 | border: 2pt solid blue; 41 | } 42 | 43 | td, th { 44 | border: none; 45 | padding: 5pt; 46 | } 47 | 48 | th{ 49 | font-weight: bold; 50 | } 51 | 52 | #left { 53 | width:45%; 54 | float:left; 55 | padding:5px; 56 | } 57 | #right { 58 | width:45%; 59 | float:right; 60 | padding:5px; 61 | } 62 | 63 | a{background-color: black; 64 | color: black; 65 | font-size: 2pt; 66 | } 67 | -------------------------------------------------------------------------------- /R/MaskedFunctions.R: -------------------------------------------------------------------------------- 1 | boxplot = 2 | function(x, ...) { 3 | MC <- match.call(expand.dots = TRUE) 4 | MC[[1L]] <- quote(graphics::boxplot) 5 | names(MC)[2] = "" 6 | Out <- eval(MC, parent.frame()) 7 | Out$main = as.character(MC$main) 8 | if (length(MC$horizontal) > 0) { 9 | Out$horizontal = as.logical(MC$horizontal) 10 | } else { 11 | Out$horizontal = FALSE 12 | } 13 | # then overwrite if user has specified (even if in error) 14 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) 15 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 16 | Out$call = MC 17 | class(Out) = "boxplot" 18 | Out=Augment(Out) 19 | return(invisible(Out)) 20 | } 21 | 22 | 23 | hist = function(x, ...) { 24 | MC <- match.call(expand.dots = TRUE) 25 | MC[[1L]] <- quote(graphics::hist) 26 | Out <- eval(MC, parent.frame()) 27 | if (length(MC$main) > 0) Out$main = as.character(MC$main) 28 | if (length(MC$sub) > 0) Out$sub = as.character(MC$sub) 29 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) 30 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 31 | Out=Augment(Out) 32 | return(invisible(Out)) 33 | } 34 | -------------------------------------------------------------------------------- /man/BrailleRUsefulLinks.Rd: -------------------------------------------------------------------------------- 1 | \name{BrailleRUsefulLinks} 2 | \alias{BrailleRHome} 3 | \alias{BrailleRInAction} 4 | \alias{LURN} 5 | \alias{Google} 6 | \alias{google} 7 | \alias{R4DS} 8 | \alias{r4ds} 9 | \alias{WriteRHome} 10 | \title{Open the home page for the BrailleR Project, the Google search engine, the BrailleR in Action book, or the Let's Use R Now (LURN) book in your browser} 11 | \usage{ 12 | BrailleRHome() 13 | 14 | BrailleRInAction() 15 | 16 | LURN(BlindVersion = getOption("BrailleR.VI")) 17 | 18 | Google() 19 | google() 20 | 21 | R4DS() 22 | r4ds() 23 | 24 | WriteRHome() 25 | } 26 | \arguments{ 27 | \item{BlindVersion}{Use the version of Let's Use R Now tailored to an audience of blind users.} 28 | } 29 | \value{ 30 | NULL. These functions are for opening a web page and nothing will result in the R session. 31 | } 32 | \description{ 33 | Visit the BrailleR Project home page for updates, instructions on how to join the mailing list which we call BlindRUG and get the latest downloads; or the Let's Use R Now (LURN) home page to read an online manual for using R. Other commonly used websites can be accessed quickly from the R prompt using the other convenience functions. 34 | } 35 | \author{A. Jonathan R. Godfrey} 36 | 37 | \details{Google is a key resource, and so should be the R for Data Science book.} 38 | -------------------------------------------------------------------------------- /R/ViewSVG.R: -------------------------------------------------------------------------------- 1 | #TODO add support for using an arbitary directory 2 | ViewSVG = function(file = "index"){ 3 | # Getting links 4 | svgHTMLFiles = .GetSVGLinks() 5 | 6 | # Get data and render whisker template 7 | data = list( 8 | files = svgHTMLFiles 9 | ) 10 | 11 | htmlTemplate = system.file("whisker/SVG/ViewSVG.html", package = "BrailleR") |> 12 | readLines() 13 | 14 | renderedText = whisker.render(htmlTemplate, data = data) 15 | 16 | # Write rendered html to file 17 | fileName = paste0(file, ".html") 18 | writeLines(renderedText, con = fileName) 19 | close(file(fileName)) 20 | 21 | 22 | if(interactive()){ 23 | browseURL(fileName) 24 | } 25 | 26 | return(invisible(NULL)) 27 | } 28 | 29 | .GetSVGLinks = function() { 30 | htmlFiles = list.files(pattern = ".html") 31 | svgHTMLFiles = list() 32 | for (file in htmlFiles) { 33 | # Search file to see if it is a svg html file. 34 | # This should always get it right as it is from the template file 35 | # It will need to be updated if the template file is updated. 36 | searchResult = readLines(file) |> 37 | grep('
', x = _, Value = TRUE) 38 | if(length(searchResult) >= 1) { 39 | svgHTMLFiles[[length(svgHTMLFiles) + 1]] = list(file=file) 40 | } 41 | } 42 | svgHTMLFiles 43 | } 44 | -------------------------------------------------------------------------------- /R/notepad.R: -------------------------------------------------------------------------------- 1 | MyBrailleR = function(){ 2 | if (interactive()) { 3 | if (.Platform$OS.type == "windows") { 4 | browseURL(getOption("BrailleR.Folder")) 5 | } else { 6 | .WindowsOnly() 7 | } 8 | } else { 9 | .InteractiveOnly() 10 | } 11 | return(invisible(NULL)) 12 | } 13 | 14 | Notepad = notepad = function(file=""){ 15 | if (interactive()) { 16 | if (.Platform$OS.type == "windows") { 17 | shell(paste('notepad', file), wait=FALSE) 18 | } else { 19 | .WindowsOnly() 20 | } 21 | } else { 22 | .InteractiveOnly() 23 | } 24 | return(invisible(NULL)) 25 | } 26 | 27 | 28 | 29 | Explorer = explorer = function(){ 30 | if (interactive()) { 31 | if (.Platform$OS.type == "windows") { 32 | shell('explorer "."', wait=FALSE) 33 | } else { 34 | .WindowsOnly() 35 | } 36 | } else { 37 | .InteractiveOnly() 38 | } 39 | return(invisible(NULL)) 40 | } 41 | 42 | 43 | CMD = cmd = function(){ 44 | if (interactive()) { 45 | if (.Platform$OS.type == "windows") { 46 | shell('cmd', wait=FALSE) 47 | } else { 48 | .WindowsOnly() 49 | } 50 | } else { 51 | .InteractiveOnly() 52 | } 53 | return(invisible(NULL)) 54 | } 55 | 56 | -------------------------------------------------------------------------------- /man/BrailleR-package.Rd: -------------------------------------------------------------------------------- 1 | \name{BrailleR-package} 2 | \alias{BrailleR-package} 3 | \alias{BrailleR} 4 | \docType{package} 5 | \title{ 6 | Improved Access for Blind Users} 7 | \description{Blind users do not have access to the graphical output from R without printing the content of graph windows to an embosser of some kind. This is not as immediate as is required for efficient access to statistical output. The functions here are created so that blind people can make even better use of R. This includes the text descriptions of graphs, convenience functions to replace the functionality offered in many GUI front ends, and experimental functionality for optimising graphical content to prepare it for embossing as tactile images. 8 | } 9 | \details{ 10 | \tabular{ll}{ 11 | Package: \tab BrailleR\cr 12 | Type: \tab Package\cr 13 | Version: \tab 1.2.0 \cr 14 | Date: \tab 2025-12-12\cr 15 | License: \tab GPL-2\cr 16 | } 17 | } 18 | \author{ 19 | A. Jonathan R. Godfrey Volker Sorge, Debra Warren, Timothy P. Bilton and James Thompson with other contributions. 20 | 21 | Maintainer: A. Jonathan R. Godfrey 22 | } 23 | \references{ 24 | Godfrey, A.J.R. (2013) \dQuote{Statistical Software from a Blind Person's Perspective: R is the Best, but we can make it better}, The R Journal 5(1), pp73-79. 25 | } 26 | \keyword{ package } 27 | -------------------------------------------------------------------------------- /man/history.Rd: -------------------------------------------------------------------------------- 1 | \name{history} 2 | \alias{history} 3 | \title{View the history of the current workspace} 4 | \usage{ 5 | history(max.show = 25, reverse = FALSE, pattern, ...) 6 | } 7 | \arguments{ 8 | \item{max.show }{The maximum number of lines to show. Inf will give all of the currently available history. 9 | } 10 | \item{reverse }{logical. If true, the lines are shown in reverse order. Note: this is not useful when there are continuation lines. 11 | } 12 | \item{pattern }{A character string to be matched against the lines of the history. When supplied, only unique matching lines are shown. 13 | } 14 | \item{\dots}{Arguments to be passed to grep when doing the matching. 15 | } 16 | } 17 | \value{ 18 | Nothing is returned to the workspace. This function exists for the creation and viewing of the temporary file that holds the list of commands issued in the current workspace. 19 | } 20 | \description{ 21 | A substitute for the history function from the \pkg{utils} package. 22 | } 23 | \details{ 24 | This function exists because the standard history function in the \pkg{utils} package opens the internal pager that cannot be used by a blind person's screen reading software. 25 | } 26 | \author{ 27 | Duncan Murdoch, with testing by A. Jonathan R. Godfrey. 28 | } 29 | \seealso{ 30 | the original \code{\link[utils]{history}} function. 31 | } 32 | 33 | -------------------------------------------------------------------------------- /R/GetExampleText.R: -------------------------------------------------------------------------------- 1 | GetExampleText = 2 | function (topic, package = NULL, lib.loc = NULL, character.only = FALSE, 3 | outFile = "") 4 | { 5 | if (!character.only) { 6 | topic <- substitute(topic) 7 | if (!is.character(topic)) 8 | topic <- deparse(topic)[1L] 9 | } 10 | 11 | 12 | pkgpaths <- find.package(package, lib.loc, verbose = FALSE) 13 | 14 | NS <- getNamespace("utils") 15 | index.search <- get("index.search", NS) 16 | .getHelpFile <- get(".getHelpFile", NS) 17 | 18 | file <- index.search(topic, pkgpaths, TRUE) 19 | if (!length(file)) { 20 | warning(gettextf("no help found for %s", sQuote(topic)), 21 | domain = NA) 22 | return(invisible()) 23 | } 24 | 25 | packagePath <- dirname(dirname(file)) 26 | pkgname <- basename(packagePath) 27 | lib <- dirname(packagePath) 28 | 29 | 30 | if(outFile=="") outFile = tempfile("Rex") 31 | tools::Rd2ex(.getHelpFile(file), outFile, commentDontrun = TRUE, 32 | commentDonttest = TRUE) 33 | 34 | if (!file.exists(outFile)) { 35 | warning(gettextf("%s has a help file but no examples", 36 | sQuote(topic)), domain = NA) 37 | return(invisible()) 38 | } 39 | ExLines = readLines(outFile) 40 | headerEnds = which(ExLines=="### ** Examples") 41 | return(ExLines[-c(1:headerEnds)]) 42 | } 43 | 44 | -------------------------------------------------------------------------------- /man/summary.recordedplot.Rd: -------------------------------------------------------------------------------- 1 | \name{summary.recordedplot} 2 | \alias{summary.recordedplot} 3 | \title{Summarise the display list for a graphics device} 4 | \description{Base graphics are created using a series of calls to C routines. This function gathers the names of these calls and the values of the arguments as supplied. Names of the arguments are then added. The display list must be retrieved before the graphics device is closed, but this could be stored for later summarisation.} 5 | \usage{ 6 | \method{summary}{recordedplot}(object, ...) 7 | } 8 | \arguments{ 9 | \item{object}{the display list created by recordPlot().} 10 | \item{\dots}{necessary argument for the method; currently ignored} 11 | } 12 | \details{ 13 | The outcome of this command must be further processed to give it context. 14 | } 15 | \value{ 16 | A named list of named vectors. Names of list elements are the C function calls used in plotting the graph on the graphics device; the names for the vectors are dependent on which C functions are called, but are the argument names as per the R function most closely associated with that C call. 17 | } 18 | \author{Deepayan Sarkar with minor edits from A. Jonathan R. Godfrey 19 | } 20 | \seealso{ 21 | %% ~~objects to See Also as \code{\link{help}}, ~~~ 22 | to fix} 23 | \examples{ 24 | plot(x=c(1:20), y=runif(20)) 25 | abline(h=0.5) 26 | 27 | p = recordPlot() 28 | summary(p) 29 | rm(p) 30 | } 31 | -------------------------------------------------------------------------------- /inst/Python/RemoveTabs.py: -------------------------------------------------------------------------------- 1 | 2 | "Replace tabs with spaces in argument files. Print names of changed files." 3 | 4 | import os 5 | import sys 6 | import getopt 7 | 8 | def main(): 9 | tabsize = 2 10 | try: 11 | opts, args = getopt.getopt(sys.argv[1:], "t:") 12 | if not args: 13 | raise getopt.error, "At least one file argument required" 14 | except getopt.error, msg: 15 | print(msg) 16 | print("usage:", sys.argv[0], "[-t tabwidth] file ...") 17 | return 18 | for optname, optvalue in opts: 19 | if optname == '-t': 20 | tabsize = int(optvalue) 21 | 22 | for filename in args: 23 | process(filename, tabsize) 24 | 25 | def process(filename, tabsize): 26 | try: 27 | f = open(filename) 28 | text = f.read() 29 | f.close() 30 | except IOError, msg: 31 | print("%r: I/O error: %s" % (filename, msg)) 32 | return 33 | newtext = text.expandtabs(tabsize) 34 | if newtext == text: 35 | return 36 | backup = filename + ".bak" 37 | try: 38 | os.unlink(backup) 39 | except os.error: 40 | pass 41 | try: 42 | os.rename(filename, backup) 43 | except os.error: 44 | pass 45 | f = open(filename, "w") 46 | f.write(newtext) 47 | f.close() 48 | print(filename) 49 | 50 | if __name__ == '__main__': 51 | main() 52 | -------------------------------------------------------------------------------- /man/Options.Rd: -------------------------------------------------------------------------------- 1 | \name{Options} 2 | \alias{GoBlind} 3 | \alias{GoSighted} 4 | \alias{GoAdvanced} 5 | \alias{GoNovice} 6 | \alias{LatexOn} 7 | \alias{LatexOff} 8 | \alias{ViewOn} 9 | \alias{ViewOff} 10 | \title{Set package options} 11 | \description{ 12 | A set of convenience functions to alter the settings that control how much output is generated and displayed by other \pkg{BrailleR} functions. 13 | } 14 | \usage{ 15 | GoBlind() 16 | GoSighted() 17 | 18 | 19 | GoAdvanced() 20 | GoNovice() 21 | 22 | LatexOn() 23 | LatexOff() 24 | 25 | ViewOn() 26 | ViewOff() 27 | } 28 | \details{ 29 | The function names should be fairly self explanatory. \code{GoBlind()} and \code{GoSighted()} control use of the \code{VI()} method which provides extra information about graphical objects for the assistance of blind users; \code{GoAdvanced} (less verbose) and \code{GoNovice()} (more verbose) control how much output a user will be given; \code{ViewOn()} and \code{ViewOff()} are for the automatic opening of \code{HTML} pages created by \pkg{BrailleR} functions; and \code{LatexOn()} and \code{LatexOff()} control the production of tables into LaTeX via the \pkg{xtable} package. 30 | } 31 | \value{ 32 | Nothing is returned. These functions are only used for their side effects. 33 | } 34 | \author{ 35 | A. Jonathan R. Godfrey 36 | } 37 | 38 | 39 | \seealso{ 40 | See these settings applied as default arguments to \code{\link{UniDesc}} 41 | } 42 | -------------------------------------------------------------------------------- /inst/Templates/NormalityTests.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "GetNortestPkg" 4 | library(nortest) 5 | ``` 6 | 7 | 8 | 9 | ```{r} 10 | #| label = "{{DataName}}-{{ResponseName}}Normality" 11 | NormalityResults = matrix(0, nrow=6, ncol=2) 12 | dimnames(NormalityResults) = list(c("Shapiro-Wilk", "Anderson-Darling", "Cramer-von Mises", 13 | "Lilliefors (Kolmoorov-Smirnov)", "Pearson chi-square", "Shapiro-Francia"), c("Statistic", "P Value")) 14 | {{ResponseName}}.swt = {{ResponseName}} |> shapiro.test() 15 | NormalityResults[1,] = c({{ResponseName}}.swt$statistic, {{ResponseName}}.swt$p.value) 16 | {{ResponseName}}.adt = {{ResponseName}} |> ad.test() 17 | NormalityResults[2,] = c({{ResponseName}}.adt$statistic, {{ResponseName}}.adt$p.value) 18 | {{ResponseName}}.cvmt = {{ResponseName}} |> cvm.test() 19 | NormalityResults[3,] = c({{ResponseName}}.cvmt$statistic, {{ResponseName}}.cvmt$p.value) 20 | {{ResponseName}}.lkst = {{ResponseName}} |> lillie.test() 21 | NormalityResults[4,] = c({{ResponseName}}.lkst$statistic, {{ResponseName}}.lkst$p.value) 22 | {{ResponseName}}.pt = {{ResponseName}} |> pearson.test() 23 | NormalityResults[5,] = c({{ResponseName}}.pt$statistic, {{ResponseName}}.pt$p.value) 24 | {{ResponseName}}.sft = {{ResponseName}} |> sf.test() 25 | NormalityResults[6,] = c({{ResponseName}}.sft$statistic, {{ResponseName}}.sft$p.value) 26 | NormalityResults |> kable(caption="Normality tests for {{ResponseName}}.") 27 | ``` 28 | -------------------------------------------------------------------------------- /inst/fonts/BRAILLE1.txt: -------------------------------------------------------------------------------- 1 | ************************************************* 2 | * These fonts are FREEWARE for PERSONNAL USE * 3 | ************************************************* 4 | 5 | It is requested, however, that you neither modify them, nor change 6 | their names. 7 | You can distribute them to whomever you like, insofar as this file 8 | "README.TXT " accompanies them. 9 | To make these fonts, I used a software bought in the USA, and thus 10 | I HAVE the LICENCE OF USE. 11 | These fonts works perfectly well under WINDOWS 95,98,2000 and up 12 | as well as on my own computer. 13 | Anyway, I could not be held responsible for any possible problems 14 | that could derive from their use. 15 | 16 | If you would like me to make a font of your personal handwriting 17 | or any particular symbolic font, you just need to visit my 18 | " PRICE " webpage here: 19 | 20 | http://philing.net 21 | 22 | you will find all details. 23 | 24 | To contact me: 25 | 26 | Philippe BLONDEL phone: 336 512 486 05 27 | "Le Village" 28 | 32350 ORDAN-LARROQUE Email : philing@hotmail.fr 29 | - FRANCE - URL : http://philing.net 30 | 31 | 32 | Your Handwriting Font !... 33 | The Best Way to Humanize Your Computer !... 34 | 35 | 36 | ***************************************************************** -------------------------------------------------------------------------------- /inst/Templates/PCA.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r} 3 | #| label = "getLibs" 4 | library(tidyverse) 5 | library(broom) 6 | library(knitr) 7 | ``` 8 | 9 | ```{r} 10 | #| label = "{{DataName}}.pc" 11 | {{DataName}}.pc = {{DataName}} |> 12 | select(where(is.numeric)) |> 13 | prcomp(center=TRUE, scale=FALSE) 14 | ``` 15 | 16 | 17 | ```{r} 18 | #| label = "GetVariances" 19 | {{DataName}}.pc |> 20 | tidy(matrix = "pcs") |> 21 | kable(caption="Principal Component contributions for the {{DataName}} data.") 22 | ``` 23 | 24 | 25 | ```{r} 26 | #| label = "ScreePlot{{DataName}}.pc", 27 | #| fig.cap = "Scree plot for the principal components analysis of the 28 | #| {{DataName}} data." 29 | {{DataName}}.pc |> plot() 30 | ``` 31 | 32 | 33 | ```{r } 34 | #| label = "getLoadings" 35 | {{DataName}}.pc$rotation |> 36 | kable(caption="Principal Component Loadings for the {{DataName}} data.") 37 | ``` 38 | 39 | 40 | ```{r} 41 | #| label = "biplot{{DataName}}.pc", 42 | #| fig.cap = "Biplot for the {{DataName}} data." 43 | {{DataName}}.pc |> biplot() 44 | ``` 45 | 46 | ```{r} 47 | #| label = "augment{{DataName}}.pc" 48 | {{DataName}}.pc.fit = {{DataName}}.pc |> augment({{DataName}}) 49 | ``` 50 | 51 | 52 | ```{r} 53 | #| label = "scatter{{DataName}}.pc", 54 | #| fig.cap = "Scatter plot of the first and second principle component 55 | #| scores." 56 | {{DataName}}.pc.fit |> ggplot(aes(x=.fittedPC1, y=.fittedPC2)) + 57 | geom_point(size = 1.5) 58 | ``` 59 | -------------------------------------------------------------------------------- /vignettes/Ex2BasicNumerical.rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The BrailleR package Example 2" 3 | author: "A. Jonathan R. Godfrey" 4 | bibliography: BrailleRPublications.bib 5 | vignette: > 6 | %\VignetteIndexEntry{Example 2: Basic numerical summaries} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | output: knitr:::html_vignette 9 | --- 10 | 11 | ```{r setup, include=FALSE} 12 | library(knitr) 13 | opts_chunk$set(fig.width=7, fig.height=5, comment="") 14 | library(BrailleR) 15 | ``` 16 | 17 | 18 | # The BrailleR package Example 2. 19 | 20 | ## Basic numerical summaries 21 | 22 | The standard presentation of a summary of a data frame where each variable is given its own column is difficult for a screen reader user to read as the processing of information is done line by line. For example: 23 | 24 | ```{r UseSummary} 25 | summary(airquality) 26 | ``` 27 | 28 | The VI() command actually calls the VI.data.frame() command. It then processes each variable one by one so that the results are printed variable by variable instead of summary statistic by summary statistic. For example: 29 | ```{r UseVI} 30 | VI(airquality) 31 | ``` 32 | 33 | 34 | 35 | ## Important features 36 | 37 | Note that in this case, the blind student could choose to present the summary of each variable as generated by the VI() command, or the output from the standard summary() command. There is no difference in the information that is ultimately presented in this case. 38 | 39 | 40 | -------------------------------------------------------------------------------- /man/WhereXY.Rd: -------------------------------------------------------------------------------- 1 | \name{WhereXY} 2 | \alias{WhereXY} 3 | \title{ 4 | Count points in a scatter plot 5 | } 6 | \description{ 7 | count the number of points that fall into various sized subparts of a scatter plot. The graphing region can be split into cells based on a uniform or normal marginal distribution separately for the x and y variables. 8 | } 9 | \usage{ 10 | WhereXY(x, y = NULL, grid = c(4, 4), xDist = "uniform", 11 | yDist = xDist, addmargins=TRUE) 12 | } 13 | \arguments{ 14 | \item{x,y}{vectors of x coordinates. If y is not specified, the function expects x to be a two-column matrix with x and y values in columns 1 and 2 respectively. } 15 | \item{grid}{pair of values to specify the way the graph is to be split into parts. Specify x and then y.} 16 | \item{xDist,yDist}{the distribution the variables might be expected to follow. The default is to consider uniformly distributed but any alternative text will lead to an assumption of both margins being normally distributed.} 17 | \item{addmargins}{logical: should sums be added to both rows and columns.} 18 | } 19 | \value{ 20 | A text description of the number of points in each subregion of the scatter plot. The table of counts can then be compared to the expected number of points in each subregion. 21 | } 22 | \author{ 23 | A. Jonathan R. Godfrey 24 | } 25 | \examples{ 26 | x=rnorm(50) 27 | y=rnorm(50) 28 | WhereXY(x,y) 29 | WhereXY(x,y, c(3,4)) 30 | WhereXY(x,y, xDist="other") 31 | } 32 | -------------------------------------------------------------------------------- /R/DataViewer.R: -------------------------------------------------------------------------------- 1 | DataViewer = 2 | function(x, Update = FALSE, New = NULL, Filename = NULL) { 3 | # only for interactive sessions 4 | if (interactive()) { 5 | # check here that x is one of data.frame, matrix, or a vector. 6 | if (!is.data.frame(x) & !is.matrix(x) & !is.vector(x)) { 7 | .NotViewable() 8 | } 9 | if (is.null(Filename)) { 10 | Filename = tempfile(pattern = "DV-", tmpdir = ".", fileext = ".csv") 11 | } 12 | write.csv(x, file = Filename) 13 | browseURL(Filename) 14 | 15 | readline( # waits for return value normally 16 | "Press once the viewing and editing is completed. \nOtherwise the temporary file will not be removed.") 17 | 18 | if (Update) { 19 | if (is.null(New)) { 20 | New = "New" 21 | } 22 | 23 | BringBack = read.csv(Filename, row.names = 1) 24 | # check for class of x 25 | if (is.matrix(x)) { 26 | BringBack = as.matrix(BringBack) 27 | } 28 | if (is.vector(x)) { 29 | BringBack = BringBack[, 1] 30 | } 31 | assign(New, BringBack, envir = parent.frame()) 32 | } # end Update 33 | 34 | file.remove(Filename) 35 | } # end interactive 36 | else { 37 | .InteractiveOnly() 38 | } # end not interactive 39 | invisible(NULL) 40 | } # end function 41 | -------------------------------------------------------------------------------- /man/unfinished.Rd: -------------------------------------------------------------------------------- 1 | \name{unfinished} 2 | \alias{VI.barplot} 3 | \alias{VI.density} 4 | \alias{VI.aovlist} 5 | \alias{VI.Date} 6 | \alias{VI.factor} 7 | \alias{VI.glm} 8 | \alias{VI.manova} 9 | \alias{VI.mlm} 10 | \alias{VI.stepfun} 11 | \alias{VI.table} 12 | \title{ 13 | Unfinished Methods to help vision impaired useRs 14 | } 15 | \description{ 16 | A set of methods that will (once coded) extract the most relevant information from a graphical object (or implied set of graphical objects) and display the interpreted results in text form. 17 | 18 | The method includes representations of summary methods that are more suitable for blind useRs. For example, the method for a data.frame uses a single line for each variable instead of the normal column layout used by the \code{summary} method. 19 | } 20 | \details{ 21 | This is the help page for the VI() functions that are not fully functional or below par in some way. 22 | } 23 | \value{ 24 | This will vary according to the needs of vision impaired useRs and the specific objects that need to be interpreted. 25 | 26 | In general, the output is a series of text strings printed in the console/terminal window in addition to the embedded command's normal functionality. 27 | 28 | These functions do not create objects as do many \R commands. Manipulations on the objects created by regular \R expressions will need those regular expressions issued in addition to those of the VI family of functions. 29 | } 30 | \author{ 31 | Jonathan Godfrey 32 | } 33 | 34 | -------------------------------------------------------------------------------- /man/dotplot.Rd: -------------------------------------------------------------------------------- 1 | \name{dotplot} 2 | \alias{dotplot} 3 | \alias{dotplot.default} 4 | \alias{dotplot.formula} 5 | \title{create a dotplot using stripchart} 6 | \description{ 7 | A method for creating dotplots. The functions call the \code{stripchart} command from the \pkg{graphics} package and assign the output to have the class \code{dotplot}. 8 | } 9 | \usage{ 10 | dotplot(x, ...) 11 | 12 | \method{dotplot}{formula}(x, ...) 13 | } 14 | \arguments{ 15 | \item{x}{a vector or formula, where the right hand side of the formula is a factor.} 16 | \item{\dots}{other graphical parameters including those passed to \code{title}.} 17 | } 18 | \details{ 19 | This function was created as a result of being unable to assign all graphical parameters that are created when a formula is used in \code{stripchart}. Users not intending to use the \code{VI} method should use \code{stripchart} instead.} 20 | \author{A. Jonathan R. Godfrey} 21 | \seealso{ 22 | This function is dependent on the \code{\link[graphics]{stripchart}} function from the \pkg{graphics} package. Consult its help page for more information. 23 | } 24 | \examples{ 25 | VI(with(airquality, dotplot(Ozone~Month))) 26 | } 27 | \value{ 28 | An object of class dotplot. This class is just a placeholder for the contents of the object used to create a boxplot which would otherwise not be stored in a usable format. The class is not intended for the user; it is a tool that enables the BrailleR package to deliver a readable text version of the plot. 29 | } 30 | -------------------------------------------------------------------------------- /inst/Python/python38/untabify.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | "Replace tabs with spaces in argument files. Print names of changed files." 4 | 5 | import os 6 | import sys 7 | import getopt 8 | import tokenize 9 | 10 | def main(): 11 | tabsize = 8 12 | try: 13 | opts, args = getopt.getopt(sys.argv[1:], "t:") 14 | if not args: 15 | raise getopt.error("At least one file argument required") 16 | except getopt.error as msg: 17 | print(msg) 18 | print("usage:", sys.argv[0], "[-t tabwidth] file ...") 19 | return 20 | for optname, optvalue in opts: 21 | if optname == '-t': 22 | tabsize = int(optvalue) 23 | 24 | for filename in args: 25 | process(filename, tabsize) 26 | 27 | 28 | def process(filename, tabsize, verbose=True): 29 | try: 30 | with tokenize.open(filename) as f: 31 | text = f.read() 32 | encoding = f.encoding 33 | except IOError as msg: 34 | print("%r: I/O error: %s" % (filename, msg)) 35 | return 36 | newtext = text.expandtabs(tabsize) 37 | if newtext == text: 38 | return 39 | backup = filename + "~" 40 | try: 41 | os.unlink(backup) 42 | except OSError: 43 | pass 44 | try: 45 | os.rename(filename, backup) 46 | except OSError: 47 | pass 48 | with open(filename, "w", encoding=encoding) as f: 49 | f.write(newtext) 50 | if verbose: 51 | print(filename) 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. 2 | # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macos-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: any::rcmdcheck 45 | needs: check 46 | 47 | - uses: r-lib/actions/check-r-package@v2 48 | with: 49 | upload-snapshots: true -------------------------------------------------------------------------------- /man/GetWriteR.Rd: -------------------------------------------------------------------------------- 1 | \name{GetWriteR} 2 | \alias{GetWriteR} 3 | \alias{GetPandoc} 4 | \alias{Get7zip} 5 | \alias{GetRStudio} 6 | \alias{GetPython3} 7 | \alias{GetPython} 8 | \alias{GetCygwin} 9 | \alias{GetWxPython3} 10 | \alias{GetWxPython} 11 | \title{Download and install software (Windows users only)} 12 | \usage{ 13 | Get7zip() 14 | 15 | GetCygwin(x64 = TRUE) 16 | 17 | GetPandoc() 18 | 19 | GetPython(x64 = TRUE) 20 | GetPython3(x64 = TRUE) 21 | 22 | GetRStudio() 23 | 24 | GetWriteR() 25 | 26 | GetWxPython() 27 | GetWxPython3() 28 | } 29 | \arguments{ 30 | \item{x64}{Use the 64 bit version if appropriate.} 31 | } 32 | \details{ This function assumes you have a current internet connection because it downloads a File. 33 | 34 | The functions will download and install the chosen application. The installers are stored in the user's MyBrailleR folder. 35 | } 36 | \value{ 37 | NULL. The downloaded file is saved in the user's MyBrailleR folder. 38 | } 39 | \note{Use of this function assumes you are happy for a file to be downloaded and saved on your hard drive. You can go to your MyBrailleR folder and delete the executable at any time.} 40 | \description{ 41 | Anyone wishing to make use any of the WriteR applications must have pandoc installed. 42 | 43 | Users that do not have Python and wxPython installed cannot use the WriteR application file as provided by the BrailleR package. This command gets an installer that can run independently of Python. 44 | 45 | Downloaded files will be saved into the user's MyBrailleR folder. 46 | } 47 | \author{ 48 | A. Jonathan R. Godfrey, building on the installr package by Tal Galili 49 | } 50 | 51 | -------------------------------------------------------------------------------- /R/BRLThis.R: -------------------------------------------------------------------------------- 1 | # @rdname BRLThis 2 | # @title Convert a graph to a pdf ready for embossing 3 | # @aliases BRLThis 4 | # @description The first argument to this function must be a call to create a graph, such as a histogram. Instead of opening a new graphics device, the graph will be created in a pdf file, with all text being presented using a braille font. The function is somewhat experimental as the best braille font is not yet confirmed, and a number of examples need to be tested on a variety of embossers before full confidence in the function is given. 5 | # @details The user's chosen braille font must be installed. This might include the default font shipped as part of the package. 6 | # @return Nothing within the R session, but a pdf file will be created in the user's working directory. 7 | # @author A. Jonathan R. Godfrey. 8 | # @examples 9 | #; data(airquality) 10 | # with(airquality, 11 | # BRLThis(hist(Ozone), "Ozone-hist.pdf")) 12 | 13 | # @export BRLThis 14 | # @param x the call to create a graph 15 | # @param file A character string giving the filename where the image is to be saved. 16 | BRLThis = 17 | function(x, file) { 18 | # extrafont::loadfonts(quiet = TRUE) 19 | # need to add these arguments to the call 20 | # family="Braille Normal", cex=1, cex.axis=1, cex.main=1, cex.lab=1, cex.sub=1) 21 | # eval({ 22 | # pdf(file, pointsize = 29) 23 | # x 24 | # dev.off() 25 | # extrafont::embed_fonts(file) # , outfile=file) 26 | # }, parent.frame()) 27 | return(invisible(NULL)) 28 | } 29 | 30 | 31 | BRLThis = 32 | function(x, file) { 33 | .DeprecatedFunction() 34 | } 35 | -------------------------------------------------------------------------------- /man/grep.VIgraph.Rd: -------------------------------------------------------------------------------- 1 | \name{grep.VIgraph} 2 | \alias{grep} 3 | \alias{grep.default} 4 | \alias{grep.VIgraph} 5 | \alias{gsub} 6 | \alias{gsub.default} 7 | \alias{gsub.VIgraph} 8 | \title{ 9 | String manipulation of the output produced by VI.ggplot 10 | } 11 | \description{ 12 | Allows the output from VI.ggplot to be searched and replaced 13 | based on a search pattern. 14 | } 15 | \usage{ 16 | \method{grep}{VIgraph}(pattern, x, \dots) 17 | \method{gsub}{VIgraph}(pattern, replacement, x, \dots) 18 | } 19 | \arguments{ 20 | \item{pattern}{Regular expression for matching, as per \code{grep}} 21 | \item{replacement}{Replacement text, as per \code{gsub}} 22 | \item{x}{object returned by \code{VI.ggplot}} 23 | \item{\dots}{other arguments passed on to \code{grep} or \code{gsub} 24 | to control matching behaviour} 25 | } 26 | \details{ 27 | The \pkg{BrailleR} package redefines the \code{grep} and \code{gsub} 28 | functions as 29 | generic functions (that dispatch on the \code{x} argument), 30 | with \code{base::grep} and \code{base::gsub} as the default methods. 31 | This \code{grep.VIgraph} 32 | method behaves like \code{base::grep} with \code{value=TRUE} 33 | (i.e., it returns the matched values, not the indices). 34 | } 35 | \value{ 36 | Returns a new object of the same type as that returned by VI.ggplot, but 37 | with the text component restricted to only those lines that matched the 38 | pattern or with the text component replaced. 39 | } 40 | \author{ 41 | Debra Warren and Paul Murrell 42 | } 43 | 44 | \examples{ 45 | if (require(ggplot2)) { 46 | grep("axis", VI(qplot(1,1))) 47 | gsub("labels", "tick labels", VI(qplot(1,1))) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /R/WriteR.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | .RunWriteRExecutable = function(file=NULL){ 4 | shell(paste0(Sys.which("WriteR"), .ifelse(is.null(file), "", file)), wait=FALSE) 5 | } 6 | 7 | .IsWriteRAvailable = 8 | function(){ 9 | Success = FALSE 10 | PyExists = TestPython() 11 | if(PyExists && .IsWxAvailable()){ 12 | Success=TRUE 13 | }else{ 14 | if(PyExists){ 15 | Success = .PullWxUsingPip() 16 | }else{ 17 | .NeedsPython() 18 | } 19 | } 20 | return(invisible(Success)) 21 | } 22 | 23 | # Running the WriteR application 24 | # only for Windows users at present. 25 | 26 | WriteR = 27 | function(file = NULL, math = c("webTeX", "MathJax")) { 28 | if (interactive()) { 29 | if (.Platform$OS.type == "windows") { 30 | if (.IsWriteRAvailable() | Sys.which("WriteR") != "") { 31 | if (!is.null(file)) { 32 | if (!file.exists(file)) { 33 | .FileCreated(file=file, where="in the current directory.") 34 | file.copy(system.file("Templates/simpleYAMLHeader.Rmd", package="BrailleR"), file) 35 | } 36 | } 37 | shell(paste0('"', file.path(system.file( 38 | "Python/WriteR/WriteR.pyw", package = "BrailleR")), '" ', 39 | .ifelse(is.null(file), "", file)), wait=FALSE) 40 | } else { 41 | .NeedsWX() 42 | .InstallPython() 43 | } 44 | } else { 45 | .WindowsOnly() 46 | } 47 | } else { 48 | .InteractiveOnly() 49 | } 50 | return(invisible(NULL)) 51 | } 52 | 53 | -------------------------------------------------------------------------------- /R/UpdateGraph.R: -------------------------------------------------------------------------------- 1 | # NB xlab() and ylab() are functions in the ggplot2 package; 2 | # the original BrailleR implementation was inconsistent with ggplot2 so the function names were chantged to camel case. 3 | 4 | Main = XLab = YLab = function(graph, label=NULL){ 5 | arg = as.character(match.call()[[1]]) 6 | Obj = tolower(as.character(match.call()[["graph"]])) 7 | if(any(class(graph)=="Augmented")){ 8 | if(is.null(label)){ 9 | Out = .GetGraphText(graph, arg) 10 | return(Out) 11 | } else { 12 | Out = .UpdateGraph(graph, label, arg) 13 | assign(Obj, Out, parent.frame()) 14 | return(invisible(Out)) 15 | } 16 | } 17 | } 18 | 19 | 20 | update.scatterplot = update.tsplot = update.fittedlineplot = UpdateGraph = function(object, ...){ 21 | MC <- match.call(expand.dots = TRUE) 22 | ParSet = (as.list(MC))[-c(1,2)] 23 | Obj = as.character(match.call()[["object"]]) 24 | Out = object 25 | # now sift ExtraArgs from ParSet and update them 26 | # now sift pars from ParSet and update them 27 | assign(Obj, Out, parent.frame()) 28 | return(invisible(Out)) 29 | } 30 | 31 | 32 | .UpdateGraph = function(graph, label, arg){ 33 | graph$"ExtraArgs"[[arg]] = label 34 | if(any(class(graph)=="ggplot")){ 35 | arg = .ggplotLabelNames[arg] 36 | graph$labels[[arg]] = label 37 | } 38 | print(graph) # is actually plot() except for histograms 39 | return(invisible(graph)) 40 | } 41 | 42 | .GetGraphText = function(graph, arg){ 43 | return(invisible(graph$"ExtraArgs"[[arg]])) 44 | } 45 | 46 | .ggplotLabelNames = c(main="title", sub="subtitle", xlab="x", ylab="y") 47 | -------------------------------------------------------------------------------- /man/FindReplace.Rd: -------------------------------------------------------------------------------- 1 | \name{FindReplace} 2 | \alias{FindReplace} 3 | \alias{Rnw2Rmd} 4 | \alias{UseTemplate} 5 | \alias{UseTemplateList} 6 | \title{Find/Replace text in a file} 7 | \usage{ 8 | FindReplace(file, find, replace) 9 | 10 | Rnw2Rmd(file) 11 | 12 | UseTemplate(file, find=NULL, replace=NULL) 13 | 14 | UseTemplateList(newfile, fileList, find=NULL, replace=NULL) 15 | } 16 | \arguments{ 17 | \item{file,fileList}{The external (text) file, template, or list of templates to be updated.} 18 | \item{newfile}{the file to write output to} 19 | 20 | \item{find}{The text to remove.} 21 | 22 | \item{replace}{The text to insert.} 23 | } 24 | \value{ 25 | FindReplace will replace the existing file with the updated version while UseTemplate will return a character string which will usually be pushed out to an R script or R markdown file. 26 | } 27 | \description{ 28 | Simple wrapper functions to make it easier to replace the text in a file, possibly due to spelling errors, but perhaps to replace default text in a template file. 29 | } 30 | \details{ 31 | The FindReplace function is purely intended for use on an external file whereas UseTemplate is intended to take a template file from within the BrailleR package and return the updated text to the calling environment. 32 | 33 | Rnw2Rmd tries to replace Standard LaTeX commands and Sweave chunk headers with R markdown ones. It is NOT comprehensive, but it does get a long way towards a useful markdown file. 34 | 35 | Obviously the specified file must exist for these functions to work. 36 | } 37 | \author{ 38 | A. Jonathan R. Godfrey 39 | } 40 | \examples{ 41 | UseTemplate("DTGroupSummary.R") 42 | UseTemplate("DTGroupSummary.R", "DataName", "MyData") 43 | } 44 | -------------------------------------------------------------------------------- /R/BrailleRUsefulLinks.R: -------------------------------------------------------------------------------- 1 | BrailleRHome = 2 | function() { 3 | if (interactive()) { 4 | browseURL("https://R-Resources.massey.ac.nz/BrailleR/") 5 | } else { 6 | .InteractiveOnly() 7 | } 8 | return(invisible(NULL)) 9 | } 10 | 11 | BrailleRInAction = 12 | function() { 13 | if (interactive()) { 14 | browseURL("https://R-Resources.massey.ac.nz/BrailleRInAction/") 15 | } else { 16 | .InteractiveOnly() 17 | } 18 | return(invisible(NULL)) 19 | } 20 | 21 | LURN = function(BlindVersion = getOption("BrailleR.VI")) { 22 | if (interactive()) { 23 | if (BlindVersion) { 24 | browseURL("https://R-Resources.massey.ac.nz/LURNBlind/") 25 | } else { 26 | browseURL("https://R-Resources.massey.ac.nz/LURN/") 27 | } 28 | } else { 29 | .InteractiveOnly() 30 | } 31 | return(invisible(NULL)) 32 | } 33 | 34 | 35 | 36 | google = Google = 37 | function() { 38 | if (interactive()) { 39 | browseURL("https://www.google.com") 40 | } else { 41 | .InteractiveOnly() 42 | } 43 | return(invisible(NULL)) 44 | } 45 | 46 | 47 | R4DS = r4ds = 48 | function() { 49 | if (interactive()) { 50 | browseURL("http://r4ds.had.co.nz/") 51 | } else { 52 | .InteractiveOnly() 53 | } 54 | return(invisible(NULL)) 55 | } 56 | 57 | 58 | WriteRHome = 59 | function() { 60 | if (interactive()) { 61 | browseURL("https://R-Resources.massey.ac.nz/WriteR/") 62 | } else { 63 | .InteractiveOnly() 64 | } 65 | return(invisible(NULL)) 66 | } 67 | -------------------------------------------------------------------------------- /man/UpdateGraph.Rd: -------------------------------------------------------------------------------- 1 | \name{UpdateGraph} 2 | \alias{UpdateGraph} 3 | \alias{Main} 4 | \alias{update.fittedlineplot} 5 | \alias{update.scatterplot} 6 | \alias{update.tsplot} 7 | \alias{XLab} 8 | \alias{YLab} 9 | \title{extract or alter graph parameters} 10 | \description{Either grabs the specified label or sets it to a newly specified value. In this case the graph is re-drawn and the graph object is updated.} 11 | \usage{ 12 | UpdateGraph(object, ...) 13 | 14 | Main(graph, label = NULL) 15 | 16 | XLab(graph, label = NULL) 17 | 18 | YLab(graph, label = NULL) 19 | } 20 | \arguments{ 21 | \item{graph,object}{The graph object to be updated.} 22 | \item{label}{the text to be used in place of the current text label. Use of the default NULL leads to the extraction of the current value and no updating is done.} 23 | \item{...}{the set of parameters to be altered.} 24 | } 25 | \details{ 26 | Specify the label to be an empty text string if the desire is to delete the current label.} 27 | \value{The graph object will be updated in the global environment if a new value is assigned.} 28 | \author{A. Jonathan R. Godfrey} 29 | \examples{ 30 | attach(airquality) 31 | op = par(mfcol=c(3,2)) 32 | #test1 = TimeSeriesPlot(x=Wind, col=4, base=TRUE) 33 | #XLab(test1, "Day") 34 | # check the change is permanent by doing another change 35 | #test1 |> Main("titles are important") # nice that the pipe works! 36 | 37 | #test2 = TimeSeriesPlot(x=Ozone, base=TRUE) 38 | # using the update method 39 | #update(test2, main="important title", sub="subtitles aren't always present", ylab="Ozone (ppb)") 40 | # finally, change the graph to use different plotting characters/line types 41 | #update(test2) # to fix 42 | par(op) 43 | detach(airquality) 44 | } 45 | -------------------------------------------------------------------------------- /man/GetExampleText.Rd: -------------------------------------------------------------------------------- 1 | \name{GetExampleText} 2 | \alias{GetExampleText} 3 | \title{extract the example text from a help page} 4 | \description{ 5 | A cut back version of example() for obtaining the text used in examples on help pages without running those examples. The function is intended to help write markdown/Sweave documents. } 6 | \usage{ 7 | GetExampleText(topic, package = NULL, lib.loc = NULL, character.only = FALSE, outFile="") 8 | } 9 | 10 | \arguments{ 11 | \item{topic}{name or literal character string: the online help topic the examples of which should be run.} 12 | \item{package}{a character vector giving the package names to look into for the topic, or NULL (the default), when all packages on the search path are used.} 13 | \item{lib.loc}{a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. If the default is used, the loaded packages are searched before the libraries.} 14 | \item{character.only}{a logical indicating whether topic can be assumed to be a character string.} 15 | \item{outFile}{an optional filename to save the results into. The default is to use a temporary file.} 16 | } 17 | \details{ 18 | The example() code was hacked back to form this utility function. It is probably a little heavy for what is needed but it works sufficiently at the time of creation.} 19 | \value{ 20 | a vector of character strings each element being one line of the examples from the corresponding help topic.} 21 | \author{The work of Martin Maechler and others got tampered with by A. Jonathan R. Godfrey} 22 | 23 | \seealso{ 24 | You may wish to compare this with \code{\link{example}} 25 | } 26 | \examples{ 27 | cat(paste(GetExampleText(mean), collapse="\n")) 28 | } 29 | -------------------------------------------------------------------------------- /man/SpellCheckFiles.Rd: -------------------------------------------------------------------------------- 1 | \name{SpellCheckFiles} 2 | \alias{SpellCheckFiles} 3 | \alias{print.wordlist} 4 | \title{Spell checking a file or all files within a specified folder} 5 | \usage{ 6 | SpellCheckFiles(file = ".", ignore = character(), 7 | local.ignore = TRUE, global.ignore = TRUE) 8 | 9 | \method{print}{wordlist}(x, ...) 10 | } 11 | \arguments{ 12 | \item{file}{The filename of an individual file, or an individual folder.} 13 | 14 | \item{ignore}{The character vector of words to be ignored by hunspell} 15 | 16 | \item{local.ignore}{Use a local file of words to be ignored. This file has the same name as the file with .ignore.txt tacked on the end and is colocated with the file being checked. If the file argument is set to a folder then the local.ignore can be set to the name of a file in the current working directory.} 17 | 18 | \item{global.ignore}{Use the global word list called words.ignore.txt found in the MyBrailleR folder} 19 | 20 | \item{x}{the object to be printed} 21 | \item{...}{other parameters pass to the print method} 22 | } 23 | \value{ 24 | A list object with each item of the list being the findings from spell checking each file. The words not found in the dictionary are given as well as the line numbers where they were found. 25 | } 26 | \description{ 27 | Check spelling using hunspell. A new print method is also used. 28 | } 29 | \details{ 30 | The global list of words to be ignored needs to be saved in the user's MyBrailleR folder. It can be updated as often as the user likes. It should have one word per line, and contain no space, tab or punctuation characters. 31 | } 32 | \author{ 33 | A. Jonathan R. Godfrey wrote these functions but leaned heavily on functions found in the devtools package. 34 | } 35 | \seealso{ 36 | The hunspell package and functions therein. 37 | } 38 | 39 | -------------------------------------------------------------------------------- /man/PrepareWriteR.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteR} 2 | \alias{PrepareWriteR} 3 | \alias{TestPython} 4 | \alias{TestWX} 5 | \alias{WriteR} 6 | \title{Getting started with WriteR} 7 | \description{The WriteR application was written in wxPython so that blind users can process Rmarkdown documents. This functionality is offered because RStudio is not an accessible application for screen reader users.} 8 | \usage{ 9 | WriteR(file = NULL, math = c("webTeX", "MathJax")) 10 | 11 | TestPython() 12 | TestWX() 13 | 14 | PrepareWriteR(Author = getOption("BrailleR.Author")) 15 | } 16 | \arguments{ 17 | \item{Author}{Your name as you want it to appear in the default text that starts your R markdown documents.} 18 | \item{file}{The filename you want started. Not implemented yet.} 19 | \item{math}{The style for mathematical content in HTML documents created using LaTeX input. Not yet implemented.} 20 | } 21 | \details{WriteR needs python and wxPython to run. Error handling for users without these packages installed is not yet incorporated in these functions. Please use \code{TestWX()} because it calls \code{TestPython()} as its first test. 22 | 23 | The \code{PrepareWriteR()} function writes the settings file (called WriteROptions) for WriteR and copies the files that were part of the BrailleR installation into the current working directory. You will be able to run the WriteR application from there, or move to a folder of your choosing.} 24 | \value{NULL. The \code{WriteR} function is for your convenience and not for doing any work inside an R session. The \code{TestWX()} function prints results but returns nothing. The \code{TestPython()} function returns a logical to say Python can be seen by your system.} 25 | \author{A. Jonathan R. Godfrey} 26 | \note{You must have Python and the associated wxPython installation on your system to use the WriteR application.} 27 | -------------------------------------------------------------------------------- /man/MakeRmdFiles.Rd: -------------------------------------------------------------------------------- 1 | \name{MakeRmdFiles} 2 | \alias{History2Qmd} 3 | \alias{History2Rmd} 4 | \alias{ProcessAllMd} 5 | \alias{ProcessAllRmd} 6 | \alias{R2Qmd} 7 | \alias{R2Rmd} 8 | \alias{RemoveBOM} 9 | \alias{rnw2Rmd} 10 | \title{Work flow convenience functions} 11 | \description{Time-saving functions that help create files in more useful formats for later use.} 12 | \usage{ 13 | History2Rmd(file = "History.Rmd") 14 | History2Qmd(file = "History.Qmd") 15 | 16 | R2Rmd(ScriptFile) 17 | R2Qmd(ScriptFile) 18 | 19 | ProcessAllMd(dir =".") 20 | ProcessAllRmd(dir =".", method = "render") 21 | 22 | RemoveBOM(file) 23 | } 24 | \arguments{ 25 | \item{dir}{The directory to find files.} 26 | \item{file}{the name of the file to be created or modified.} 27 | \item{method}{The method used to process Rmd files; one of "render" or "knit2html".} 28 | \item{ScriptFile}{the R script to be processed into the R markdown file.} 29 | } 30 | 31 | \details{The History2Rmd() function was intended for turning a short interactive R session into an R markdown file. Lines of code are all separated into distinct code chunks in the Rmd file. the resulting file will need to be edited if commands have spanned more than one line. 32 | 33 | The R2Rmd() function does try to limit the number of blank lines copied from the R script into the Rmarkdown file. The Rmd file may need some editing. 34 | 35 | Once all Rmd files have been edited, the user can have all the Rmd files in a folder processed using ProcessAllRmd(). A similar function ProcessAllMd() exists to process any plain markdown files which do not need knitting. 36 | } 37 | \value{NULL. These functions are for creating files in the current working directory.} 38 | \author{A. Jonathan R. Godfrey} 39 | \seealso{ 40 | These functions were inspired by the \code{\link[knitr]{spin}} functionality of the \pkg{knitr} package. You may wish to move onto using it for more features.} 41 | -------------------------------------------------------------------------------- /man/ViewSVG.Rd: -------------------------------------------------------------------------------- 1 | \name{ViewSVG} 2 | \alias{ViewSVG} 3 | 4 | \title{Create the necessary files to allow interactive viewing of SVG} 5 | \description{Copy files from the package folders to the current working directory and write a markdown file that contains the links to all accessible SVG files in the current directory.} 6 | \usage{ 7 | ViewSVG(file = "index") 8 | } 9 | \arguments{ 10 | \item{file}{The file basename to be used. This file will be made in the current directory.} 11 | } 12 | \details{ 13 | This will create a html file that has a list of the available svg in the current directory. This only supports the current working directory at the moment. However this is planned on changing in the future. To make the files you can use the \code{MakeAccessibleSVG()} function 14 | } 15 | \value{ 16 | NULL. This function exists for its side effects only. 17 | } 18 | \references{ 19 | Godfrey, A.J.R. (2013) \sQuote{Statistical Software from a Blind Person's Perspective: R is the Best, but we can make it better}, The R Journal 5(1), pp73-79. 20 | } 21 | \author{ 22 | A. Jonathan R. Godfrey and James A. Thompson 23 | } 24 | 25 | \examples{ 26 | library(ggplot2) 27 | 28 | # Make a few svg webpages 29 | tsplot = TimeSeriesPlot(airquality, x=airquality$Temp) 30 | MakeAccessibleSVG(tsplot, file = "tsplot") 31 | 32 | barChart = ggplot(Orange, aes(x = Tree)) + 33 | geom_bar() 34 | MakeAccessibleSVG(barChart, file = "barChart") 35 | 36 | histogram = ggplot(attenu, aes(x=dist)) + 37 | geom_histogram() 38 | histogram 39 | MakeAccessibleSVG(histogram, file="histogram") 40 | 41 | # Display the 'home' page 42 | ViewSVG() 43 | 44 | # Cleaning up afterwards 45 | # Created by the MakeAccessibleSVG (xml and svg are auto deleted) 46 | unlink("histogram.html") 47 | unlink("barChart.html") 48 | unlink("tsplot.html") 49 | unlink("index.html") # Created by the ViewSVG function 50 | } 51 | 52 | \seealso{ 53 | \code{\link{MakeAccessibleSVG}} 54 | } 55 | -------------------------------------------------------------------------------- /R/MakeQmdFiles.R: -------------------------------------------------------------------------------- 1 | 2 | History2Qmd = 3 | function(file = "History.Qmd") { 4 | if (interactive()) { 5 | TempFile = tempfile(fileext = "R") 6 | savehistory(TempFile) 7 | Lines = readLines(TempFile) 8 | LineNo = 1:length(Lines) 9 | cat(paste0('---\ntitle: "History from R session on ', format(Sys.Date(), "%A %d %B %Y"), 10 | '"\nauthor: "by ', getOption("BrailleR.Author"), '"\ndate: ', format(Sys.Date(), "%A %d %B %Y"), '\n---\n\n```{r setup, nclude=FALSE}\nlibrary(knitr) 11 | opts_chunk$set(comment="", fig.cap="to fix") 12 | ```\n\n'), file = file) 13 | cat(paste0("```{r} 14 | #| line", LineNo, "\n", Lines, "\n``` \n\n"), 15 | file = file, append = TRUE) 16 | .NewFile(file) 17 | return(file) 18 | } else { 19 | .InteractiveOnly() 20 | return(invisible(NULL)) 21 | } 22 | } 23 | 24 | 25 | R2Qmd = 26 | function(ScriptFile) { 27 | if (file.exists(ScriptFile)) { 28 | QmdFile = gsub(".Qmd", ".Qmd", paste0(ScriptFile, "md")) 29 | Lines = readLines(ScriptFile) 30 | NoLines = length(Lines) 31 | GoodLines = Lines > "" 32 | GoodLines2 = c(FALSE, GoodLines[1:(NoLines - 1)]) 33 | ShowLines = GoodLines | GoodLines2 34 | #if(Lines[1]=="") ShowLines[1]=FALSE 35 | Lines[Lines == ""] = "``` \n\n```{r} " 36 | Lines = Lines[ShowLines] 37 | 38 | cat(paste0('---\ntitle: ""\nauthor: "', getOption("BrailleR.Author"), '"\ndate: ', format(Sys.Date(), "%A %d %B %Y"), '\n---\n\n```{r}'), 39 | file = QmdFile) 40 | cat(paste0("\n", Lines, " "), file = QmdFile, append = TRUE) 41 | cat("\n# end of input \n``` \n\n", file = QmdFile, append = TRUE) 42 | .NewFile(file = QmdFile) 43 | return(QmdFile) 44 | } else { 45 | .FileDoesNotExist(file) 46 | return(invisible(NULL)) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /R/MakeRmdFiles.R: -------------------------------------------------------------------------------- 1 | History2Rmd = 2 | function(file = "History.Rmd") { 3 | if (interactive()) { 4 | TempFile = tempfile(fileext = "R") 5 | savehistory(TempFile) 6 | Lines = readLines(TempFile) 7 | LineNo = 1:length(Lines) 8 | cat(paste0('---\ntitle: "History from R session on ', format(Sys.Date(), "%A %d %B %Y"), 9 | '"\nauthor: "by ', getOption("BrailleR.Author"), '"\ndate: Updated on `r format(Sys.Date(), \'%A %d %B %Y\')`\n---\n\n```{r setup, include=FALSE}\nlibrary(knitr) 10 | opts_chunk$set(comment="", fig.cap="to fix") 11 | ```\n\n'), file = file) 12 | cat(paste0("```{r line", LineNo, "} \n", Lines, "\n``` \n\n"), 13 | file = file, append = TRUE) 14 | .NewFile(file = file) 15 | return(file) 16 | } else { 17 | .InteractiveOnly() 18 | return(invisible(NULL)) 19 | } 20 | } 21 | 22 | 23 | R2Rmd = 24 | function(ScriptFile) { 25 | if (file.exists(ScriptFile)) { 26 | RmdFile = gsub(".rmd", ".Rmd", paste0(ScriptFile, "md")) 27 | Lines = readLines(ScriptFile) 28 | NoLines = length(Lines) 29 | GoodLines = Lines > "" 30 | GoodLines2 = c(FALSE, GoodLines[1:(NoLines - 1)]) 31 | ShowLines = GoodLines | GoodLines2 32 | #if(Lines[1]=="") ShowLines[1]=FALSE 33 | Lines[Lines == ""] = "``` \n\n```{r } " 34 | Lines = Lines[ShowLines] 35 | 36 | cat(paste0('---\ntitle: ""\nauthor: "', getOption("BrailleR.Author"), '"\ndate: `r format(Sys.Date(), \'%A %d %B %Y\')`\n---\n\n```{r }'), 37 | file = RmdFile) 38 | cat(paste0("\n", Lines, " "), file = RmdFile, append = TRUE) 39 | cat("\n# end of input \n``` \n\n", file = RmdFile, append = TRUE) 40 | .NewFile(file = RmdFile) 41 | return(RmdFile) 42 | } else { 43 | .FileDoesNotExist() 44 | return(invisible(NULL)) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /R/Callback.R: -------------------------------------------------------------------------------- 1 | # with much help from Gabe Becker 2 | BrailleR <- NULL 3 | 4 | 5 | ShowMe <- function(file = NULL, n=1) { 6 | if (interactive()) { 7 | if(is.null(file)){ file = paste0(tempfile(), ".txt")} 8 | .SessionLogWorker(file = file, n=n) 9 | browseURL(file) 10 | } else { 11 | .InteractiveOnly() 12 | } 13 | return(invisible(NULL)) 14 | } 15 | 16 | 17 | GrabLast <- function(file = "", n=1) { 18 | if (interactive()) { 19 | .SessionLogWorker(file = file, n=n) 20 | } else { 21 | .InteractiveOnly() 22 | } 23 | return(invisible(NULL)) 24 | } 25 | 26 | SessionLog <- function(file = "", n=NULL) { 27 | if (interactive()) { 28 | .SessionLogWorker(file = file, n=NULL) 29 | } else { 30 | .InteractiveOnly() 31 | } 32 | return(invisible(NULL)) 33 | } 34 | 35 | .SessionLogWorker <- function(file = "", n=NULL) { 36 | df <- .get_session_log() 37 | if(!is.null(n)){ 38 | NRows = nrow(df) 39 | df = df[(NRows+1-n): NRows, ] 40 | } 41 | mapply(function(expr, pr) cat(c(paste(">", paste(expr, collapse = "\n")), pr, ""), sep = "\n", file = file), 42 | expr = df$expr, 43 | pr = df$pr_output) 44 | invisible(NULL) 45 | } 46 | 47 | 48 | .callback <- function(expr, value, success, printed, env) { 49 | if(!success) 50 | return(TRUE) 51 | 52 | if(printed) 53 | prout <- tryCatch(capture.output(print(value)), error = function(e) "error during callback") 54 | else 55 | prout <- "" 56 | rw <- data.frame(expr = I(list(deparse(expr))), 57 | val_class = I(list(class(value))), 58 | pr_output = I(list(prout))) 59 | if(exists("session_log", env)) 60 | env$session_log <- c(env$session_log,list(rw)) 61 | else 62 | env$session_log <- list(rw) 63 | TRUE 64 | } 65 | 66 | 67 | .get_session_log <- function() { 68 | do.call(rbind, BrailleR$session_log) 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /R/GettingStarted.R: -------------------------------------------------------------------------------- 1 | GetGoing = 2 | function() { 3 | if (interactive()) { 4 | .AnswerQuestionsMSG() 5 | 6 | .AuthorNameMSG() 7 | name = readLines(n = 1) 8 | if (name != "") SetAuthor(name) 9 | 10 | .PValueDigitsMSG() 11 | 12 | digits = as.numeric(readLines(n = 1)) 13 | if (!is.na(digits)) SetSigLevel(digits) 14 | 15 | .DefaultSignificanceMSG() 16 | alpha = as.numeric(readLines(n = 1)) 17 | if (!is.na(alpha)) SetSigLevel(alpha) 18 | 19 | message( 20 | "\nThe following questions are yes/no questions. Use T or TRUE for yes, F or FALSE for no.") 21 | 22 | message( 23 | "\nDo you want to process R scripts and Rmd files outside R? (TRUE)") 24 | batch = as.logical(readLines(n = 1)) 25 | if (is.na(batch)) batch = TRUE 26 | if (batch) MakeBatch() 27 | 28 | message( 29 | "\nDo you want to incorporate output from R into LaTeX files? (TRUE)") 30 | latex = as.logical(readLines(n = 1)) 31 | if (is.na(latex)) latex = TRUE 32 | if (latex) { 33 | LatexOn() 34 | } else { 35 | LatexOff() 36 | } 37 | 38 | message( 39 | "\nDo you want to automatically open HTML files of R output? (TRUE)") 40 | view = as.logical(readLines(n = 1)) 41 | if (is.na(view)) view = TRUE 42 | if (view) { 43 | ViewOn() 44 | } else { 45 | ViewOff() 46 | } 47 | 48 | message( 49 | "\nBrailleR assumes you are blind. Is this how you will work? (TRUE)") 50 | vi = as.logical(readLines(n = 1)) 51 | if (is.na(vi)) vi = TRUE 52 | if (vi) { 53 | GoBlind() 54 | } else { 55 | GoSighted() 56 | } 57 | 58 | 59 | #end interactive section. 60 | } else { 61 | .InteractiveOnly() 62 | } 63 | return(invisible(NULL)) 64 | } 65 | -------------------------------------------------------------------------------- /man/DataViewer.Rd: -------------------------------------------------------------------------------- 1 | \name{DataViewer} 2 | \alias{DataViewer} 3 | \title{Open a data object in your chosen spreadsheet software} 4 | \description{ 5 | The chosen data object (data.frame, matrix, or vector) is stored in a temporary csv file. The file is opened while the R terminal/console is suspended until the key is pressed. This should be done once the spreadsheet software has been closed so that the temporary file is removed and the data object gets updated from the edited csv file. The user must save the csv file if changes are made.} 6 | \usage{ 7 | DataViewer(x, Update = FALSE, New = NULL, Filename = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{an object of class data.frame, matrix, or vector. A check is made for this condition.} 11 | \item{Update}{Logical. Will changes made in the spreadsheet editor be returned to the R session.} 12 | \item{New}{If Update=TRUE, the original object will be replaced unless a name for a new object is given. N.B. the default is to overwrite the original object.} 13 | \item{Filename}{Provide a filename if desired. N.B. this does not guarantee that the csv file will be kept. Do not use this function as a shortcut for saving csv files.} 14 | } 15 | \details{The following steps should be taken if the intention is to view and possibly edit a data.frame, matrix, or vector: 16 | 17 | There are a few quirks with respect to variables that could be interpreted as factors. The process of updating is to write a csv file using code \link{write.csv}() and then read it back using code \link{read.csv}() after it has been edited. Users must be aware that factors may not register as such, or that character vectors may be interpreted as factors. 18 | } 19 | \value{If code Update=TRUE and code New=NULL, the original data object is overwritten. To create a new object the user must specify code New.} 20 | \author{A. Jonathan R. Godfrey \email{a.j.godfrey@massey.ac.nz}} 21 | \examples{ 22 | \donttest{ 23 | data(airquality) 24 | DataViewer(airquality, Update=TRUE, New="NewAirQuality") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /R/SpellCheckFiles.R: -------------------------------------------------------------------------------- 1 | ## need to fix this to revert to spelling package 2 | 3 | SpellCheckFiles = 4 | function(file = ".", ignore = character(), local.ignore = TRUE, 5 | global.ignore = TRUE) { 6 | ignore <- c(hunspell::en_stats, ignore) 7 | if (global.ignore) { 8 | globalIgnoreFile = 9 | paste0(getOption("BrailleR.Folder"), "words.ignore.txt") 10 | if (file.exists(globalIgnoreFile)) { 11 | ignore = c(ignore, read.table(globalIgnoreFile, 12 | colClasses = "character")[, 1]) 13 | } 14 | } 15 | if (dir.exists(file)) { 16 | filenames = list.files(file) 17 | checkFiles <- normalizePath(paste0(file, "/", filenames)) 18 | if (file.exists(as.character(local.ignore))) { 19 | ignore = 20 | c(ignore, read.table(local.ignore, colClasses = "character")[, 1]) 21 | } 22 | } else { 23 | filenames = checkFiles <- file 24 | localIgnoreFile = paste0(filenames, ".ignore.txt") 25 | if (file.exists(localIgnoreFile)) { 26 | ignore = c(ignore, 27 | read.table(localIgnoreFile, colClasses = "character")[, 1]) 28 | } 29 | } 30 | # a little hack because Hadley doesn't want to export spell_check_files from the devtools package 31 | # NS = getNamespace("devtools") 32 | # spell_check_file = get("spell_check_file", NS) 33 | checkLines = list() 34 | checkLines <- lapply( 35 | checkFiles, spelling::spell_check_files, ignore = ignore, dict="en_us") 36 | names(checkLines) = filenames 37 | class(checkLines) = c("wordlist", "data.frame") 38 | return(checkLines) 39 | } 40 | 41 | 42 | 43 | 44 | 45 | print.wordlist = 46 | function(x, ...) { 47 | for (i in 1:length(x)) { 48 | cat(paste0("File: ", names(x)[i], "\n")) 49 | cat(paste0(names(x[[i]]), " ", gsub(",", " ", x[[i]]), "\n")) 50 | } 51 | return(invisible(x)) 52 | } 53 | 54 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://ajrgodfrey.github.io/BrailleR/ 2 | template: 3 | bootstrap: 5 4 | 5 | articles: 6 | - title: Use BrailleR 7 | navbar: ~ 8 | contents: 9 | - ExploringGraphs 10 | - IntroWriteR 11 | - BrailleRHistory 12 | - title: Examples 13 | desc: > 14 | Various sets of example pages 15 | contents: 16 | - starts_with("Ex") 17 | - qplot 18 | 19 | reference: 20 | - title: Explore Graphs 21 | desc: Explore ggplot graphs in accessible ways. 22 | contents: 23 | - VI 24 | - sort.VIgraph 25 | - grep.VIgraph 26 | - Describe 27 | - MakeAccessibleSVG 28 | - BrowseSVG 29 | - SVGThis 30 | - ViewSVG 31 | - AddXML 32 | - WTF 33 | - summary.recordedplot 34 | 35 | - title: Graph and analysis shortcuts 36 | desc: Functions to help speed up graph making and analysis tasks 37 | contents: 38 | - boxplot 39 | - dotplot 40 | - hist 41 | - OneFactor 42 | - OnePredictor 43 | - ScatterPlot 44 | - ThreeFactors 45 | - TimeSeriesPlot 46 | - TwoFactors 47 | - UniDesc 48 | - WhereXY 49 | 50 | - title: Shortcuts / Macros 51 | desc: Other shortcut functions to speed up common task 52 | contents: 53 | - BrailleRUsefulLinks 54 | - DataViewer 55 | - Premier100 56 | - FindReplace 57 | - GetExampleText 58 | - Get7zip 59 | - history 60 | - JoinBlindRUG 61 | - MakeBatch 62 | - MakeReadable 63 | - History2Rmd 64 | - NewFunction 65 | - Notepad 66 | - PandocAll 67 | - pdf2html 68 | - txtStart 69 | - Require 70 | - ChooseEmbosser 71 | - SpellCheck 72 | - SpellCheckFiles 73 | - UpdateGraph 74 | - CheckIt 75 | - WhichFile 76 | - AutoSpellCheck 77 | - FindCSSFile 78 | - BRLThis 79 | - CleanCSV 80 | - MakeAllFormats 81 | - MakeSlideShow 82 | - unfinished 83 | - SessionLog 84 | 85 | - title: BrailleR related 86 | desc: All other function not otherwise categorized 87 | contents: 88 | - BrailleR 89 | - SetupBrailleR 90 | - GetGoing 91 | - MakeRprofile 92 | - GoBlind 93 | - WriteR 94 | - Deprecated 95 | - AugmentMethod 96 | -------------------------------------------------------------------------------- /man/hist.Rd: -------------------------------------------------------------------------------- 1 | \name{hist} 2 | \alias{hist} 3 | \title{Create a standard histogram with a few extra elements added to the output object} 4 | \description{This function is a wrapper to the standard \code{hist()} function in the \pkg{graphics} package. It adds detail to the stored object so that a better text description can be formulated using the \code{VI()} method in the \pkg{BrailleR} package.} 5 | \usage{ 6 | hist(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{a numeric variable.} 10 | \item{\dots}{ 11 | additional arguments passed on to the plotting function.} 12 | } 13 | \details{ 14 | This function masks the function of the same name in the \pkg{graphics} package. Even though the base R implementation does create an object of class histogram, the object does not store all graphical arguments that are passed to the \code{hist()} function. The functionality should be no different at all for anyone who is not using the \code{VI()} function to gain a more detailed text description of the histogram. See the help page for the graphics::hist() function to get a more complete description of histogram creation.} 15 | \value{ 16 | An object of class histogram as per the \code{hist()} function from the \pkg{graphics} package, with the addition of any calls to the main title or axis labels.} 17 | \references{ 18 | Godfrey, A.J.R. (2013) \sQuote{Statistical Software from a Blind Person's Perspective: R is the Best, but we can make it better}, The R Journal 5(1), pp73-79. 19 | } 20 | \author{ 21 | A. Jonathan R. Godfrey 22 | } 23 | 24 | 25 | \seealso{ 26 | The base R implementation of the \code{\link[graphics]{hist}} function should be consulted, using the entry in the \pkg{\link{graphics}} package 27 | } 28 | \examples{ 29 | x=rnorm(1000) 30 | # the stamdard hist function returns 31 | MyHist=graphics::hist(x, xlab="random normal values", main="Example histogram (graphics package)") 32 | MyHist 33 | 34 | # while this version returns 35 | MyHist=hist(x, xlab="random normal values", main="Example histogram (BrailleR package)") 36 | MyHist 37 | 38 | # The VI() method then uses the extra information stored 39 | VI(MyHist) 40 | } 41 | -------------------------------------------------------------------------------- /R/BaseGraphics.R: -------------------------------------------------------------------------------- 1 | # making sure the old style graphics are presented as the right text strings 2 | # colours (col), line types (lty), plotting character (pch) symbols 3 | # need to add bty, 4 | 5 | .ColourText = function(x){ 6 | for(Colour in 1:length(x)){ 7 | xx=x[Colour] 8 | XXX = as.integer(xx) 9 | if(!is.na(XXX)){ 10 | x[Colour]=.BaseColourText[XXX+1] 11 | } else if (is.character(xx)) { 12 | x[Colour]=tolower(xx) 13 | } else { 14 | stop("incorrect input value") 15 | } 16 | } 17 | return(x) 18 | } 19 | 20 | .BaseColourText = c("white", "black", "red", "green", "blue", "cyan", "magenta", "yellow", "grey") 21 | names(.BaseColourText) = .BaseColourText 22 | 23 | 24 | .LineTypeText = function(x){ 25 | for(LineType in 1:length(x)){ 26 | xx=x[LineType] 27 | XXX = as.integer(xx) 28 | if(!is.na(XXX)){ 29 | x[LineType]=.BaseLineTypeText[XXX+1] 30 | } else if (is.character(xx)) { 31 | x[LineType]=tolower(xx) 32 | } else { 33 | stop("incorrect input value") 34 | } 35 | } 36 | return(x) 37 | } 38 | 39 | .BaseLineTypeText = c("blank", "solid", "dashed", "dotted", "dotdash", "longdash", "twodash") 40 | names(.BaseLineTypeText) = .BaseLineTypeText 41 | 42 | 43 | .SymbolText = function(x){ 44 | for(Symbol in 1:length(x)){ 45 | xx=x[Symbol] 46 | XXX = as.integer(xx) 47 | if(!is.na(XXX)){ 48 | x[Symbol]=.BaseSymbolText[XXX+1] 49 | } else if (is.character(xx)) { 50 | x[Symbol]=tolower(xx) 51 | } else { 52 | stop("incorrect input value") 53 | } 54 | } 55 | return(x) 56 | } 57 | 58 | .BaseSymbolText = c("square", "circle", "triangle point up", "plus", "cross", "diamond", "triangle point down", "square cross", "star", "diamond plus", "circle plus", "square plus", "triangle plus", "star plus", "circle cross", "square cross", "filled square", "filled circle", "filled triangle point up", "filled diamond", "filled triangle point down", "filled circle plus", "filled square plus", "filled diamond plus", "filled triangle plus", "filled star", "filled square cross") 59 | names(.BaseSymbolText) = .BaseSymbolText 60 | 61 | 62 | .BaseBoxTypeText = c("n"="none", "o"="all", "l"="bottom-left", "7"="top-right", "c"="all but right", "u"="all but top", "]"="all but left") 63 | -------------------------------------------------------------------------------- /R/TSPlot.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | TimeSeriesPlot = function(.data, x, time=NULL, base=FALSE, ...){ 4 | Out = list() 5 | MC = match.call(expand.dots = TRUE) 6 | if(base){ 7 | Out = list(x=as.ts(x)) 8 | MC$ylab= ifelse(is.null(MC$ylab), as.character(MC$x), MC$ylab) 9 | MC[[1L]] <- quote(graphics::plot) 10 | MC$x <- Out$x 11 | 12 | Out$graph <- eval(MC, envir=parent.frame()) 13 | 14 | Out$par = par() 15 | class(Out) = "tsplot" 16 | if (length(MC$main) > 0) Out$main = as.character(MC$main) else {Out$main = ""} 17 | if (length(MC$sub) > 0) Out$sub = as.character(MC$sub) 18 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) else {Out$xlab = "Time"} 19 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 20 | Out=Augment(Out) 21 | } 22 | else{ ## do it in ggplot2 23 | MC$ylab = ifelse(is.null(MC$ylab), tail(strsplit(as.character(MC$x), "$"),n=1), MC$ylab) 24 | if (length(MC$sub) > 0) Out$sub = as.character(MC$sub) 25 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) else {Out$xlab = "Time"} 26 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 27 | if (length(MC$main) > 0) Out$main = as.character(MC$main) 28 | 29 | #Special care has to be taken if it is a dataframe 30 | if (is.ts(.data)) { 31 | #Sort out data frame 32 | .data = data.frame(Y=as.matrix(.data), date=time(.data)) 33 | time = .data$date 34 | x = .data$Y 35 | #Get correct ylab 36 | Out$ylab = ifelse(is.null(MC$ylab[[1]]), deparse(MC$.data), MC$ylab) 37 | } else if (!is.data.frame(.data)) { 38 | x = .data 39 | .data = data.frame(x=x) 40 | } 41 | 42 | if (is.null(time)) time = 1:length(x) 43 | 44 | Out = ggplot(.data, aes(y=x, x=time)) + 45 | geom_line() + 46 | ylab(Out$ylab) + xlab(Out$xlab) + 47 | labs(title=Out$main, subtitle=Out$sub) 48 | } 49 | return(invisible(Out)) 50 | } 51 | 52 | plot.tsplot = function(x, ...){ 53 | x = .RemoveExtraGraphPars(x) # see ScatterPlot.R for this function 54 | suppressWarnings(do.call(plot, x)) 55 | return(invisible(x)) 56 | } 57 | 58 | print.tsplot = plot.tsplot 59 | -------------------------------------------------------------------------------- /R/WhereXY.R: -------------------------------------------------------------------------------- 1 | WhereXY = 2 | function(x, y = NULL, grid = c(4, 4), xDist = "uniform", yDist = xDist, 3 | addmargins = TRUE) { 4 | 5 | if (is.null(y)) { 6 | x = as.matrix(x) 7 | if (length(x[1, ]) != 2) { 8 | .NoYNeeds2X() 9 | } 10 | y = x[, 2] 11 | if (!is.numeric(y)) { 12 | .XOrYNotNumeric(which="y") 13 | } 14 | x = x[, 1] 15 | if (!is.numeric(x)) { 16 | .XOrYNotNumeric(which="x") 17 | } 18 | } 19 | XMin = min(x, na.rm = TRUE) 20 | YMin = min(y, na.rm = TRUE) 21 | XMax = max(x, na.rm = TRUE) 22 | YMax = max(y, na.rm = TRUE) 23 | XRange = XMax - XMin 24 | YRange = YMax - YMin 25 | 26 | if (xDist == "uniform") { 27 | XNew = cut(x, breaks = grid[1], labels = FALSE) 28 | } else { 29 | XMean = mean(x, na.rm = TRUE) 30 | XSD = sd(x, na.rm = TRUE) 31 | XBreaks = c((1 - 0.1 * sign(XMin)) * XMin, 32 | XMean + XSD * qnorm((1:(grid[1] - 1)) / grid[1]), 33 | (1 + 0.1 * sign(XMax)) * XMax) 34 | XNew = cut(x, breaks = XBreaks, labels = FALSE) 35 | } 36 | 37 | if (yDist == "uniform") { 38 | #YBreaks <- seq(YMax+0.001*YRange,YMin-0.001*YRange, length.out=grid[2]+1) 39 | YNew = cut(y, breaks = grid[2], labels = FALSE) 40 | } #cut(y,breaks=YBreaks, labels=FALSE)} 41 | else { 42 | YMean = mean(y, na.rm = TRUE) 43 | YSD = sd(y, na.rm = TRUE) 44 | YBreaks = c((1 - 0.1 * sign(YMin)) * YMin, 45 | YMean + YSD * qnorm((1:(grid[2] - 1)) / grid[2]), 46 | (1 + 0.1 * sign(YMax)) * YMax) 47 | YNew = cut(y, breaks = YBreaks, labels = FALSE) 48 | } 49 | 50 | XNew <- factor(XNew, levels = c(1:grid[1])) 51 | YNew <- factor(YNew, levels = c(1:grid[2])) 52 | Output = tapply(x, list(YNew, XNew), length) 53 | Output[is.na(Output)] = 0 54 | Output = Output[rev(1:grid[2]), ] 55 | if (addmargins) { 56 | Output = addmargins(Output) 57 | } 58 | return(Output) 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /R/MakeAccessibleSVGMethod.R: -------------------------------------------------------------------------------- 1 | 2 | MakeAccessibleSVG <- function(x, file = paste0(deparse(substitute(x)), "-SVG"), view = interactive(), cleanup = TRUE, ...) { 3 | UseMethod("MakeAccessibleSVG") 4 | } 5 | 6 | MakeAccessibleSVG.default <- 7 | function(x, file = paste0(deparse(substitute(x)), "-SVG"), view = interactive(), cleanup = TRUE, ...) { 8 | svgfile <- SVGThis(x, paste0(file, ".svg")) 9 | xmlfile <- AddXML(x, paste0(file, ".xml")) 10 | BrowseSVG(file = file, view = view, ...) 11 | .SVGAndXMLMade() 12 | if (cleanup) { 13 | unlink(paste0(file, ".xml")) 14 | unlink(paste0(file, ".svg")) 15 | } 16 | return(invisible(NULL)) 17 | } 18 | 19 | MakeAccessibleSVG.histogram <- MakeAccessibleSVG.scatterplot <- MakeAccessibleSVG.default 20 | 21 | MakeAccessibleSVG.tsplot <- 22 | function(x, file = paste0(deparse(substitute(x)), "-SVG"), view = interactive(), cleanup = TRUE, ...) { 23 | svgfile <- SVGThis(x, paste0(file, ".svg")) 24 | if (x$Continuous) { 25 | .RewriteSVG.tsplot(x, paste0(file, ".svg")) 26 | } 27 | xmlfile <- AddXML(x, paste0(file, ".xml")) 28 | BrowseSVG(file = file, view = view, ...) 29 | .SVGAndXMLMade() 30 | if (cleanup) { 31 | unlink(paste0(file, ".xml")) 32 | unlink(paste0(file, ".svg")) 33 | } 34 | return(invisible(NULL)) 35 | } 36 | 37 | MakeAccessibleSVG.ggplot <- 38 | function(x, file = paste0(deparse(substitute(x)), "-SVG"), view = interactive(), cleanup = TRUE, VI_and_Describe = TRUE, ...) { 39 | pdf(NULL) # create non-displaying graphics device for SVGThis and AddXML 40 | svgfile <- SVGThis(x, paste0(file, ".svg"), createDevice = FALSE) 41 | xmlfile <- AddXML(x, paste0(file, ".xml")) 42 | dev.off() # destroy graphics device, now that we're done with it 43 | 44 | if (VI_and_Describe) { 45 | BrowseSVG(file = file, view = view, ggplot_object = x, ...) 46 | } else { 47 | BrowseSVG(file = file, view = view, ...) 48 | } 49 | 50 | 51 | .SVGAndXMLMade() 52 | 53 | if (cleanup) { 54 | unlink(paste0(file, ".xml")) 55 | unlink(paste0(file, ".svg")) 56 | } 57 | return(invisible(NULL)) 58 | } 59 | -------------------------------------------------------------------------------- /man/AddXMLMethod.Rd: -------------------------------------------------------------------------------- 1 | \name{AddXMLMethod} 2 | \alias{AddXML} 3 | \alias{AddXML.default} 4 | \alias{AddXML.boxplot} 5 | \alias{AddXML.dotplot} 6 | \alias{AddXML.eulerr} 7 | \alias{AddXML.ggplot} 8 | \alias{AddXML.histogram} 9 | \alias{AddXML.scatterplot} 10 | \alias{AddXML.tsplot} 11 | 12 | \title{Create XML files to sit alongside SVG files in order to make an accessible graph experience.} 13 | \description{Creates the necessary XML file for a graph object (as long as it has a class assigned)} 14 | \usage{ 15 | AddXML(x, file) 16 | } 17 | \arguments{ 18 | \item{x}{a graph object for which a method exists} 19 | \item{file}{The XML file to be created.} 20 | } 21 | \details{ 22 | It will create a xml file which has useful information for creating a accessible svg graph experience. However for it to work properly the \code{SVGThis} and \code{BrowseSVG} function must also be used. As can be seen in the examples it takes a bit of verbose code to use this function. To create easy exploration webpages of a graph use \code{MakeAccessibleSVG}. 23 | } 24 | \value{NULL. This function is solely for the purpose of creating XML files in the current working directory or in a path of the user's choosing.} 25 | \references{ 26 | P. Dengler et al. (2011) Scalable vector graphics (SVG) 1.1, second edition. W3C recommendation, W3C. http://www.w3.org/TR/2011/REC-XML11-20110816/ 27 | } 28 | \author{Volker Sorge, A. Jonathan R. Godfrey and James Thompson} 29 | 30 | \examples{ 31 | library(ggplot2) 32 | library(grid) 33 | 34 | # Create a simple histogram plot 35 | simpleHist = data.frame(x=rnorm(1e2)) |> 36 | ggplot(aes(x=x)) + 37 | geom_histogram() 38 | 39 | # Open a new PDF device, but 40 | #discard the output instead of saving it to a file 41 | pdf(NULL) 42 | 43 | # Plot the ggplot object on the current device 44 | simpleHist 45 | 46 | # Force the plot to be drawn on the device, 47 | #even though the output is being discarded 48 | grid.force() 49 | 50 | # Export the plot to an XML file 51 | AddXML(simpleHist, file = "histogram.xml") 52 | 53 | # Close the current PDF graphic device 54 | dev.off() 55 | 56 | #Cleaning up afterwards 57 | unlink("histogram.xml") 58 | } 59 | 60 | \seealso{ 61 | \code{\link{MakeAccessibleSVG}} 62 | } 63 | -------------------------------------------------------------------------------- /vignettes/Ex4SingleResponseOneGroupingFactor.rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The BrailleR package Example 4" 3 | author: "A. Jonathan R. Godfrey" 4 | bibliography: BrailleRPublications.bib 5 | vignette: > 6 | %\VignetteIndexEntry{Example 4: A single continuous response with one grouping factor} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | output: knitr:::html_vignette 9 | --- 10 | 11 | ```{r setup, include=FALSE} 12 | library(knitr) 13 | opts_chunk$set(fig.width=7, fig.height=5, comment="") 14 | library(BrailleR) 15 | ``` 16 | 17 | ## Analysis of a single continuous variable with respect to a single grouping factor 18 | 19 | There are many commands needed to get the numeric and graphic summary measures that might be required to collect all relevant information on a single numeric variable when it might depend on a grouping factor. The OneFactor() command has been written as a shortcut for a blind user who wishes to obtain: 20 | - the counts of observations within each group, 21 | - the mean, standard deviation and standard error for each group, 22 | - boxplots and/or dotplots, 23 | - the one-way analysis of variance, and 24 | - Tukey's Honestly Significant Difference (HSD) test on the significance of the between group differences. 25 | 26 | In addition, the blind user may need any/all of the graphs in a variety of formats (png, pdf, eps, or svg), nicely formatted tables for insertion into documents (LaTeX or HTML), and access to the code that generated these graphs and tables (an R script). 27 | 28 | The OneFactor() function can deliver all of this with minimal effort from the user. In addition, the output HTML file is opened automatically if using R interactively, giving the blind user immediate access to the information. The content is presented using sufficiently marked up HTML code including headings and tables so that the blind user can make best use of their screen reading software. All graphs included in the HTML file can be presented using a text description available from the VI() functionality of the BrailleR package. 29 | 30 | 31 | The main output document (HTML) can be viewed by issuing the command 32 | ```{r Example, eval=FALSE} 33 | example(OneFactor) 34 | ``` 35 | while running R interactively. 36 | 37 | 38 | -------------------------------------------------------------------------------- /man/ThreeFactors.Rd: -------------------------------------------------------------------------------- 1 | \name{ThreeFactors} 2 | \alias{ThreeFactors} 3 | \title{A convenience function for a Three-way analysis} 4 | \description{Prepares an analysis of a data set with one response and three predictors that are all factors. Interactions between the Three factors are also allowed for. The function creates a number of graphs and tables relevant for the analysis.} 5 | \usage{ 6 | ThreeFactors(Response, Factor1, Factor2, Factor3, Data = NULL, Filename = NULL, 7 | Folder = NULL, VI = getOption("BrailleR.VI"), Latex = getOption("BrailleR.Latex"), 8 | View = getOption("BrailleR.View"), Modern=TRUE) 9 | } 10 | \arguments{ 11 | \item{Response}{Name of the continuous response variable.} 12 | \item{Factor1, Factor2, Factor3}{Name the three factors to be included.} 13 | \item{Data}{Name the data.frame that includes the three variables of interest.} 14 | \item{Filename}{Name of the Rmarkdown and HTML files to be created. A default will be created that uses the names of the variables if this is left set to NULL.} 15 | \item{Folder}{Name of the folder to store graph and LaTeX files. A default will be created based on the name of the data.frame being used.} 16 | \item{VI}{Logical: Should the VI method for blind users be employed?} 17 | \item{Latex}{Logical: Should the tabulated sections be saved in LaTeX format?} 18 | \item{View}{Logical: Should the HTML file be opened for inspection?} 19 | \item{Modern}{Logical: Should the graphics be created using ggplot?} 20 | } 21 | \details{ 22 | to complete} 23 | \value{This function is used for creation of the files saved in the working directory and a few of its subdirectories.} 24 | \author{A. Jonathan R. Godfrey and Timothy P. Bilton} 25 | 26 | \seealso{ 27 | The \code{\link{OneFactor}} script was the basis for this function;. 28 | } 29 | \examples{ 30 | DIR = getwd() 31 | setwd(tempdir()) 32 | TestData=data.frame(Resp=sample(54), expand.grid(F1=c("a","b","c"), 33 | F2=c("d","e","f"), F3=c("g","h","i"), rep=c(1,2))) 34 | attach(TestData) 35 | ThreeFactors(Resp,F1,F2,F3) 36 | detach(TestData) 37 | rm(TestData) 38 | # N.B. Various files and a folder were created in a temporary directory. 39 | # Please investigate them to see how this function worked. 40 | setwd(DIR) 41 | } 42 | -------------------------------------------------------------------------------- /man/BrowseSVG.Rd: -------------------------------------------------------------------------------- 1 | \name{BrowseSVG} 2 | \alias{BrowseSVG} 3 | 4 | \title{Merge svg and xml file in html file} 5 | \description{Creates a single HTML file that embeds an SVG diagram and 6 | its XML annotations. Then launches a browser tab to allow viewing and 7 | interactive exploration of the SVG diagram.} 8 | \usage{ 9 | BrowseSVG(file="test", key=TRUE, footer = TRUE, view=interactive(), ggplot_object = NULL) 10 | } 11 | \arguments{ 12 | \item{file}{the filename for the HTML file; this should correspond to 13 | basename of an existing SVG and its XML annotations} 14 | \item{key}{include key for explorer's keyboard commands in webpage} 15 | \item{footer}{Whether the footer should be showed at bottom of webpage} 16 | \item{view}{launch in browser; this is the default when running in an interactive session} 17 | \item{ggplot_object}{This is the plot that the svg and XML are based off. If it is included than there will be the VI and the Describe information in the webpage.} 18 | 19 | } 20 | \details{ 21 | A HTML file is written in the current working directory. This HTML file will have the embeded svg and xml files as well as the javascript (diagcess) to help with the exploration of the graph. Note that it is required that you already have a svg and xml file in the current directory for it to work. 22 | 23 | It is much easier however to just use the \code{MakeAccessibleSVG} function directly which does it all for you} 24 | \value{ 25 | NULL. This function exists for its side effects only. 26 | } 27 | \author{ 28 | Volker Sorge and James A. Thompson 29 | } 30 | 31 | \examples{ 32 | library(ggplot2) 33 | simpleHist = data.frame(x=rnorm(1e2)) |> 34 | ggplot(aes(x=x)) + 35 | geom_histogram() 36 | file = "histogram" 37 | pdf(NULL) # create non-displaying graphics device for SVGThis and AddXML 38 | svgfile = SVGThis(simpleHist, paste0(file, ".svg"),createDevice=FALSE) 39 | xmlfile = AddXML(simpleHist, paste0(file, ".xml")) 40 | dev.off() # destroy graphics device, now that we're done with it 41 | 42 | BrowseSVG(file) 43 | 44 | #Cleaing up from BrowseSVG 45 | unlink(paste0(file, ".svg")) 46 | unlink(paste0(file, ".xml")) 47 | unlink(paste0(file, ".html")) 48 | } 49 | 50 | \seealso{ 51 | \code{\link{MakeAccessibleSVG}, \link{SVGThis}, \link{AddXML}} 52 | } 53 | -------------------------------------------------------------------------------- /man/Describe.Rd: -------------------------------------------------------------------------------- 1 | \name{Describe} 2 | \alias{Describe} 3 | \alias{Describe.default} 4 | \alias{Describe.aov} 5 | \alias{Describe.boxplot} 6 | \alias{Describe.dotplot} 7 | \alias{Describe.histogram} 8 | \alias{Describe.lm} 9 | \alias{Describe.matrix} 10 | \alias{Describe.scatterplot} 11 | \alias{Describe.summary.lm} 12 | \alias{Describe.tsplot} 13 | \alias{Describe.TukeyHSD} 14 | \alias{Describe.ggplot} 15 | \alias{print.description} 16 | \alias{print.multiDescription} 17 | 18 | \title{ 19 | Describe method to help visualize plot types. 20 | } 21 | \description{ 22 | A function to help describe what a graph model would look like, to a vision impaired person. 23 | } 24 | \usage{ 25 | Describe(x, VI=FALSE, ...) 26 | 27 | \method{Describe}{histogram}(x, VI=FALSE, ...) 28 | 29 | \method{Describe}{ggplot}(x,VI=FALSE, whichLayer=NULL, ...) 30 | } 31 | \arguments{ 32 | \item{x}{any \R object} 33 | \item{VI}{Should \code{VI()} be called at the same time} 34 | \item{whichLayer}{Only used with Describe.ggplot, if NULL will either display the layer if ggplot has one layer, ask user for input if it is an interactive session or print out all of the layers} 35 | \item{...}{other arguments, currently ignored} 36 | } 37 | \details{ 38 | Describe() is for explaining how a given type of graph appears to a sighted person and is intended for use by blind people who do not know how the graph looks. There is room to add hints for displaying the graphs in a more visually appealing manner. 39 | 40 | The text description will only be generic to the plot type and not specific information for specific information see \code{VI()}. 41 | 42 | Unlike \code{VI()} and ggplot Describe needs to be explicitly called to show its output. 43 | } 44 | \value{ 45 | A description in the format of a list. It will have the title, general info and RHints. If multiple layers of a ggplot are being described then it will be a list of descriptions for each layer. 46 | } 47 | \author{ 48 | A. Jonathan R. Godfrey and James A. Thompson 49 | } 50 | 51 | \examples{ 52 | # Base R 53 | scatter = FittedLinePlot(NULL, x = rnorm(1e2), y = rnorm(1e2)) 54 | Describe(scatter) 55 | hist = hist(rnorm(1e3)) 56 | Describe(hist) 57 | 58 | # ggplot 59 | if(require(ggplot2)){ 60 | simplePoint = ggplot(NULL, aes(rnorm(1e2), rnorm(1e2))) + 61 | geom_point() 62 | Describe(simplePoint) 63 | } 64 | } -------------------------------------------------------------------------------- /R/Stop.R: -------------------------------------------------------------------------------- 1 | # still need to insert factor name in error message; look for which 2 | 3 | 4 | .BlankStop = function() { 5 | stop("\n") 6 | return(invisible(NULL)) 7 | } 8 | 9 | .FactorNotFactor = function(which=NULL) { 10 | stop("The factor is not stored as a factor.\nTry using as.factor() on a copy of the data.frame.") 11 | return(invisible(NULL)) 12 | } 13 | 14 | .GroupNotFactor = function() { 15 | stop("The group variable is not a factor.\nTry using as.factor() on a copy of the data.frame.") 16 | return(invisible(NULL)) 17 | } 18 | 19 | .MissingFolder = function() { 20 | stop("Specified folder does not exist.\n") 21 | return(invisible(NULL)) 22 | } 23 | 24 | .MissingMethod = function() { 25 | stop("Specified method is not yet available.\n") 26 | return(invisible(NULL)) 27 | } 28 | 29 | 30 | .NoBrailleRFolder= function() { 31 | stop("No permanent MyBrailleR folder was found.\n Use `SetupBrailleR()` to fix this problem.") 32 | return(invisible(NULL)) 33 | } 34 | 35 | 36 | .NoResponse = function() { 37 | stop("You must specify either the Response or the ResponseName.") 38 | return(invisible(NULL)) 39 | } 40 | 41 | 42 | .NotADataFrame = function() { 43 | stop("The named dataset is not a data.frame.") 44 | return(invisible(NULL)) 45 | } 46 | 47 | 48 | .NotAProperFileName = function() { 49 | stop('file must be a character string or connection') 50 | return(invisible(NULL)) 51 | } 52 | 53 | .NotViewable = function() { 54 | stop("The named data is not a data.frame, matrix, or vector so cannot be viewed.") 55 | return(invisible(NULL)) 56 | } 57 | 58 | 59 | 60 | .NoYNeeds2X = function() { 61 | stop("If y is not supplied, x must have two numeric columns") 62 | return(invisible(NULL)) 63 | } 64 | 65 | 66 | .PredictorNotNumeric = function() { 67 | stop("The predictor variable is not numeric.") 68 | return(invisible(NULL)) 69 | } 70 | 71 | .ResponseNotNumeric = function() { 72 | stop("The response variable is not numeric.") 73 | return(invisible(NULL)) 74 | } 75 | 76 | .ResponseNotAVector = function() { 77 | stop("Input response is not a vector.") 78 | return(invisible(NULL)) 79 | } 80 | 81 | .XOrYNotNumeric = function(which="y") { 82 | stop("The x or y variable is not numeric.") 83 | return(invisible(NULL)) 84 | } 85 | 86 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onDetach = 2 | function(libpath) { 3 | options("BrailleR.VI" = NULL) 4 | } 5 | 6 | .onAttach = 7 | function(libname, pkgname) { 8 | options("BrailleR.VI" = TRUE) 9 | options("BrailleR.Advanced" = FALSE) 10 | if (interactive()) { 11 | packageStartupMessage( 12 | "The BrailleR.View option has been set to TRUE. \nConsult the help page for GoSighted() to see how settings can be altered.\nYou may wish to use the GetGoing() function as a quick way of getting started.") 13 | } else { 14 | packageStartupMessage("The BrailleR.View, option is set to FALSE.") 15 | } 16 | } 17 | 18 | 19 | BrailleR <- NULL 20 | .onLoad = 21 | function(libname, pkgname) { 22 | ns <- getNamespace(pkgname) 23 | 24 | Folder = SetupBrailleR() 25 | 26 | if (file.exists("BrailleROptions")) { 27 | OpSet = read.dcf("BrailleROptions", all = TRUE) 28 | } else { # first time package is used in this directory 29 | if (is.null(Folder)) { 30 | OpSet = read.dcf(system.file("MyBrailleR/BrailleROptions", 31 | package = "BrailleR"), all = TRUE) 32 | } else { 33 | OpSet = read.dcf(file.path(Folder, "/BrailleROptions"), all = TRUE) 34 | } 35 | # to do: # ask for permission to write a local copy 36 | ## write.dcf(OpSet, file="BrailleROptions") 37 | } 38 | OpSet$BrailleR.Folder = Folder 39 | OpSet$BrailleR.SigLevel = as.numeric(OpSet$BrailleR.SigLevel) 40 | OpSet$BrailleR.PValDigits = as.numeric(OpSet$BrailleR.PValDigits) 41 | OpSet$BrailleR.DotplotBins = as.numeric(OpSet$BrailleR.DotplotBins) 42 | OpSet$BrailleR.BRLPointSize = as.numeric(OpSet$BrailleR.BRLPointSize) 43 | OpSet$BrailleR.PaperWidth = as.numeric(OpSet$BrailleR.PaperWidth) 44 | OpSet$BrailleR.PaperHeight = as.numeric(OpSet$BrailleR.PaperHeight) 45 | #OpSet$ = as.numeric(OpSet$) 46 | do.call(options, as.list(OpSet)) 47 | Op <- getOption("repos") 48 | Op["CRAN"] <- "https://cran.rstudio.com/" 49 | options(repos = Op) 50 | options(BrailleR.View = interactive()) 51 | BrailleR <<- new.env(parent = .GlobalEnv) 52 | if (interactive()) { 53 | addTaskCallback(.callback, data = BrailleR, name = "BrailleR_logger") 54 | options("menu.graphics" = FALSE) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /man/OnePredictor.Rd: -------------------------------------------------------------------------------- 1 | \name{OnePredictor} 2 | \alias{OnePredictor} 3 | \title{Exploration of the relationship between a response and a single predictor} 4 | \description{ 5 | A convenience function for generating exploratory graphs and numeric summaries, regression analysis output, and the residual analysis of the simple linear model.} 6 | \usage{ 7 | OnePredictor(Response, Predictor, Data = NULL, 8 | Filename = NULL, Folder = NULL, 9 | VI = getOption("BrailleR.VI"), Latex = getOption("BrailleR.Latex"), 10 | View = getOption("BrailleR.View"), Modern=TRUE) 11 | } 12 | \arguments{ 13 | \item{Response}{Name of the continuous response variable.} 14 | \item{Predictor}{Name of the continuous response variable.} 15 | \item{Data}{The data.frame that contains both the response and the factor.} 16 | \item{Filename}{Name of the Rmarkdown and HTML files to be created. A default will be created that uses the names of the variables if this is left set to NULL.} 17 | \item{Folder}{Name of the folder to store graph and LaTeX files. A default will be created based on the name of the data.frame being used.} 18 | \item{VI}{Logical: Should the VI method for blind users be employed?} 19 | \item{Latex}{Logical: Should the tabulated sections be saved in LaTeX format?} 20 | \item{View}{Logical: Should the HTML file be opened for inspection?} 21 | \item{Modern}{Logical: Should the graphics be created using ggplot?} 22 | } 23 | \details{This function writes an R markdown file that is knitted into HTML and purled into an R script. All graphs are saved in subdirectories in png, eps, pdf and svg formats. Tabulated results can be stored in files suitable for importing into LaTeX documents.} 24 | \value{This function is used for creation of the files saved in the working directory and a few of its subdirectories.} 25 | \author{A. Jonathan R. Godfrey and Timothy P. Bilton} 26 | \seealso{Other convenience functions can be investigated via their help pages. See \code{\link{UniDesc}}, \code{\link{OneFactor}}, and \code{\link{TwoFactors}} 27 | } 28 | \examples{ 29 | if(require(nortest)){ # used in a dependent function's Rmd file 30 | library(knitr) 31 | DIR = getwd() 32 | setwd(tempdir()) 33 | data(airquality) 34 | OnePredictor("Ozone", "Wind", airquality) 35 | # N.B. Various files and a folder were created in a temporary directory. 36 | # Please investigate them to see how this function worked. 37 | setwd(DIR) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vignettes/Ex3UnivariateDescription.rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The BrailleR package Example 3" 3 | author: "A. Jonathan R. Godfrey" 4 | bibliography: BrailleRPublications.bib 5 | vignette: > 6 | %\VignetteIndexEntry{Example 3: Univariate Description} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | output: knitr:::html_vignette 9 | --- 10 | 11 | 12 | ```{r setup, include=FALSE} 13 | library(knitr) 14 | opts_chunk$set(fig.width=7, fig.height=5, comment="") 15 | library(BrailleR) 16 | ``` 17 | 18 | 19 | # The BrailleR package Example 3. 20 | 21 | ## Description of a single numeric variable 22 | 23 | There are many commands needed to get the numeric and graphic summary measures that might be required to collect all relevant information on a single numeric variable. The UniDesc() command has been written as a shortcut for a blind user who wishes to obtain: 24 | - the counts of points in the sample that were observed and not observed, 25 | - the mean and trimmed mean, 26 | - the five number summary: minimum, lower quartile, median, upper quartile, and maximum, 27 | - the interquartile range (IQR) and standard deviation, 28 | - measures of skewness and kurtosis (thanks to the moments package), 29 | - a histogram and/or a boxplot, 30 | - a normality (quantile-quantile) plot, 31 | - various tests for normality (thanks to the nortest package), and 32 | - tests on the significance of the skewness and kurtosis (again, thanks to the moments package). 33 | 34 | In addition, the blind user may need any/all of the graphs in a variety of formats (png, pdf, eps, or svg), nicely formatted tables for insertion into documents (LaTeX or HTML), and access to the code that generated these graphs and tables (an R script). 35 | 36 | The UniDesc() function can deliver all of this with minimal effort from the user. In addition, the output HTML file is opened automatically if R is being used interactively, giving the blind user immediate access to the information. The content is presented using sufficiently marked up HTML code including headings and tables so that the blind user can make best use of their screen reading software. All graphs included in the HTML file can be presented using a text description available from the VI() functionality of the BrailleR package. 37 | 38 | The main output document (HTML) can be viewed by issuing the command 39 | ```{r Example, eval=FALSE} 40 | example(UniDesc) 41 | ``` 42 | while running R interactively. 43 | 44 | 45 | -------------------------------------------------------------------------------- /R/dotplots.R: -------------------------------------------------------------------------------- 1 | dotplot = function(x, ...) { 2 | UseMethod("dotplot") 3 | } 4 | 5 | dotplot.default = 6 | function(x, ...) { 7 | .NotBaseRWarning("The dotplot command is a wrapper for stripchart,") 8 | MC <- match.call(expand.dots = TRUE) 9 | MC[[1L]] <- quote(graphics::stripchart) 10 | names(MC)[2] = "" 11 | Out <- eval(MC, parent.frame()) 12 | if (length(MC$vertical) > 0) { 13 | Out$vertical = as.logical(MC$vertical) 14 | } else { 15 | Out$vertical = FALSE 16 | } 17 | Out$vals = list(sort(x)) 18 | Out$main = as.character(MC$main) 19 | # then overwrite if user has specified (even if in error) 20 | if (length(MC$group.names) > 0) 21 | Out$group.names = as.character(MC$group.names) 22 | if (length(MC$dlab) > 0) Out$dlab = as.character(MC$dlab) 23 | if (length(MC$glab) > 0) Out$glab = as.character(MC$glab) 24 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) 25 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 26 | Out$call = MC 27 | class(Out) = "dotplot" 28 | Out=Augment(Out) 29 | return(invisible(Out)) 30 | } 31 | 32 | 33 | dotplot.formula = 34 | function(x, ...) { 35 | .NotBaseRWarning("The dotplot command is a wrapper for stripchart,") 36 | MC <- match.call(expand.dots = TRUE) 37 | MC[[1L]] <- quote(graphics::stripchart) 38 | names(MC)[2] = "" 39 | Out <- eval(MC, parent.frame()) 40 | if (length(MC$vertical) > 0) { 41 | Out$vertical = as.logical(MC$vertical) 42 | } else { 43 | Out$vertical = FALSE 44 | } 45 | Temp = aggregate(x, FUN = sort) 46 | Out$vals = Temp[[2]] 47 | names(Out$vals) = Temp[[1]] 48 | # formula assigns glab which is old school 49 | Out$main = as.character(MC$main) 50 | # then overwrite if user has specified (even if in error) 51 | if (length(MC$group.names) > 0) 52 | Out$group.names = as.character(MC$group.names) 53 | if (length(MC$dlab) > 0) Out$dlab = as.character(MC$dlab) 54 | if (length(MC$glab) > 0) Out$glab = as.character(MC$glab) 55 | if (length(MC$xlab) > 0) Out$xlab = as.character(MC$xlab) 56 | if (length(MC$ylab) > 0) Out$ylab = as.character(MC$ylab) 57 | Out$call = MC 58 | class(Out) = "dotplot" 59 | Out=Augment(Out) 60 | return(invisible(Out)) 61 | } 62 | 63 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # All available hooks: https://pre-commit.com/hooks.html 2 | # R specific hooks: https://github.com/lorenzwalthert/precommit 3 | repos: 4 | - repo: https://github.com/lorenzwalthert/precommit 5 | rev: v0.3.2.9007 6 | hooks: 7 | - id: style-files 8 | args: [--style_pkg=styler, --style_fun=tidyverse_style] 9 | # codemeta must be above use-tidy-description when both are used 10 | # - id: codemeta-description-updated 11 | - id: use-tidy-description 12 | - id: spell-check 13 | exclude: > 14 | (?x)^( 15 | .*\.[rR]| 16 | .*\.feather| 17 | .*\.jpeg| 18 | .*\.pdf| 19 | .*\.png| 20 | .*\.py| 21 | .*\.RData| 22 | .*\.rds| 23 | .*\.Rds| 24 | .*\.Rproj| 25 | .*\.sh| 26 | (.*/|)\.gitignore| 27 | (.*/|)\.gitlab-ci\.yml| 28 | (.*/|)\.lintr| 29 | (.*/|)\.pre-commit-.*| 30 | (.*/|)\.Rbuildignore| 31 | (.*/|)\.Renviron| 32 | (.*/|)\.Rprofile| 33 | (.*/|)\.travis\.yml| 34 | (.*/|)appveyor\.yml| 35 | (.*/|)NAMESPACE| 36 | (.*/|)DESCRIPTION| 37 | (.*/|)renv/settings\.dcf| 38 | (.*/|)renv\.lock| 39 | (.*/|)WORDLIST| 40 | \.github/workflows/.*| 41 | data/.*| 42 | )$ 43 | - id: lintr 44 | args: [--warn_only] 45 | - id: parsable-R 46 | - id: no-browser-statement 47 | - id: no-debug-statement 48 | - id: deps-in-desc 49 | - repo: https://github.com/pre-commit/pre-commit-hooks 50 | rev: v4.4.0 51 | hooks: 52 | - id: check-added-large-files 53 | args: ['--maxkb=200'] 54 | - id: file-contents-sorter 55 | files: '^\.Rbuildignore$' 56 | - id: end-of-file-fixer 57 | exclude: '\.Rd' 58 | - repo: https://github.com/pre-commit-ci/pre-commit-ci-config 59 | rev: v1.5.1 60 | hooks: 61 | # Only reuiqred when https://pre-commit.ci is used for config validation 62 | - id: check-pre-commit-ci-config 63 | - repo: local 64 | hooks: 65 | - id: forbid-to-commit 66 | name: Don't commit common R artifacts 67 | entry: Cannot commit .Rhistory, .RData, .Rds or .rds. 68 | language: fail 69 | files: '\.(Rhistory|RData|Rds|rds)$' 70 | # `exclude: ` to allow committing specific files 71 | 72 | ci: 73 | autoupdate_schedule: monthly 74 | -------------------------------------------------------------------------------- /inst/whisker/Describe/baseR.txt: -------------------------------------------------------------------------------- 1 | type,title,general,RHints 2 | default," 3 | No description of this type of object has been written at this time."," 4 | none yet"," 5 | none yet" 6 | histogram," 7 | A histogram created using the base graphics package."," 8 | A histogram uses rectangles to represent the counts or relative frequencies of observations falling in each subrange of the numeric variable being investigated. The rectangles are standing side by side with their bottom end at the zero mark of the vertical axis. The widths of the rectangles are usually constant, but this can be altered by the user. A sighted person uses the heights and therefore the areas of the rectangles to help determine the overall shape of the distribution, the presence of gaps in the data, and any outliers that might be present. The vertical axis for frequency always starts at zero. {{BaseAxisStyleText}} {{CommonTickMarkText}} {{CommonAspectRatioText}}"," 9 | If you intend to make a tactile version of a histogram, you may find it useful to alter the aspect ratio so that the histogram is wider than it is tall." 10 | scatterplot," 11 | A scatter plot created using BrailleR which builds on base graphics use of the plot() command"," 12 | {{CommonScatterplotGen}} {{BaseAxisStyleText}} {{CommonTickMarkText}} 13 | {{CommonAspectRatioText}}"," 14 | Default settings would use a small black open circle for each observation in the dataset that has a value for both variables being plotted. The `col` and `pch` arguments alter the colour and shape of the symbols; these might vary according to some other information known about each observation. It is common to add a straight line with the `abline()` command to show how well a linear relationship summarises the data." 15 | tsplot," 16 | A time series plot created using BrailleR which builds on base graphics use of the plot() command"," 17 | A time series plot shows the behaviour of a variable over time, by connecting successive points at the height of the variable of interest using line segments. The x-axis is labelled as "Time" by default.{{BaseAxisStyleText}} {{CommonTickMarkText}} 18 | {{CommonAspectRatioText}}"," 19 | Default settings would use a series of straight black line segments to join adjacent points. Each missing observation contributes to the absence of two line segments. \nThe line segments are printed as solid black lines, unless the colour is changed using the `col` argument. The type of line is changed with the `lty` argument. It can prove useful to alter the width of lines using the `lwd` argument." 20 | -------------------------------------------------------------------------------- /R/UseTemplate.R: -------------------------------------------------------------------------------- 1 | UseTemplateList = function(newfile, fileList, find=NULL, replace=NULL){ 2 | if (interactive()) { 3 | for(Template in fileList){ 4 | cat(UseTemplate(Template, find=find, replace=replace), file=newfile, append=TRUE) 5 | } 6 | } else { 7 | .InteractiveOnly() 8 | } 9 | return(invisible(TRUE)) 10 | } 11 | 12 | 13 | UseTemplate = function(file, find=NULL, replace=NULL){ 14 | if (interactive()) { 15 | TXT = readLines(system.file(paste0("Templates/", file), package="BrailleR")) 16 | if(!is.null(replace)){ 17 | for(i in 1:length(replace)){ 18 | TXT = gsub(find[i], replace[i], TXT) 19 | } 20 | } 21 | return(paste0(TXT, collapse="\n")) 22 | } else { 23 | .InteractiveOnly() 24 | } 25 | } 26 | 27 | 28 | .UseTemplate = function(templateFile, NewFile=NULL, Changes=list()){ 29 | if (interactive()) { 30 | TXT = readLines(system.file(paste0("Templates/", templateFile), package="BrailleR")) 31 | OutText = whisker.render(template=TXT, data=Changes) 32 | if(!is.null(NewFile)){ 33 | cat(OutText, file=NewFile) 34 | .NewFile(NewFile) 35 | } 36 | return(OutText) 37 | } else { 38 | .InteractiveOnly() 39 | } 40 | } 41 | 42 | .ChooseTemplate = function(){ 43 | if (interactive()) { 44 | Templates = read.csv(system.file("Templates/templates.csv", package="BrailleR")) 45 | Types = as.character(unique(Templates$Type)) 46 | UserPrefType = menu(Types, 47 | title = "Which type of template do you want?") 48 | Subset = Templates[Templates$Type == Types[UserPrefType], ] 49 | UserPrefFile = menu(Subset$Template, 50 | title = "Which template do you want?") 51 | file = Subset$Template[UserPrefFile] 52 | message(paste("The", file, "uses the following terms that must be replaced:", Subset$Changes[UserPrefFile], "\nIt will ", Subset$Description[UserPrefFile])) 53 | } else { 54 | .InteractiveOnly() 55 | file=NULL 56 | } 57 | return(file) 58 | } 59 | 60 | .BuildRmdFile = function(TemplateList = c("simpleYAMLHeader.Rmd", "StandardSetupChunk.Rmd", "GetLibs.Rmd", "GetData.Rmd"), 61 | Changes = list(), Outfile = "test.Rmd"){ 62 | if (interactive()) { 63 | for(Template in TemplateList){ 64 | cat(.UseTemplate(Template, Changes=Changes), "\n\n\n", file=Outfile, append=TRUE) 65 | } 66 | .NewFile(Outfile) 67 | message("N.B. it will not be processed untill all {{.}} elements have been replaced with meaningful text.") 68 | } else { 69 | .InteractiveOnly() 70 | } 71 | return(invisible(TRUE)) 72 | } 73 | -------------------------------------------------------------------------------- /R/MakeReadable.R: -------------------------------------------------------------------------------- 1 | 2 | MakeReadable = 3 | function(pkg) { 4 | if (.Platform$OS.type == "windows") { 5 | if (requireNamespace(pkg, ) ) { 6 | # move files here for subsequent conversion 7 | VignetteFolder = paste0(system.file(package = pkg), "/doc") 8 | RnwFiles = c(list.files(path = VignetteFolder, pattern = "Rnw", full.names=TRUE), 9 | list.files(path = VignetteFolder, pattern = "rnw", full.names=TRUE)) 10 | MyVignettesFolder = 11 | paste0(getOption("BrailleR.Folder"), "/Vignettes/") 12 | if (!dir.exists(MyVignettesFolder)) dir.create(MyVignettesFolder) 13 | 14 | FinalMoveTo = paste0(MyVignettesFolder, pkg, "/") 15 | if (!dir.exists(FinalMoveTo)) dir.create(FinalMoveTo) 16 | FinalMoveTo = MyVignettesFolder 17 | 18 | OriginalDir = getwd() 19 | 20 | MoveTo=pkg 21 | dir.create(MoveTo) 22 | 23 | 24 | file.copy(RnwFiles, 25 | MoveTo, overwrite = TRUE) 26 | 27 | setwd(MoveTo) 28 | 29 | RnwFiles = c(list.files(pattern = "Rnw"), 30 | list.files(pattern = "rnw")) 31 | 32 | # Copying and converting line breaks 33 | 34 | for (i in RnwFiles) { 35 | try(Sweave(i)) 36 | } 37 | 38 | TeXFiles = list.files(pattern=".tex") 39 | 40 | #if(nzchar(Sys.which("htmlblahlatex"))){ 41 | # try to use tex4ht 42 | # shoudl fail because if() is flaweed on purpose while developing. 43 | #} else { 44 | # use pandoc 45 | HTMLFile=gsub(".tex", ".html", i) 46 | shell(paste("pandoc", i, "-o", HTMLFile)) 47 | #} 48 | setwd(OriginalDir) 49 | 50 | file.copy(MoveTo, FinalMoveTo, overwrite=TRUE) 51 | unlink(MoveTo) 52 | 53 | } else { 54 | .PkgNotFound() 55 | } 56 | } else { 57 | .WindowsOnly() 58 | } 59 | return(invisible(NULL)) 60 | } 61 | 62 | 63 | .RemoveWhiteSpace = function(file){ 64 | .Done() 65 | writeLines(gsub(" *", " ", readLines(file)), file) 66 | return(invisible(NULL)) 67 | } 68 | 69 | 70 | 71 | .RemoveTabs = function(file){ 72 | # Converting tabs to spaces 73 | writeLines(gsub("\t", " ", readLines(file)), file) 74 | # shell(paste0(system.file( 75 | # "Python/RemoveTabs.py", package = "BrailleR"), 76 | # ' "', file, '"')) 77 | return(invisible(NULL)) 78 | } 79 | 80 | .MakeBackUp = function(file){ 81 | OldFile=paste0(file, ".bak") 82 | file.copy(file, OldFile) 83 | return(invisible(NULL)) 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /man/ScatterPlot.Rd: -------------------------------------------------------------------------------- 1 | \name{ScatterPlot} 2 | \alias{FittedLinePlot} 3 | \alias{ScatterPlot} 4 | \alias{plot.scatterplot} 5 | \alias{plot.fittedlineplot} 6 | \alias{print.scatterplot} 7 | \alias{print.fittedlineplot} 8 | \title{Create a standard scatter plot with a few extra elements added to the output object} 9 | \description{This function is a wrapper to the standard \code{plott()} function in the \pkg{graphics} package. It is tailored to generating a scatter plot, and adds detail to the stored object so that a better text description can be formulated using the \code{VI()} method in the \pkg{BrailleR} package. The function will become redundant once all other \pkg{BrailleR} functionality is working well with ggplot style graphics.} 10 | \usage{ 11 | ScatterPlot(.data, x, y, base=FALSE, ...) 12 | 13 | FittedLinePlot(.data, x, y, line.col=2, base=FALSE, ...) 14 | 15 | } 16 | \arguments{ 17 | \item{.data}{the data.frame from which variables are drawn. Ignored if using base graphics.} 18 | \item{x,y}{numeric variables. N.B. you must explicitly specify them by naming the arguments.} 19 | \item{base}{Use base style graphics. Default is to use ggplot2 instead.} 20 | \item{line.col}{colour to be used for the fitted line; col is used to modify the colour of the points.} 21 | \item{\dots}{additional arguments passed on to the plotting function.} 22 | } 23 | \details{ 24 | These wrapper functions will draw the graphics plots for a set of points. The only difference is that the fitted line is added for the FittedLinePlot() 25 | 26 | The original style used base graphics. Given the improved interaction of ggplot graphics for BrailleR users, the preferred style from v0.33.0 onwards was the ggplot style. 27 | } 28 | 29 | \value{ 30 | Either: 31 | 32 | 1. An object of class scatterplot of fittedlineplot, with the addition of any calls to the main title or axis labels being explicitly stored even if a zero length character string, or 33 | 34 | 2. a ggplot object.} 35 | \references{Godfrey, A.J.R. (2013) \sQuote{Statistical Software from a Blind Person's Perspective: R is the Best, but we can make it better}, The R Journal 5(1), pp73-79.} 36 | \author{A. Jonathan R. Godfrey} 37 | 38 | \examples{ 39 | attach(airquality) 40 | op = par(mfcol=c(3,2)) 41 | plot(x=Wind, y=Ozone, pch=4) 42 | test1 = ScatterPlot(x=Wind, y=Ozone, pch=4, base=TRUE) 43 | test1 #does the plot method work? 44 | plot(x=Wind,y= Ozone) 45 | abline(coef(lm(Ozone~Wind)), col=4) 46 | test2 = FittedLinePlot(x=Wind, y=Ozone, line.col=4, base=TRUE) 47 | test2 #does the plot method work? 48 | par(op) 49 | detach(airquality) 50 | } 51 | 52 | -------------------------------------------------------------------------------- /R/TextStrings.R: -------------------------------------------------------------------------------- 1 | 2 | .BoxplotText = function(fivenum, outliers=NULL, horizontal=FALSE){ 3 | Outs=length(outliers) 4 | TextOuts = ifelse(Outs==0, "no", as.character(Outs)) 5 | ShortText = paste("Min", fivenum[1], "Lower quartile", fivenum[2], "Median", fivenum[3], "Upper quartile", fivenum[4], "Max", fivenum[5], "with", TextOuts, ifelse(Outs==1, "outlier.", "outliers.")) 6 | 7 | Text1 = Text2 = Text3 = Text4 = Text5 = Text6 = "" 8 | 9 | if (Outs>0) { 10 | Text1 = paste(ifelse(Outs==1, "An outlier is", "Outliers are"), 'marked at:', outliers) 11 | } else{ 12 | Text1 = "no outliers" 13 | } 14 | Text2 = paste('The whiskers extend to', fivenum[1], 'and', fivenum[5], 15 | 'from the ends of the box, \nwhich are at', fivenum[2], 'and', 16 | fivenum[4], '\n') 17 | BoxLength = fivenum[4] - fivenum[2] 18 | Text3 = paste('The median,', fivenum[3], 'is', 19 | round(100 * (fivenum[3] - fivenum[2]) / BoxLength, 0), 20 | '% from the', ifelse(horizontal, 'left', 'lower'), 21 | 'end of the box to the', ifelse(horizontal, 'right', 'upper'), 22 | 'end.\n') 23 | Text4 = paste('The', ifelse(horizontal, 'right', 'upper'), 'whisker is', 24 | round((fivenum[5] - 25 | fivenum[4]) / (fivenum[2] - fivenum[1]), 2), 26 | 'times the length of the', ifelse(horizontal, 'left', 'lower'), 27 | 'whisker.\n') 28 | 29 | LongText = c(Text1, Text2, Text3, Text4) 30 | return(invisible(list(Short=ShortText, Long=LongText))) 31 | } 32 | 33 | .GetAxisTicks = 34 | function(x) { 35 | A = x[1] 36 | B = x[2] 37 | Ticks = x[3] 38 | paste(paste0(seq(A, B - (B - A)/Ticks, (B - A) / Ticks), ",", collapse = " "), 39 | "and", B, collapse = " ") 40 | } 41 | 42 | 43 | .ScatterPlotText = function(x, MedianX=x$GroupSummaries$MedianX, MedianY=x$GroupSummaries$MedianY, MeanX=x$GroupSummaries$MeanX, MeanY=x$GroupSummaries$MeanY, MinX=x$GroupSummaries$MinX, MinY=x$GroupSummaries$MinY, MaxX=x$GroupSummaries$MaxX, MaxY=x$GroupSummaries$MaxY, SDX=x$GroupSummaries$SDX, SDY=x$GroupSummaries$SDY, CorXY=x$GroupSummaries$CorXY, N=x$GroupSummaries$N){ 44 | 45 | ShortText = paste("Around X=", MedianX, "there are", N, "y values with median =", MedianY, "over the range", MinY, "to", MaxY) 46 | LongText = paste("X=", MedianX, "has y values with median =", MedianY, "over the range", MinY, "to", MaxY, "; the values have a correlation of", CorXY) 47 | return(invisible(list(Short=ShortText, Long=LongText))) 48 | } 49 | 50 | -------------------------------------------------------------------------------- /man/TwoFactors.Rd: -------------------------------------------------------------------------------- 1 | \name{TwoFactors} 2 | \alias{TwoFactors} 3 | \title{A convenience function for a two-way analysis} 4 | \description{Prepares an analysis of a data set with one response and two predictors that are both factors. An interaction between the two factors is also allowed for. The function creates a number of graphs and tables relevant for the analysis.} 5 | \usage{ 6 | TwoFactors(Response, Factor1, Factor2, Inter = FALSE, HSD = TRUE, 7 | AlphaE = getOption("BrailleR.SigLevel"), Data = NULL, Filename = NULL, 8 | Folder = NULL, VI = getOption("BrailleR.VI"), Latex = getOption("BrailleR.Latex"), 9 | View = getOption("BrailleR.View"), Modern=TRUE) 10 | } 11 | \arguments{ 12 | \item{Response}{Name of the continuous response variable.} 13 | \item{Factor1, Factor2}{Name the two factors to be included.} 14 | \item{Inter}{Logical: Should the interaction of the two factors be included?} 15 | \item{HSD}{Logical: Should Tukey's HSD be evaluated for the data?} 16 | \item{AlphaE}{The family-wise Type I error rate for Tukey's HSD calculations.} 17 | \item{Data}{Name the data.frame that includes the three variables of interest.} 18 | \item{Filename}{Name of the Rmarkdown and HTML files to be created. A default will be created that uses the names of the variables if this is left set to NULL.} 19 | \item{Folder}{Name of the folder to store graph and LaTeX files. A default will be created based on the name of the data.frame being used.} 20 | \item{VI}{Logical: Should the VI method for blind users be employed?} 21 | \item{Latex}{Logical: Should the tabulated sections be saved in LaTeX format?} 22 | \item{View}{Logical: Should the HTML file be opened for inspection?} 23 | \item{Modern}{Logical: Should the graphics be created using ggplot?} 24 | } 25 | \details{ 26 | to complete} 27 | \value{This function is used for creation of the files saved in the working directory and a few of its subdirectories.} 28 | \author{Timothy P. Bilton and A. Jonathan R. Godfrey} 29 | 30 | \seealso{ 31 | The \code{\link{OneFactor}} script was the basis for this function;. 32 | } 33 | \examples{ 34 | DIR = getwd() 35 | setwd(tempdir()) 36 | if(require(dplyr)){ 37 | TG <- ToothGrowth |> mutate(dose = as.factor(dose)) 38 | 39 | # Without interaction 40 | TwoFactors('len','supp','dose',Data=TG, Inter=FALSE) 41 | 42 | # With two-way interaction 43 | TwoFactors('len', 'supp', 'dose', Data=TG, Inter=TRUE) 44 | 45 | rm(TG); rm(TG) 46 | # N.B. Various files and a folder were created in a temporary directory. 47 | # Please investigate them to see how this function worked. 48 | } 49 | setwd(DIR) 50 | } 51 | -------------------------------------------------------------------------------- /R/GetPython.R: -------------------------------------------------------------------------------- 1 | GetPython27 = function(...){ 2 | .DeprecatedFunction() 3 | } 4 | 5 | GetWxPython27 = function(...){ 6 | .DeprecatedFunction() 7 | } 8 | 9 | TestPython = function(){ 10 | HasPython=nzchar(Sys.which("python")) 11 | if(HasPython){ 12 | .PythonVersion() 13 | } 14 | else{ 15 | .NoSeePython() 16 | } 17 | return(invisible(HasPython)) 18 | } 19 | 20 | 21 | TestWX = function(){ 22 | if(TestPython()){ 23 | if (interactive()) { 24 | if (.Platform$OS.type == "windows") { 25 | shell(paste("python", system.file("Python/TestWX.py", package="BrailleR"))) 26 | } else { 27 | .WindowsOnly() 28 | } 29 | } 30 | if(.IsWxAvailable()){ 31 | .CanSeeWxPython() 32 | .CanUseWriteR() 33 | return(invisible(TRUE))} 34 | else{ .CannotSeeWxPython() 35 | return(invisible(FALSE))} 36 | } 37 | } 38 | 39 | 40 | .IsWxAvailable = 41 | function(){ 42 | TestWx = system('python -c "import wx"') 43 | return(TestWx == 0) 44 | } 45 | 46 | 47 | 48 | 49 | GetPython = GetPython3 = 50 | function(x64=TRUE) { 51 | .GetPython(3, x64=x64) 52 | return(invisible(NULL)) 53 | } 54 | 55 | .GetPython = 56 | function(version, x64=x64) { 57 | if (interactive()) { 58 | if (.Platform$OS.type == "windows") { 59 | if (requireNamespace("BrailleR")) { 60 | if (requireNamespace("installr")) { 61 | .DownloadAFile() 62 | bit = .ifelse(x64, 64, 32) 63 | installr::install.python(version_number = version, download_dir=getOption("BrailleR.Folder"), keep_install_file = TRUE, x64=x64) 64 | .Added2MyBrailleR() 65 | .DeleteAnytime() 66 | } 67 | } 68 | } else { 69 | .WindowsOnly() 70 | } 71 | } else { 72 | .InteractiveOnly() 73 | } 74 | return(invisible(NULL)) 75 | } 76 | 77 | .PullWxUsingPip = function(){ 78 | if(.IsWxAvailable()){ 79 | system("pip install --user -U wxPython") 80 | } 81 | else{ 82 | system("pip install --user wxPython") 83 | } 84 | return(invisible(TRUE)) 85 | } 86 | 87 | 88 | 89 | GetWxPython = GetWxPython3 = 90 | function() { 91 | Success = FALSE 92 | if (interactive()) { 93 | if (.Platform$OS.type == "windows") { 94 | if(TestPython()){ 95 | .PullWxUsingPip() 96 | } 97 | } else { 98 | .WindowsOnly() 99 | } 100 | } else { 101 | .InteractiveOnly() 102 | } 103 | return(invisible(Success)) 104 | } 105 | -------------------------------------------------------------------------------- /man/boxplot.Rd: -------------------------------------------------------------------------------- 1 | \name{boxplot} 2 | \alias{boxplot} 3 | \title{Create a standard boxplot with a few extra elements added to the output object} 4 | \description{This function is a wrapper to the standard \code{boxplot()} function in the \pkg{graphics} package. It adds detail to the stored object so that a better text description can be formulated using the \code{VI()} method in the \pkg{BrailleR} package.} 5 | \usage{ 6 | boxplot(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{a numeric variable.} 10 | \item{\dots}{ 11 | additional arguments passed on to the plotting function.} 12 | } 13 | \details{ 14 | This function masks the function of the same name in the \pkg{graphics} package. The base R implementation does create an object, but does not give it a class attribute, the object does not store all graphical arguments that are passed to the \code{boxplot()} function. The functionality should be no different at all for anyone who is not using the \code{VI()} function to gain a more detailed text description of the boxplot. See the help page for the \code{graphics::boxplot()} function to get a more complete description of boxplot creation.} 15 | \value{ 16 | An object of class boxplot. This class is just a placeholder for the contents of the object used to create a boxplot which would otherwise not be stored in a usable format. The class is not intended for the user; it is a tool that enables the BrailleR package to deliver a readable text version of the plot. 17 | } 18 | \references{ 19 | The problem of not including class attributes for graphs was identified in: 20 | Godfrey, A.J.R. (2013) \sQuote{Statistical Software from a Blind Person's Perspective: R is the Best, but we can make it better}, The R Journal 5(1), pp73-79. 21 | } 22 | \author{A. Jonathan R. Godfrey} 23 | \note{ 24 | I would love to see this function become redundant. This will happen if the extra functionality is included in the \code{boxplot()} function in the \pkg{graphics} package. This should be possible as the user experience will not be any different, no matter if the user is blind or sighted. 25 | } 26 | 27 | \seealso{ 28 | The base R implementation of the \code{\link[graphics]{boxplot}} function should be consulted; see the entry in the \pkg{\link{graphics}} package 29 | } 30 | \examples{ 31 | x=rnorm(1000) 32 | op = par(mfcol=c(2,1)) 33 | # the stamdard boxplot function returns 34 | MyBoxplot=graphics::boxplot(x, main="Example boxplot (graphics package)", horizontal=TRUE) 35 | MyBoxplot 36 | 37 | # while this version returns 38 | MyBoxplot=boxplot(x, main="Example boxplot (BrailleR package)", horizontal=TRUE) 39 | MyBoxplot 40 | par(op) 41 | 42 | # The VI() method then uses the extra information stored 43 | VI(MyBoxplot) 44 | } 45 | -------------------------------------------------------------------------------- /R/BrowseSVG.R: -------------------------------------------------------------------------------- 1 | # Currently only supports working the current directory. 2 | BrowseSVG <- function(file = "test", key = TRUE, footer = TRUE, view = interactive(), ggplot_object = NULL) { 3 | # Required file for correct execution 4 | xmlFileName <- paste0(file, ".xml") 5 | svgFileName <- paste0(file, ".svg") 6 | 7 | if (!(file.exists(xmlFileName) && file.exists(svgFileName))) { 8 | warning("You do not have both a svg and xml file in current wd. Please create these with SVGThis()/AddXML() or use MakeAccessibleSVG()") 9 | return(invisible()) 10 | } 11 | 12 | # Read and clean xml file 13 | xmlString <- xmlFileName |> 14 | readLines() |> 15 | gsub("sre:", "", x = _) |> 16 | gsub(" *<[a-zA-Z]+/>", "", x = _) 17 | 18 | # Read svg file 19 | svgString <- svgFileName |> 20 | readLines() 21 | 22 | # Add Describe and VI 23 | # Some formatting is to be done to make it work with the templates 24 | if (!is.null(ggplot_object)) { 25 | # Get the Describe output 26 | Description <- Describe(ggplot_object, whichLayer = "all") 27 | if (isa(Description, "multiDescription")) { 28 | Description <- unclass(Description) 29 | Description <- lapply(seq_along(Description), function(i) { 30 | Description[[i]]$name <- names(Description)[[i]] 31 | Description[[i]] 32 | }) 33 | } else { 34 | Description <- unclass(Description) 35 | } 36 | 37 | # setNames(rep(NULL, length(length(ggplot_object$layers)))) 38 | # Get the VI output 39 | VI <- VI(ggplot_object) 40 | # Need to make a list with names to get mustache list looping working. 41 | VI.text <- as.list(VI$text) |> 42 | stats::setNames(rep("text", length(VI$text))) 43 | } else { 44 | VI.text <- Description <- NULL 45 | } 46 | 47 | 48 | # Whiskers prep and rendering 49 | data <- list( 50 | xml = xmlString, 51 | svg = svgString, 52 | footer = footer, 53 | key = key, 54 | title = file, 55 | description = Description, 56 | has_description = !is.null(Description), 57 | vi = VI.text 58 | ) 59 | 60 | htmlTemplate <- system.file("whisker/SVG/template.html", package = "BrailleR") |> 61 | readLines() 62 | 63 | renderedText <- whisker.render(htmlTemplate, data = data) |> 64 | # Remove commas that are added to the data instead of new lines. 65 | gsub("(> *)(,)( *<)", "\\1\n\\3", x = _) |> # In SVG and XML 66 | gsub("(\\.)(,)", "\\1
", x = _) # In the VI and the Describe 67 | 68 | # Write the rendered text to html file 69 | fileName <- paste0(file, ".html") 70 | writeLines(renderedText, con = paste0(file, ".html")) 71 | close(file(fileName)) 72 | 73 | if (view) { 74 | browseURL(fileName) 75 | } 76 | } 77 | --------------------------------------------------------------------------------