https://github.com/bertcarnell/soas
Creates Stratum Orthogonal Arrays (a.k.a. Strong OAs)
https://github.com/bertcarnell/soas
Last synced: 3 months ago
JSON representation
Creates Stratum Orthogonal Arrays (a.k.a. Strong OAs)
- Host: GitHub
- URL: https://github.com/bertcarnell/soas
- Owner: bertcarnell
- License: gpl-2.0
- Created: 2021-08-31T00:34:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-14T14:13:23.000Z (over 1 year ago)
- Last Synced: 2024-06-05T12:25:46.935Z (12 months ago)
- Language: R
- Homepage: https://bertcarnell.github.io/SOAs/
- Size: 769 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output:
github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
rd <- tools::parse_Rd(file.path("man", "SOAs-package.Rd"))
rd_html <- capture.output(tools::Rd2HTML(rd))## Note: These functions are internal to the tools package, but are not exposed
## and are therefore not intended to be used and are subject to change.
## for that reason, they are replicated here to ensure they stay consistent
## with this document## based on tools:::RdTags
rd_get_tags <- function(Rd)
{
res <- lapply(Rd, attr, "Rd_tag")
if (length(res))
simplify2array(res, FALSE)
else character()
}## based on tools:::.Rd_get_metadata
rd_get_metadata <- function(x, tag)
{
x <- x[rd_get_tags(x) == sprintf("\\%s", tag)]
if (!length(x))
character()
else unique(trimws(vapply(x, paste, "", collapse = "\n")))
}## might also want to capture html output for markdown. This is more fragile
rd_html_get <- function(rd_html, from_h3, to_h3)
{
#from_h3 <- "Details"
#to_h3 <- "Author"
ind_from <- grep(paste0("", from_h3), rd_html)
ind_to <- grep(paste0("", to_h3), rd_html)
if (length(ind_from) != 1 | length(ind_to) != 1 | all(ind_from == ind_to))
{
stop("from_h3 or to_h3 are not specified correctly")
}
return(rd_html[(ind_from + 1):(ind_to - 1)])
}my_Rd_expr_doi <- function (x)
{
x <- tools:::.canonicalize_doi(x)
sprintf("[doi: %s](https://doi.org/%s)", x, x)
}
```# SOAs
```{r description, results = "asis"}
cat(rd_get_metadata(rd, "description"))
``````{r authors, results = "asis"}
x <- rd_get_metadata(rd, "author")
x <- gsub("Author", "- **Author**", x)
x <- gsub("Contributor", "\n- **Contributor**", x)
cat(x)
``````{r build_badges, results = "asis"}
cat("|Actions|Coverage|Website|\n")
cat("|:-----:|:------:|:-----:|\n")
cat(paste0("|",
"[](https://github.com/bertcarnell/SOAs/actions/workflows/r_cmd_check.yml)",
"[](https://github.com/bertcarnell/SOAs/actions/workflows/pkgdown.yaml)",
"|",
"[](https://codecov.io/gh/bertcarnell/SOAs?branch=main)",
"|",
"[](https://bertcarnell.github.io/SOAs/)",
"|"))
```## Installation
You can install the released version of `SOAs` from [CRAN](https://CRAN.R-project.org) with:
```{r install1, echo=TRUE, eval=FALSE}
install.packages("SOAs")
```
You can also install the development version of `SOAs` from here with:```{r install_option, eval=FALSE, echo=TRUE}
if (!require(devtools)) install.packages("devtools")
devtools::install_github("bertcarnell/SOAs")
```## Details
```{r details, results = "asis"}
temp <- rd_html_get(rd_html, "Details", "Author")# change equations back to $ for eqn and $$ for deqn
# Findand then the very next
start_token <- '
'
'
end_token <- '
deqn_start_token <- '
'
tag is not on the same line as the start for an equation")
p_token <- ''
'
p_end_token <- '
p_align_token <- ''
ind_start <- grep(start_token, temp)
ind_deqn_start <- grep(deqn_start_token, temp)for (i in 1:length(temp))
{
## /deqn
if (i %in% ind_deqn_start)
{
temp[i] <- gsub(start_token, "\n$$", temp[i])
if (!grepl(end_token, temp[i]))
stop("closing
temp[i] <- gsub(end_token, "$$\n", temp[i])
}
## /eqn
if (i %in% setdiff(ind_start, ind_deqn_start))
{
temp[i] <- gsub(start_token, "$", temp[i])
if (!grepl(end_token, temp[i]))
stop("closing tag is not on the same line as the start for an equation")
temp[i] <- gsub(end_token, "$", temp[i])
}
}##
tags
temp <- gsub(p_token, "\n", temp)
temp <- gsub(p_end_token, "\n", temp)
temp <- gsub(p_align_token, "\n", temp)cat(temp)
```## References
```{r references, results = "asis"}
temp <- rd_html_get(rd_html, "References", "See")
for (i in seq_along(temp))
{
if (grepl("[\\]+Sexpr[[]results=rd,stage=build[]][{].+[}]", temp[i]))
{
m <- regexpr("[\\]+Sexpr[[]results=rd,stage=build[]][{].+[}]", temp[i])
text1 <- substring(temp[i], 1, m-1)
code <- substring(temp[i], m, m + attr(m, "match.length"))
if (m + attr(m, "match.length") >= nchar(temp[i]))
{
text2 <- ""
} else
{
text2 <- substring(temp[i], m + attr(m,"match.length") + 1, nchar(temp[i]))
}
code <- gsub(".*[{]", "", code)
code <- gsub("[}].*", "", code)
code <- gsub("tools:::Rd_expr_doi", "my_Rd_expr_doi", code)
temp[i] <- paste(text1, eval(parse(text=code)), text2)
}
}# this is a fix for Issue 19 - https://github.com/bertcarnell/SOAs/issues/19
line_found <- grep("[_]II", temp)
posit_found <- gregexpr("[_]II", temp[line_found])
temp2 <- temp
# temp2[line_found] <- paste0(substring(temp[line_found], 1, posit_found[[1]][2]-1),
# "_",
# substring(temp[line_found], posit_found[[1]][2]+1, nchar(temp[line_found])))
temp2[line_found] <- gsub("[>]http", ">`http", temp[line_found])
temp2[line_found] <- gsub("pdf[<]", "pdf`<", temp2[line_found])cat(temp2)
```