From fa36925016b33e9a5326e268a2abcaac0cb94332 Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Sun, 15 May 2022 19:28:01 -0400 Subject: [PATCH 01/14] Added new function and documentation for calculating distance --- NAMESPACE | 1 + R/distance.R | 34 ++++++++++++++++++++++++++++++++++ man/euclideanDist.Rd | 25 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 R/distance.R create mode 100644 man/euclideanDist.Rd diff --git a/NAMESPACE b/NAMESPACE index 01843dc..6bd620a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ # Generated by roxygen2: do not edit by hand +export(euclideanDist) export(hello) diff --git a/R/distance.R b/R/distance.R new file mode 100644 index 0000000..cdd2ad6 --- /dev/null +++ b/R/distance.R @@ -0,0 +1,34 @@ +#' @title Euclidean distance +#' @description Calculates Euclidean distance between two vectors. An error will be +#' given if NAs are present in either vector. +#' +#' @param a The first vector to use in the distance calculation. +#' @param b The second vector to use in the distance calculation. +#' @param verbose Boolean. If \code{TRUE}, a message will be printed. Default \code{TRUE}. +#' @return A numeric value of a distance +#' @examples +#' euclideanDist(c(1, 2), c(2, 3), verbose = FALSE) +#' @export +euclideanDist <- function(a, b, verbose = FALSE) { + if (isTRUE(verbose)) { + message("Calculating distance ...") + } + + # Check validity of data + .check_data(a) + .check_data(b) + + # Perform calculation + res <- sqrt(sum((a-b)^2)) + return(res) +} + +#' @description Check for NAs +#' +#' @param input A numeric vector +#' @return Nothing returned +.check_data <- function(input) { + if (any(is.na(input))) { + stop("'input' must not contain NAs") + } +} diff --git a/man/euclideanDist.Rd b/man/euclideanDist.Rd new file mode 100644 index 0000000..f5e51f4 --- /dev/null +++ b/man/euclideanDist.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/distance.R +\name{euclideanDist} +\alias{euclideanDist} +\title{Euclidean distance} +\usage{ +euclideanDist(a, b, verbose = FALSE) +} +\arguments{ +\item{a}{The first vector to use in the distance calculation.} + +\item{b}{The second vector to use in the distance calculation.} + +\item{verbose}{Boolean. If \code{TRUE}, a message will be printed. Default \code{TRUE}.} +} +\value{ +A numeric value of a distance +} +\description{ +Calculates Euclidean distance between two vectors. An error will be +given if NAs are present in either vector. +} +\examples{ +euclideanDist(c(1, 2), c(2, 3), verbose = FALSE) +} From 1910d7537f4877ef4c8eb45d136070a8e62b020e Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Sun, 15 May 2022 20:25:03 -0400 Subject: [PATCH 02/14] Added new example_dataset and used it in the example for the euclideanDist function --- .Rbuildignore | 1 + DESCRIPTION | 2 ++ R/data.R | 11 +++++++++++ R/distance.R | 3 ++- data-raw/example_data.R | 6 ++++++ data/example_data.rda | Bin 0 -> 2010 bytes man/euclideanDist.Rd | 3 ++- man/example_data.Rd | 20 ++++++++++++++++++++ 8 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 R/data.R create mode 100644 data-raw/example_data.R create mode 100644 data/example_data.rda create mode 100644 man/example_data.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 88b0533..6624a45 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ ^docs$ ^pkgdown$ ^\.lintr$ +^data-raw$ diff --git a/DESCRIPTION b/DESCRIPTION index e2161da..2418b46 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,3 +22,5 @@ Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 VignetteBuilder: knitr +Depends: + R (>= 2.10) diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..be00067 --- /dev/null +++ b/R/data.R @@ -0,0 +1,11 @@ +#' Example dataset +#' +#' A dataset containing a matrix with two columns that were generated +#' with a random normal distribution with a mean of 0 and stdev of 1. +#' +#' @format A matrix with 100 rows and 2 columns +#' @keywords datasets +#' @usage data("example_data") +#' @examples +#' data("example_data") +"example_data" \ No newline at end of file diff --git a/R/distance.R b/R/distance.R index cdd2ad6..c34910a 100644 --- a/R/distance.R +++ b/R/distance.R @@ -7,7 +7,8 @@ #' @param verbose Boolean. If \code{TRUE}, a message will be printed. Default \code{TRUE}. #' @return A numeric value of a distance #' @examples -#' euclideanDist(c(1, 2), c(2, 3), verbose = FALSE) +#' data(example_data) +#' euclideanDist(example_data[,1], example_data[,2], verbose = FALSE) #' @export euclideanDist <- function(a, b, verbose = FALSE) { if (isTRUE(verbose)) { diff --git a/data-raw/example_data.R b/data-raw/example_data.R new file mode 100644 index 0000000..24efc73 --- /dev/null +++ b/data-raw/example_data.R @@ -0,0 +1,6 @@ +## code to prepare `example_data` dataset goes here +set.seed(123) +a <- rnorm(100) +b <- rnorm(100) +example_data <- cbind(a, b) +usethis::use_data(example_data, overwrite = TRUE) diff --git a/data/example_data.rda b/data/example_data.rda new file mode 100644 index 0000000000000000000000000000000000000000..cfdadd051565028c4850e318a879fccc388bd049 GIT binary patch literal 2010 zcmV<02PODIT4*^jL0KkKS)Rp2K>z_VfB*mg|NsC0|NsC0|NsC0|NsC0|NsC0|NsC0 z|NsC0|NqbgeqQEVJ=A7O@B$Mi$urR>lwx{~9)dka(3)+ifsICuG-;-TO*W>P2dMQ8 zGe$&hPf*BunrWtLG-%pJgVK6KO+8Ohka}bgJb=_`=trd5o~P=bNs;NMnI;f0Y7%2f z`liZerk;}#vYDpU9-}l(G{|K1Luv*_Bh>XCnns?dr1dtTqttm#FhPj)(mhX83FLz` zPbsv4=@>GeqtPCkf$AQiS z0z5zn^)aSIdI^(iW`s1+lLCIAXiNynh}sc=8UZxX>8a^5GHHZqngqzeCO}MR00000 z0Wb{!GynhrpiCnG000006HTB127mwnMhSpMOojje000D2(?}GXKtZF_XvhYDX{Hk( zG#ME*8Z>AP4XL4!G&Il+G|15FH>01X2WXnKtRG#L!i0MKX}G%^Z;#=LsQ zq*V}x|7KY#;<)Pp09-W4nFIhDL<}Gxc9aMJ=m3CI!7*?>@^y(2f&u~q9QQ=O6RXhx5pE$t6Ap02>zl-o z9o2zs(*&L|%e)EvRM^&9+@`oQPd5B{dgr3?=q[J5>4=9s&MXUdWSthKOK52(ri z8nVwH8>LWE6=myK*RnBB)}@%v(?&x{`y2c95d6QTD-s-Zsa^Oif$b)tZ>W*=LX=EM zmrgQ8;Ko;Z6-;u;~MQ`F;v>4gk8*HEsf~V$6y&~HV$tLV#w+8Bl z5xXR1YNTCqrfaU;?L38UapcbR3?xRjEw}biP!BhmEc_1Yh1nQD&$U~W485soAlYU@ z5mq07N0JIZi3n$ZyQ16?F)bV8s_skIvFp+NGoECvm34faDzKdu0u++0L9v+f4RJ6{ zv8mQ2^bAut?1ocYr@Wnj12msQPj+K1c*pP0B1^>2)r%EK1ShEh_FM|e3&P;yUc#Gq zk-0$#%Wq7a6|5iSqoTWRminYp#On9zg-95f`MhEX#}!33xf)&dQ#vGXo=NxCLg-)7 zC3s;hM#7fn@AxiVVKl+#^gbk*2HxaBI1kL6+zp)~SWo$G(uoax@Eq)p$#}P(1&4=8 zvvj%=q5wS=8>@z7<$+DGG>Lj50)ZAn_U1zjAutm#R6!OM3_Aa?fOI3u4aofV95_~J z7jS>Y8QU@u+$AFE2j_6`W!z8gUu7)v+%iAQi2^yX!=Y}!ynhuf^XY&`?Jkv1r{S8t@hf6h)TFuno zC3D>zA?(>Yr!U(MCI&J&NU^#ReVJMhdLkBvBq>!*r0t>GwX2>t5IXL4rQirfXr~I` zDXBW?5=3yCXDK28>?NpF;e~1l6&QE!Bv)duwke`&o0+M4hl8+5pOq93+j6z4BEGO^*=4y`n9_&vHIH=wR}DjJy?9dG_f?2-j5Vc(Du6(Q@I{ z(<+6bS;7|HPynX3IjjkTlq#lRt_ut^To@r%uAB>g!F8~oa1LnR2M z2PiNU?Cl{xY&gs-n@x^;2nI_lQyF{=Q&7rrMHrd4KWSlfe4D3smJl-Py6`00l-Us- zVXS#9WL;@@)5y?@hJ0V}z6RqON&Cis-GrsE-6aKZzD98C9VeO-XH{vv3hB}ULng^- z@*(Bk6i5qM1mV#=N$`a$0QfY(Z%GqDq7g(c)|84#kx@Ood=KoqG7db@cQmnJH`1$K zz%x7^4E`)Y(oB1`qzWVi>B-R(!6>(}AVVW%3u=}yM8&4pwPT2&uBOiD`JeZ`N6WX= zEsc*af=2dhn+bgo2F2QhNcdyzO_Z3QtO5J^MnWAbtc@3exti53PZgK>tb&)n@YK%IRMNE zITQx7tc!v$vV4vbUHO-Xnu*aTR=9vTulQXN*b=|AG`NT&)C6WFMTAX{&)mH+?% literal 0 HcmV?d00001 diff --git a/man/euclideanDist.Rd b/man/euclideanDist.Rd index f5e51f4..ed10e85 100644 --- a/man/euclideanDist.Rd +++ b/man/euclideanDist.Rd @@ -21,5 +21,6 @@ Calculates Euclidean distance between two vectors. An error will be given if NAs are present in either vector. } \examples{ -euclideanDist(c(1, 2), c(2, 3), verbose = FALSE) +data(example_data) +euclideanDist(example_data[,1], example_data[,2], verbose = FALSE) } diff --git a/man/example_data.Rd b/man/example_data.Rd new file mode 100644 index 0000000..e724347 --- /dev/null +++ b/man/example_data.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{example_data} +\alias{example_data} +\title{Example dataset} +\format{ +A matrix with 100 rows and 2 columns +} +\usage{ +data("example_data") +} +\description{ +A dataset containing a matrix with two columns that were generated +with a random normal distribution with a mean of 0 and stdev of 1. +} +\examples{ +data("example_data") +} +\keyword{datasets} From ffcefb5ad722f10d1ae55139f74827b238d7445c Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Thu, 19 May 2022 21:49:48 -0400 Subject: [PATCH 03/14] Fixed documentation for utility function --- R/distance.R | 4 +++- man/dot-check_data.Rd | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 man/dot-check_data.Rd diff --git a/R/distance.R b/R/distance.R index c34910a..b28b001 100644 --- a/R/distance.R +++ b/R/distance.R @@ -24,7 +24,9 @@ euclideanDist <- function(a, b, verbose = FALSE) { return(res) } -#' @description Check for NAs +#' Validity check +#' +#' This functions checks for NAs in a vector #' #' @param input A numeric vector #' @return Nothing returned diff --git a/man/dot-check_data.Rd b/man/dot-check_data.Rd new file mode 100644 index 0000000..d0e1b19 --- /dev/null +++ b/man/dot-check_data.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/distance.R +\name{.check_data} +\alias{.check_data} +\title{Validity check} +\usage{ +.check_data(input) +} +\arguments{ +\item{input}{A numeric vector} +} +\value{ +Nothing returned +} +\description{ +This functions checks for NAs in a vector +} From b42cdbfb646253c748f29e98398abe8babe2a008 Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Thu, 19 May 2022 21:53:15 -0400 Subject: [PATCH 04/14] Added unit test for euclideanDist function --- tests/testthat/test-euclidean.R | 9 +++++++++ tests/testthat/test-functions.R | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test-euclidean.R diff --git a/tests/testthat/test-euclidean.R b/tests/testthat/test-euclidean.R new file mode 100644 index 0000000..d51b9ad --- /dev/null +++ b/tests/testthat/test-euclidean.R @@ -0,0 +1,9 @@ +library("DevelExample") +data(example_data) + +test_that("Testing euclideanDist function", { + res <- dist(rbind(example_data[,1], example_data[,2]))[1] + expect_equal(euclideanDist(example_data[,1], example_data[,2]), res) + + expect_error(euclideanDist(c(1, 2), c(NA, 2)), regexp = "contain NAs") +}) diff --git a/tests/testthat/test-functions.R b/tests/testthat/test-functions.R index 5bfa2f2..d573a7c 100644 --- a/tests/testthat/test-functions.R +++ b/tests/testthat/test-functions.R @@ -5,7 +5,7 @@ test_that("multiplication works", { }) test_that("hello world message", { - expect_message(message(hello()), regexp = "Hello world.") + expect_message(message(hello()), regexp = "Hello world") }) test_that("hello world text with !", { From 86845959469b690683ddc0ba8ef1e7ab55f1d3fa Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Thu, 19 May 2022 22:11:01 -0400 Subject: [PATCH 05/14] fixed lints --- R/data.R | 4 ++-- R/distance.R | 21 +++++++++++---------- man/{dot-check_data.Rd => dot-checkData.Rd} | 6 +++--- man/euclideanDist.Rd | 7 ++++--- tests/testthat/test-euclidean.R | 6 +++--- 5 files changed, 23 insertions(+), 21 deletions(-) rename man/{dot-check_data.Rd => dot-checkData.Rd} (81%) diff --git a/R/data.R b/R/data.R index be00067..394dcb5 100644 --- a/R/data.R +++ b/R/data.R @@ -1,11 +1,11 @@ #' Example dataset #' #' A dataset containing a matrix with two columns that were generated -#' with a random normal distribution with a mean of 0 and stdev of 1. +#' with a random normal distribution with a mean of 0 and stdev of 1. #' #' @format A matrix with 100 rows and 2 columns #' @keywords datasets #' @usage data("example_data") #' @examples #' data("example_data") -"example_data" \ No newline at end of file +"example_data" diff --git a/R/distance.R b/R/distance.R index b28b001..93f8b93 100644 --- a/R/distance.R +++ b/R/distance.R @@ -1,10 +1,11 @@ #' @title Euclidean distance -#' @description Calculates Euclidean distance between two vectors. An error will be -#' given if NAs are present in either vector. +#' @description Calculates Euclidean distance between two vectors. An error +#' will be given if NAs are present in either vector. #' #' @param a The first vector to use in the distance calculation. #' @param b The second vector to use in the distance calculation. -#' @param verbose Boolean. If \code{TRUE}, a message will be printed. Default \code{TRUE}. +#' @param verbose Boolean. If \code{TRUE}, a message will be printed. +#' Default \code{TRUE}. #' @return A numeric value of a distance #' @examples #' data(example_data) @@ -14,23 +15,23 @@ euclideanDist <- function(a, b, verbose = FALSE) { if (isTRUE(verbose)) { message("Calculating distance ...") } - + # Check validity of data - .check_data(a) - .check_data(b) - + .checkData(a) + .checkData(b) + # Perform calculation - res <- sqrt(sum((a-b)^2)) + res <- sqrt(sum((a - b) ^ 2)) return(res) } #' Validity check -#' +#' #' This functions checks for NAs in a vector #' #' @param input A numeric vector #' @return Nothing returned -.check_data <- function(input) { +.checkData <- function(input) { if (any(is.na(input))) { stop("'input' must not contain NAs") } diff --git a/man/dot-check_data.Rd b/man/dot-checkData.Rd similarity index 81% rename from man/dot-check_data.Rd rename to man/dot-checkData.Rd index d0e1b19..28633bd 100644 --- a/man/dot-check_data.Rd +++ b/man/dot-checkData.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/distance.R -\name{.check_data} -\alias{.check_data} +\name{.checkData} +\alias{.checkData} \title{Validity check} \usage{ -.check_data(input) +.checkData(input) } \arguments{ \item{input}{A numeric vector} diff --git a/man/euclideanDist.Rd b/man/euclideanDist.Rd index ed10e85..d868d2c 100644 --- a/man/euclideanDist.Rd +++ b/man/euclideanDist.Rd @@ -11,14 +11,15 @@ euclideanDist(a, b, verbose = FALSE) \item{b}{The second vector to use in the distance calculation.} -\item{verbose}{Boolean. If \code{TRUE}, a message will be printed. Default \code{TRUE}.} +\item{verbose}{Boolean. If \code{TRUE}, a message will be printed. +Default \code{TRUE}.} } \value{ A numeric value of a distance } \description{ -Calculates Euclidean distance between two vectors. An error will be -given if NAs are present in either vector. +Calculates Euclidean distance between two vectors. An error +will be given if NAs are present in either vector. } \examples{ data(example_data) diff --git a/tests/testthat/test-euclidean.R b/tests/testthat/test-euclidean.R index d51b9ad..19ddcd0 100644 --- a/tests/testthat/test-euclidean.R +++ b/tests/testthat/test-euclidean.R @@ -2,8 +2,8 @@ library("DevelExample") data(example_data) test_that("Testing euclideanDist function", { - res <- dist(rbind(example_data[,1], example_data[,2]))[1] - expect_equal(euclideanDist(example_data[,1], example_data[,2]), res) - + res <- dist(rbind(example_data[, 1], example_data[, 2]))[1] + expect_equal(euclideanDist(example_data[, 1], example_data[, 2]), res) + expect_error(euclideanDist(c(1, 2), c(NA, 2)), regexp = "contain NAs") }) From 0d7807025cafe1bfcab7299b0120024fe583158c Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Fri, 20 May 2022 09:10:25 -0400 Subject: [PATCH 06/14] Added euclideanDist example to vignette --- vignettes/DevelExample.Rmd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vignettes/DevelExample.Rmd b/vignettes/DevelExample.Rmd index 170fadb..0bc4917 100644 --- a/vignettes/DevelExample.Rmd +++ b/vignettes/DevelExample.Rmd @@ -34,6 +34,19 @@ We can also run the same function but without all of the exclamation marks: hello(withExcitement = FALSE) ``` +To calculate the euclidean distance between two vectors, we can use the `euclideanDist` function. In this example we will generate two random vectors from normal distributions with two different means and calculate the distance between them: + +```{r dist} +set.seed(12345) +v1 <- rnorm(10000, mean = 1) +v2 <- rnorm(10000, mean = 2) +res <- euclideanDist(v1, v2, verbose = FALSE) +res +``` + +The `set.seed` function is used for the random number generator and ensures the same vectors will be produced each time for reproducibility. + + It is usually a good idea to show the session information to help with reproducibility: ```{r session} From 6c7a09196c3fed7552b8a2e38514c896ebed64bd Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Fri, 20 May 2022 09:36:08 -0400 Subject: [PATCH 07/14] Updated NEWS and bumped version number to 0.1.0 --- DESCRIPTION | 2 +- NEWS.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2418b46..f663d85 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: DevelExample Title: A Basic R Package to Demonstrate a Cycle of Code Development -Version: 0.0.1 +Version: 0.1.0 Authors@R: person(given = "Joshua", family = "Campbell", diff --git a/NEWS.md b/NEWS.md index 4cd8ae2..86504fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# Changes in Version 0.1.0 (2022-05-20) +* Added function to calculate euclidean distance + # Changes in Version 0.0.1 (2022-05-08) * Created package * Added Hello World function From eb388690ea73eda8a12c52a068e6af46f426375b Mon Sep 17 00:00:00 2001 From: "Joshua D. Campbell" Date: Fri, 20 May 2022 10:26:30 -0400 Subject: [PATCH 08/14] Updated pkgdown website files and removed 'docs' from .gitignore --- .gitignore | 1 - docs/404.html | 99 ++++++++ docs/LICENSE-text.html | 95 ++++++++ docs/LICENSE.html | 79 ++++++ docs/articles/DevelExample.html | 154 ++++++++++++ docs/articles/index.html | 73 ++++++ docs/authors.html | 94 ++++++++ docs/bootstrap-toc.css | 60 +++++ docs/bootstrap-toc.js | 159 +++++++++++++ docs/docsearch.css | 148 ++++++++++++ docs/docsearch.js | 85 +++++++ docs/index.html | 132 ++++++++++ docs/link.svg | 12 + docs/news/index.html | 82 +++++++ docs/pkgdown.css | 384 ++++++++++++++++++++++++++++++ docs/pkgdown.js | 108 +++++++++ docs/pkgdown.yml | 7 + docs/reference/Rplot001.png | Bin 0 -> 1011 bytes docs/reference/dot-checkData.html | 89 +++++++ docs/reference/euclideanDist.html | 103 ++++++++ docs/reference/example_data.html | 91 +++++++ docs/reference/hello.html | 96 ++++++++ docs/reference/index.html | 90 +++++++ docs/sitemap.xml | 42 ++++ 24 files changed, 2282 insertions(+), 1 deletion(-) create mode 100644 docs/404.html create mode 100644 docs/LICENSE-text.html create mode 100644 docs/LICENSE.html create mode 100644 docs/articles/DevelExample.html create mode 100644 docs/articles/index.html create mode 100644 docs/authors.html create mode 100644 docs/bootstrap-toc.css create mode 100644 docs/bootstrap-toc.js create mode 100644 docs/docsearch.css create mode 100644 docs/docsearch.js create mode 100644 docs/index.html create mode 100644 docs/link.svg create mode 100644 docs/news/index.html create mode 100644 docs/pkgdown.css create mode 100644 docs/pkgdown.js create mode 100644 docs/pkgdown.yml create mode 100644 docs/reference/Rplot001.png create mode 100644 docs/reference/dot-checkData.html create mode 100644 docs/reference/euclideanDist.html create mode 100644 docs/reference/example_data.html create mode 100644 docs/reference/hello.html create mode 100644 docs/reference/index.html create mode 100644 docs/sitemap.xml diff --git a/.gitignore b/.gitignore index 0dddc4b..2743be2 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,3 @@ vignettes/*.pdf # R Environment Variables .Renviron inst/doc -docs diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..794dfbf --- /dev/null +++ b/docs/404.html @@ -0,0 +1,99 @@ + + + + + + + +Page not found (404) • DevelExample + + + + + + + + + + + +
+
+ + + + +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + +
+ +
+

+

Site built with pkgdown 2.0.3.

+
+ +
+
+ + + + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html new file mode 100644 index 0000000..4732112 --- /dev/null +++ b/docs/LICENSE-text.html @@ -0,0 +1,95 @@ + +License • DevelExample + + +
+
+ + + +
+
+ + +
MIT License
+
+Copyright (c) 2022 campbio
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+ +
+ + + +
+ + + +
+ +
+

Site built with pkgdown 2.0.3.

+
+ +
+ + + + + + + + diff --git a/docs/LICENSE.html b/docs/LICENSE.html new file mode 100644 index 0000000..b60e81a --- /dev/null +++ b/docs/LICENSE.html @@ -0,0 +1,79 @@ + +MIT License • DevelExample + + +
+
+ + + +
+
+ + +
+

Copyright (c) 2022 DevelExample authors

+

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

+

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

+

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+
+ +
+ + + +
+ + + +
+ +
+

Site built with pkgdown 2.0.3.

+
+ +
+ + + + + + + + diff --git a/docs/articles/DevelExample.html b/docs/articles/DevelExample.html new file mode 100644 index 0000000..d3ce655 --- /dev/null +++ b/docs/articles/DevelExample.html @@ -0,0 +1,154 @@ + + + + + + + +R Development Example • DevelExample + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +

This is a simple vignette to demonstrate the functions that are available in the DevelExample package. The purpose of this package is to demonstrate the process of adding code to an R function. The full tutorial “Adding code to an R package” can be found at the Campbell lab website under the “Articles” tab.

+

Let’s first load the library:

+
+library(DevelExample)
+

Next we can run our function with default parameters:

+
+hello()
+#> [1] "Hello world!!!"
+

We can also run the same function but without all of the exclamation marks:

+
+hello(withExcitement = FALSE)
+#> [1] "Hello world."
+

To calculate the euclidean distance between two vectors, we can use the euclideanDist function. In this example we will generate two random vectors from normal distributions with two different means and calculate the distance between them:

+
+set.seed(12345)
+v1 <- rnorm(10000, mean = 1)
+v2 <- rnorm(10000, mean = 2)
+res <- euclideanDist(v1, v2, verbose = FALSE)
+res
+#> [1] 171.4371
+

The set.seed function is used for the random number generator and ensures the same vectors will be produced each time for reproducibility.

+

It is usually a good idea to show the session information to help with reproducibility:

+
+sessionInfo()
+#> R version 4.0.2 (2020-06-22)
+#> Platform: x86_64-apple-darwin17.0 (64-bit)
+#> Running under: macOS  10.16
+#> 
+#> Matrix products: default
+#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
+#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
+#> 
+#> locale:
+#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
+#> 
+#> attached base packages:
+#> [1] stats     graphics  grDevices utils     datasets  methods   base     
+#> 
+#> other attached packages:
+#> [1] DevelExample_0.1.0
+#> 
+#> loaded via a namespace (and not attached):
+#>  [1] rstudioapi_0.13   knitr_1.39        magrittr_2.0.1    R6_2.5.0         
+#>  [5] ragg_1.1.3        rlang_1.0.2       fastmap_1.1.0     stringr_1.4.0    
+#>  [9] tools_4.0.2       xfun_0.30         cli_3.3.0         jquerylib_0.1.3  
+#> [13] htmltools_0.5.2   systemfonts_1.0.1 yaml_2.2.1        digest_0.6.27    
+#> [17] rprojroot_2.0.2   pkgdown_2.0.3     crayon_1.4.1      textshaping_0.3.5
+#> [21] purrr_0.3.4       sass_0.4.1        fs_1.5.0          memoise_2.0.0    
+#> [25] cachem_1.0.4      evaluate_0.15     rmarkdown_2.14    stringi_1.5.3    
+#> [29] compiler_4.0.2    bslib_0.3.1       desc_1.3.0        jsonlite_1.7.2
+
+ + + +
+ + + +
+ +
+

+

Site built with pkgdown 2.0.3.

+
+ +
+
+ + + + + + + + diff --git a/docs/articles/index.html b/docs/articles/index.html new file mode 100644 index 0000000..3905764 --- /dev/null +++ b/docs/articles/index.html @@ -0,0 +1,73 @@ + +Articles • DevelExample + + +
+
+ + + +
+
+ + +
+

All vignettes

+

+ +
R Development Example
+
+
+
+
+ + +
+ +
+

Site built with pkgdown 2.0.3.

+
+ +
+ + + + + + + + diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..61c8a23 --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,94 @@ + +Authors and Citation • DevelExample + + +
+
+ + + +
+
+
+ + + +
  • +

    Joshua Campbell. Author, maintainer. +

    +
  • +
+
+
+

Citation

+ +
+
+ + +

Campbell J (2022). +DevelExample: A Basic R Package to Demonstrate a Cycle of Code Development. +R package version 0.1.0. +

+
@Manual{,
+  title = {DevelExample: A Basic R Package to Demonstrate a Cycle of Code Development},
+  author = {Joshua Campbell},
+  year = {2022},
+  note = {R package version 0.1.0},
+}
+ +
+ +
+ + + +
+ +
+

Site built with pkgdown 2.0.3.

+
+ +
+ + + + + + + + diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..379e1d7 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,132 @@ + + + + + + + +A Basic R Package to Demonstrate a Cycle of Code Development • DevelExample + + + + + + + + + + + + +
    +
    + + + + +
    +
    + + +
    + +

    A basic R package to demonstrate a cycle of code development

    +

    For use with the coding tutorial “Adding code to an R package” which can be found at camplab.net under the “Articles” tab.

    +
    + +
    + + +
    + + +
    + +
    +

    +

    Site built with pkgdown 2.0.3.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/link.svg b/docs/link.svg new file mode 100644 index 0000000..88ad827 --- /dev/null +++ b/docs/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/docs/news/index.html b/docs/news/index.html new file mode 100644 index 0000000..144e6e2 --- /dev/null +++ b/docs/news/index.html @@ -0,0 +1,82 @@ + +Changelog • DevelExample + + +
    +
    + + + +
    +
    + + +
    + +
    • Added function to calculate euclidean distance
    +
    + +
    • Created package
    • +
    • Added Hello World function
    • +
    • Added documentation, unit tests, and vignettes
    • +
    • Added a NEWS.md file to track changes to the package.
    • +
    +
    + + + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..80ea5b8 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,384 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +/* Ensure in-page images don't run outside their container */ +.contents img { + max-width: 100%; + height: auto; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + display: none; + margin-left: 5px; + width: 20px; + height: 20px; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +h1:hover .anchor, +h2:hover .anchor, +h3:hover .anchor, +h4:hover .anchor, +h5:hover .anchor, +h6:hover .anchor { + display: inline-block; +} + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre, code, pre code { + background-color: #f8f8f8; + color: #333; +} +pre, pre code { + white-space: pre-wrap; + word-break: break-all; + overflow-wrap: break-word; +} + +pre { + border: 1px solid #eee; +} + +pre .img, pre .r-plt { + margin: 5px 0; +} + +pre .img img, pre .r-plt img { + background-color: #fff; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.error {font-weight: bolder;} +.warning {font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} + +/* Section anchors --------------------------------- + Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 +*/ + +div.csl-bib-body { } +div.csl-entry { + clear: both; +} +.hanging-indent div.csl-entry { + margin-left:2em; + text-indent:-2em; +} +div.csl-left-margin { + min-width:2em; + float:left; +} +div.csl-right-inline { + margin-left:2em; + padding-left:1em; +} +div.csl-indent { + margin-left: 2em; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..6f0eee4 --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,108 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $("div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..de87fcb --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,7 @@ +pandoc: 2.11.4 +pkgdown: 2.0.3 +pkgdown_sha: ~ +articles: + DevelExample: DevelExample.html +last_built: 2022-05-20T13:37Z + diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 0000000000000000000000000000000000000000..17a358060aed2a86950757bbd25c6f92c08c458f GIT binary patch literal 1011 zcmeAS@N?(olHy`uVBq!ia0y~yV0-|=9Be?5+AI5}0x7m6Z+90U4Fo@(ch>_c&H|6f zVg?3oArNM~bhqvg0|WD9PZ!6KiaBo&GBN^{G%5UFpXcEKVvd5*5Eu=C0SJK)8A6*F U7`aXvEC5;V>FVdQ&MBb@00SN#Z2$lO literal 0 HcmV?d00001 diff --git a/docs/reference/dot-checkData.html b/docs/reference/dot-checkData.html new file mode 100644 index 0000000..42a8978 --- /dev/null +++ b/docs/reference/dot-checkData.html @@ -0,0 +1,89 @@ + +Validity check — .checkData • DevelExample + + +
    +
    + + + +
    +
    + + +
    +

    This functions checks for NAs in a vector

    +
    + +
    +
    .checkData(input)
    +
    + +
    +

    Arguments

    +
    input
    +

    A numeric vector

    +
    +
    +

    Value

    +

    Nothing returned

    +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/euclideanDist.html b/docs/reference/euclideanDist.html new file mode 100644 index 0000000..5c5ef70 --- /dev/null +++ b/docs/reference/euclideanDist.html @@ -0,0 +1,103 @@ + +Euclidean distance — euclideanDist • DevelExample + + +
    +
    + + + +
    +
    + + +
    +

    Calculates Euclidean distance between two vectors. An error +will be given if NAs are present in either vector.

    +
    + +
    +
    euclideanDist(a, b, verbose = FALSE)
    +
    + +
    +

    Arguments

    +
    a
    +

    The first vector to use in the distance calculation.

    +
    b
    +

    The second vector to use in the distance calculation.

    +
    verbose
    +

    Boolean. If TRUE, a message will be printed. +Default TRUE.

    +
    +
    +

    Value

    +

    A numeric value of a distance

    +
    + +
    +

    Examples

    +
    data(example_data)
    +euclideanDist(example_data[,1], example_data[,2], verbose = FALSE)
    +#> [1] 13.69805
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/example_data.html b/docs/reference/example_data.html new file mode 100644 index 0000000..07a79fd --- /dev/null +++ b/docs/reference/example_data.html @@ -0,0 +1,91 @@ + +Example dataset — example_data • DevelExample + + +
    +
    + + + +
    +
    + + +
    +

    A dataset containing a matrix with two columns that were generated +with a random normal distribution with a mean of 0 and stdev of 1.

    +
    + +
    +
    data("example_data")
    +
    + +
    +

    Format

    +

    A matrix with 100 rows and 2 columns

    +
    + +
    +

    Examples

    +
    data("example_data")
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/hello.html b/docs/reference/hello.html new file mode 100644 index 0000000..8a571fe --- /dev/null +++ b/docs/reference/hello.html @@ -0,0 +1,96 @@ + +Hello world — hello • DevelExample + + +
    +
    + + + +
    +
    + + +
    +

    A simple function to print Hello world

    +
    + +
    +
    hello(withExcitement = TRUE)
    +
    + +
    +

    Arguments

    +
    withExcitement
    +

    Boolean. If TRUE, then the message +will be printed with exlamation points. Default TRUE.

    +
    +
    +

    Value

    +

    A string with the hello world text

    +
    + +
    +

    Examples

    +
    hello(withExcitement = TRUE)
    +#> [1] "Hello world!!!"
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..b8bbf27 --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,90 @@ + +Function reference • DevelExample + + +
    +
    + + + +
    +
    + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    .checkData()

    +

    Validity check

    +

    euclideanDist()

    +

    Euclidean distance

    +

    example_data

    +

    Example dataset

    +

    hello()

    +

    Hello world

    + + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.3.

    +
    + +
    + + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..20905ab --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,42 @@ + + + + /404.html + + + /LICENSE-text.html + + + /LICENSE.html + + + /articles/DevelExample.html + + + /articles/index.html + + + /authors.html + + + /index.html + + + /news/index.html + + + /reference/dot-checkData.html + + + /reference/euclideanDist.html + + + /reference/example_data.html + + + /reference/hello.html + + + /reference/index.html + + From 0c7a91bde7612e0846a5015cc6663ab3ccbc8df3 Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Mon, 4 Sep 2023 16:33:43 -0400 Subject: [PATCH 09/14] Added new example dataset and used it in the example for the euclidianDist fxn --- DESCRIPTION | 2 +- NAMESPACE | 1 - R/distance.R | 33 +++++++-------------------------- data-raw/example_data.R | 1 + data/example_data.rda | Bin 2010 -> 2009 bytes man/dot-checkData.Rd | 17 ----------------- man/euclideanDist.Rd | 27 --------------------------- 7 files changed, 9 insertions(+), 72 deletions(-) delete mode 100644 man/dot-checkData.Rd delete mode 100644 man/euclideanDist.Rd diff --git a/DESCRIPTION b/DESCRIPTION index f663d85..5884c4a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,7 +15,7 @@ Encoding: UTF-8 biocViews: Clustering LazyData: false Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.3 Suggests: knitr, rmarkdown, diff --git a/NAMESPACE b/NAMESPACE index 6bd620a..01843dc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,3 @@ # Generated by roxygen2: do not edit by hand -export(euclideanDist) export(hello) diff --git a/R/distance.R b/R/distance.R index 93f8b93..054f88c 100644 --- a/R/distance.R +++ b/R/distance.R @@ -1,38 +1,19 @@ -#' @title Euclidean distance -#' @description Calculates Euclidean distance between two vectors. An error -#' will be given if NAs are present in either vector. -#' -#' @param a The first vector to use in the distance calculation. -#' @param b The second vector to use in the distance calculation. -#' @param verbose Boolean. If \code{TRUE}, a message will be printed. -#' Default \code{TRUE}. -#' @return A numeric value of a distance -#' @examples -#' data(example_data) -#' euclideanDist(example_data[,1], example_data[,2], verbose = FALSE) -#' @export euclideanDist <- function(a, b, verbose = FALSE) { if (isTRUE(verbose)) { message("Calculating distance ...") } - + # Check validity of data - .checkData(a) - .checkData(b) - + .check_data(a) + .check_data(b) + # Perform calculation - res <- sqrt(sum((a - b) ^ 2)) + res <- sqrt(sum((a-b)^2)) return(res) } -#' Validity check -#' -#' This functions checks for NAs in a vector -#' -#' @param input A numeric vector -#' @return Nothing returned -.checkData <- function(input) { +.check_data <- function(input) { if (any(is.na(input))) { stop("'input' must not contain NAs") } -} +} \ No newline at end of file diff --git a/data-raw/example_data.R b/data-raw/example_data.R index 24efc73..6521d8a 100644 --- a/data-raw/example_data.R +++ b/data-raw/example_data.R @@ -1,4 +1,5 @@ ## code to prepare `example_data` dataset goes here +## code to prepare `example_data` dataset goes here set.seed(123) a <- rnorm(100) b <- rnorm(100) diff --git a/data/example_data.rda b/data/example_data.rda index cfdadd051565028c4850e318a879fccc388bd049..c16d4321456ba9323c64133d9a4e2589c279122e 100644 GIT binary patch delta 1941 zcmV;G2Wt4*57`e6LRx4!F+o`-Q(5(P$9j?A=Cb+q?jiYI#jG{X%|}dT5(b z>5@H0(ionjA(|l3iKc@?BPM|L4K)2mPUp$W2$sf55IM%2ceQK)SbX)+Bkjj4#qgv|z1O&*O* zjDI6F0Li8!)WpphC$xmdq3Jy!exeL&V27#Y2AW_a(G4?5dLE%YLq^oX42dz2Jt3i~ znrRqMP!B2S3F>Im5vG|m159dWNt&LKv}nZB6v*`+nwo7vk%Teoh9{I{7)B?lk){a7 zfiMY>(Daxzo}*0zN1y}%XcHO$08BIh042}>CIAG$0003n000vs02%-QOad?iKmY&$ z1Y|G(07TG1Nwg-DS^+nIWGNK|jadekWGW#GQ<`L~3gfH-0^y}WNCXCf0-VG#3^j59 zfKx!RZ$0*LiHsyvNKg$6ftFQk)cJW#!AH|gg zYUR`jyJ-1m2(Xmm2m;1cLB%w(F0t1MJL$_u~%`7`{ZnY#bcQl3`D8nmWCst zD~=+OX6eKx7IktU0w3lTER+u(he#1&H8^w)l?87WE}A;9xvEp_OpbX%O~o38FRaim`oyJEOVT~;qHlzH z4>?idolHh~0u3*JF*qJDr^Fs9?r|m&B3-@Vafet+KUSrlRl$@zFXG-z*Z8%#jR~Z} zTTmeMOJpnGb=lWEUH%R-Cp};4^n@C7pQe_)Tnm?&^(zynXAqZmbe))FFZbg`QN9Y^ zIHUdUD&oHe0g!mp!9OaHHGo~q%v1x$0}M;yiwb$4JQ0e2B@307uwNkjPK60nXsjMo z<-%$f1pS#DM;Ve3h#(rC@p(o*)RcB6IeDTQ!_Ww_HDlONfUh{To92>|Q4V&V2|D+E zdNjcVVXgbSK28+Z&Wi(49wTDf>cs}v_6VdCVoKykIST36X?H4#I}QwDL6(1_(Uy%RPWl}PnfTJZsu zMLT1RZ06h)b1n!{7961g9_*=VIE15p%uX-nef%T-yW2q|ADL&@(c|11bR%Veb?~kv z)@XGGii`hQ@67|>m=#XNzPT93D_3ao6t{vc3u57aqie!-rYgzsK%ha{U|1EnBBKHu zI3d7ATZ>hj8OtSU2(P4Ilv*GaSn~L1lSJ0PV*8a*9X5SpO)ynYySW+q0fl1Is|c}j z>Ops8hyQFJDYfFRc@kB%J7r#gVKO)vME;9R0xp*bmVQPE)Xw^=!|8M{wXV3C z!&$?BIobrdonA(ufNPY!hy&>6N~tMk8u5A?R%31xn&@7#zFpMbO0)HF!P`NeDCw`2 zF&`vkG20n4=>d&XQ7~Q5emuT6&`>&^thVjFGoBEIm55=hf8YA>|l6)kPc zLfYOmuRR3gKRw=ljm>#g@TK5HLldKj;=;C5wBE_|7YTurgRRBjLHF3C1#lKLFw7+7@WD{$Opl@j3FR z7H3!|M%H*tFNN*iMr!iaHdTa&uA$p*BW%8Zl zgUzbXyH_MB1CY4redst}ttOX_hcZywXzZkVIYRYjRcuK?%}%#HRC3WMW5ksiGlZUZ zjS(``~(Hy`s;tnQ%*7eZdh)FI_4KD=56M@wc zmMKD|fr1iIZd~!I72*)U>w78(NWNlMu@;m=MC@A3^+I@7dzA5LCQ|&UxXDvP@6HbJ zb)>?GXdV-Kcet7R1XTzk5l|ZA97yKAlbCc#F8i4BHAXP}%Zo8aprsL15X0L(hV+c9 zm*W}GWKxu_76`c3R0vi^YE0l^%-zh|!bH>5rQvp@74jlN(9&uaglwx{~9)dka z(3)+ifsICuG-;-TO*W>P2dMQ8Ge$&hPf*BunrWtLG-%pJgVK6KO+8Ohka}bgJb=_` z=trd5o~P=bNs;NMnI;f0Y7%2f`liZerk;}#vYDpU9-}l(G{|K1Luv*_Bh>XCnns?d zq<{4`p`+A!O)x=-^wK>~QwijQG*2nCf$11Bo}mh{Q5vzydr#2=y_hM0yF6YG#Bq(USsxplD18$%xt!fEocb z(dnt_GBRm|X_^Gcz$QRUXaE2J00A%!03|d400E#(BLDyZ000wBpa2Gd002e_fJRJ) z000001XI&U6q`VkS^+nIG%^Z;#=LsQq*V}x|7KY#;<)Pp09-W4nFIhDL<}Gxc9aMJ z=m3CI!7*?>@^y(2f&u~qK@$#e#p|2IkR8>5Y|{juG0VIO{8ZT1THL0%Gfy`Bd3xuf z@#rl6^aIZ}Q0ADsg=fl=0<5*LRu8Dj{~EH-9~-4mQWa(ESl6;KPu8WF&eKLiN&6f7 z^$`5Or7IE~bg5l`_$-0#CZTVrk@Z59Oh}hbGDYCVS9uj#U*KrDot4dm`c6;xA7>LH_r<)q=N>VI|(bD>V^@!BxP!(U2>*>Yp&ewJcVv?y@C{0{1c*%(02wOf=7y{Ty+*=9l!Rv&;zk_tbG2xou0qTCTNEgR#i?n~FP z>(Tr(o@A|+b$pyEu$>hG6q2k#v6%7=aWGA>sn#X*3{yDlhErRoyq$mpG@nCHc4IAg z$M4S~OT^EA)r%EK1ShEh_FM|e3&P;yUc#Gqk-0$#%Wq7a6|5iSqoTWRminYp#On9z zg-95f`MhEX#}!33xf)&dQ#vGXo=NxCLg-)7C3s;hM#7fn@AxiVVKl+#^gbk*2HxaB zI1kL6+zp)~SWo$G(uoax@Eq)p$#}P(1&4=8vvj(D5~2V-6&tIDWaWWPur!H!A_9RH zLiXlE3?VQRFjPSn6%0E6uz++U$_>c;_8d4?XcusQ#TnZ&5!@vr=?CYB83xl+iXRF3 zJp`&Bo2;!gI}5R>MVtYA!KC$?Hts7l&rpXZsn-lw9L2=j}XDV zqAkJCay~ogVDfv6ycJb>_UT6m*Hr3wu?x`Aa^cm}Dutn0!WQ080H(G%tO2PiNU?Cl{xY&gs-n@x^;2nI_l zQyF{=Q&7rrMHrd4KWSlfe4D3smJl-Py6`00l-Us-VXS#9WL;@@)5y?@hJ0V}z6RqO zN&Cis-GrsE-6aKZzD98C9VeO-XH{u`y$b2l0z)RrY4RcE-V{g+Sp?zHJxTC|D**U3 zz;8(tL81{vF4mNaNs&=KynGMryD|YuWeaMSFhs?s*R^AapsuFQ==q=bzDLWq)GdvWb)4cSw56h2?FB}EnZ=lA zv6V#E={My=H;m@lsTzhn2s``hCpAM0aiB(kSWGb|cGXZX6-iFwcbMeZ3-n6$K=SM5 zd#4AhO`CMCL{bMaa?pE`IA3iAF&_{~L+NAkatQK8?#imzqXVLyUUI1Nk(DFG861(q zQ#r+nnr71{PGbYBDS&>XyC({NL%j*>Vs9~qz2*qWWH0(UV>FBgs_}56IY}Fw~e;!Xg-JU(CG& zEa&&d^Vt-pGmU;SIh7F#z|G1W2y+)=Zeb)-^v2-!WL5E_BWG$VCWT-!5vOwS>-Xnu c*aTR=9vTulQXN*b=|AG`NT&)C6WFMTAlLMSd;kCd diff --git a/man/dot-checkData.Rd b/man/dot-checkData.Rd deleted file mode 100644 index 28633bd..0000000 --- a/man/dot-checkData.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distance.R -\name{.checkData} -\alias{.checkData} -\title{Validity check} -\usage{ -.checkData(input) -} -\arguments{ -\item{input}{A numeric vector} -} -\value{ -Nothing returned -} -\description{ -This functions checks for NAs in a vector -} diff --git a/man/euclideanDist.Rd b/man/euclideanDist.Rd deleted file mode 100644 index d868d2c..0000000 --- a/man/euclideanDist.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/distance.R -\name{euclideanDist} -\alias{euclideanDist} -\title{Euclidean distance} -\usage{ -euclideanDist(a, b, verbose = FALSE) -} -\arguments{ -\item{a}{The first vector to use in the distance calculation.} - -\item{b}{The second vector to use in the distance calculation.} - -\item{verbose}{Boolean. If \code{TRUE}, a message will be printed. -Default \code{TRUE}.} -} -\value{ -A numeric value of a distance -} -\description{ -Calculates Euclidean distance between two vectors. An error -will be given if NAs are present in either vector. -} -\examples{ -data(example_data) -euclideanDist(example_data[,1], example_data[,2], verbose = FALSE) -} From a5a44e08eac2f7d4d4814791f93e17710ac7669f Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Mon, 4 Sep 2023 17:44:11 -0400 Subject: [PATCH 10/14] Add NEWS.md --- NEWS.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 86504fb..eaad579 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,3 @@ -# Changes in Version 0.1.0 (2022-05-20) -* Added function to calculate euclidean distance +# DevelExample 0.1.0 -# Changes in Version 0.0.1 (2022-05-08) -* Created package -* Added Hello World function -* Added documentation, unit tests, and vignettes -* Added a `NEWS.md` file to track changes to the package. +* Initial CRAN submission. From f068bebe976eb02c1ebb514c04594856a6f21e5d Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Sun, 17 Sep 2023 19:22:40 -0400 Subject: [PATCH 11/14] Eucl Distance --- .Rbuildignore | 2 + .Rprofile | 1 + .gitignore | 1 + renv/.gitignore | 7 + renv/activate.R | 1201 ++++++++++++++++++++++++++++++++++++++++++++ renv/settings.json | 19 + 6 files changed, 1231 insertions(+) create mode 100644 .Rprofile create mode 100644 renv/.gitignore create mode 100644 renv/activate.R create mode 100644 renv/settings.json diff --git a/.Rbuildignore b/.Rbuildignore index 6624a45..c1f5b85 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ +^renv$ +^renv\.lock$ ^LICENSE\.md$ ^.*\.Rproj$ ^\.Rproj\.user$ diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..81b960f --- /dev/null +++ b/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/.gitignore b/.gitignore index 2743be2..0dddc4b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ vignettes/*.pdf # R Environment Variables .Renviron inst/doc +docs diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000..0ec0cbb --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,7 @@ +library/ +local/ +cellar/ +lock/ +python/ +sandbox/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000..2969c73 --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,1201 @@ + +local({ + + # the requested version of renv + version <- "1.0.2" + attr(version, "sha") <- NULL + + # the project directory + project <- getwd() + + # use start-up diagnostics if enabled + diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE") + if (diagnostics) { + start <- Sys.time() + profile <- tempfile("renv-startup-", fileext = ".Rprof") + utils::Rprof(profile) + on.exit({ + utils::Rprof(NULL) + elapsed <- signif(difftime(Sys.time(), start, units = "auto"), digits = 2L) + writeLines(sprintf("- renv took %s to run the autoloader.", format(elapsed))) + writeLines(sprintf("- Profile: %s", profile)) + print(utils::summaryRprof(profile)) + }, add = TRUE) + } + + # figure out whether the autoloader is enabled + enabled <- local({ + + # first, check config option + override <- getOption("renv.config.autoloader.enabled") + if (!is.null(override)) + return(override) + + # next, check environment variables + # TODO: prefer using the configuration one in the future + envvars <- c( + "RENV_CONFIG_AUTOLOADER_ENABLED", + "RENV_AUTOLOADER_ENABLED", + "RENV_ACTIVATE_PROJECT" + ) + + for (envvar in envvars) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(tolower(envval) %in% c("true", "t", "1")) + } + + # enable by default + TRUE + + }) + + if (!enabled) + return(FALSE) + + # avoid recursion + if (identical(getOption("renv.autoloader.running"), TRUE)) { + warning("ignoring recursive attempt to run renv autoloader") + return(invisible(TRUE)) + } + + # signal that we're loading renv during R startup + options(renv.autoloader.running = TRUE) + on.exit(options(renv.autoloader.running = NULL), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # unload renv if it's already been loaded + if ("renv" %in% loadedNamespaces()) + unloadNamespace("renv") + + # load bootstrap tools + `%||%` <- function(x, y) { + if (is.null(x)) y else x + } + + catf <- function(fmt, ..., appendLF = TRUE) { + + quiet <- getOption("renv.bootstrap.quiet", default = FALSE) + if (quiet) + return(invisible()) + + msg <- sprintf(fmt, ...) + cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") + + invisible(msg) + + } + + header <- function(label, + ..., + prefix = "#", + suffix = "-", + n = min(getOption("width"), 78)) + { + label <- sprintf(label, ...) + n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) + if (n <= 0) + return(paste(prefix, label)) + + tail <- paste(rep.int(suffix, n), collapse = "") + paste0(prefix, " ", label, " ", tail) + + } + + startswith <- function(string, prefix) { + substring(string, 1, nchar(prefix)) == prefix + } + + bootstrap <- function(version, library) { + + friendly <- renv_bootstrap_version_friendly(version) + section <- header(sprintf("Bootstrapping renv %s", friendly)) + catf(section) + + # attempt to download renv + catf("- Downloading renv ... ", appendLF = FALSE) + withCallingHandlers( + tarball <- renv_bootstrap_download(version), + error = function(err) { + catf("FAILED") + stop("failed to download:\n", conditionMessage(err)) + } + ) + catf("OK") + on.exit(unlink(tarball), add = TRUE) + + # now attempt to install + catf("- Installing renv ... ", appendLF = FALSE) + withCallingHandlers( + status <- renv_bootstrap_install(version, tarball, library), + error = function(err) { + catf("FAILED") + stop("failed to install:\n", conditionMessage(err)) + } + ) + catf("OK") + + # add empty line to break up bootstrapping from normal output + catf("") + + return(invisible()) + } + + renv_bootstrap_tests_running <- function() { + getOption("renv.tests.running", default = FALSE) + } + + renv_bootstrap_repos <- function() { + + # get CRAN repository + cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") + + # check for repos override + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (!is.na(repos)) { + + # check for RSPM; if set, use a fallback repository for renv + rspm <- Sys.getenv("RSPM", unset = NA) + if (identical(rspm, repos)) + repos <- c(RSPM = rspm, CRAN = cran) + + return(repos) + + } + + # check for lockfile repositories + repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) + if (!inherits(repos, "error") && length(repos)) + return(repos) + + # retrieve current repos + repos <- getOption("repos") + + # ensure @CRAN@ entries are resolved + repos[repos == "@CRAN@"] <- cran + + # add in renv.bootstrap.repos if set + default <- c(FALLBACK = "https://cloud.r-project.org") + extra <- getOption("renv.bootstrap.repos", default = default) + repos <- c(repos, extra) + + # remove duplicates that might've snuck in + dupes <- duplicated(repos) | duplicated(names(repos)) + repos[!dupes] + + } + + renv_bootstrap_repos_lockfile <- function() { + + lockpath <- Sys.getenv("RENV_PATHS_LOCKFILE", unset = "renv.lock") + if (!file.exists(lockpath)) + return(NULL) + + lockfile <- tryCatch(renv_json_read(lockpath), error = identity) + if (inherits(lockfile, "error")) { + warning(lockfile) + return(NULL) + } + + repos <- lockfile$R$Repositories + if (length(repos) == 0) + return(NULL) + + keys <- vapply(repos, `[[`, "Name", FUN.VALUE = character(1)) + vals <- vapply(repos, `[[`, "URL", FUN.VALUE = character(1)) + names(vals) <- keys + + return(vals) + + } + + renv_bootstrap_download <- function(version) { + + sha <- attr(version, "sha", exact = TRUE) + + methods <- if (!is.null(sha)) { + + # attempting to bootstrap a development version of renv + c( + function() renv_bootstrap_download_tarball(sha), + function() renv_bootstrap_download_github(sha) + ) + + } else { + + # attempting to bootstrap a release version of renv + c( + function() renv_bootstrap_download_tarball(version), + function() renv_bootstrap_download_cran_latest(version), + function() renv_bootstrap_download_cran_archive(version) + ) + + } + + for (method in methods) { + path <- tryCatch(method(), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("All download methods failed") + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + args <- list( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + if ("headers" %in% names(formals(utils::download.file))) + args$headers <- renv_bootstrap_download_custom_headers(url) + + do.call(utils::download.file, args) + + } + + renv_bootstrap_download_custom_headers <- function(url) { + + headers <- getOption("renv.download.headers") + if (is.null(headers)) + return(character()) + + if (!is.function(headers)) + stopf("'renv.download.headers' is not a function") + + headers <- headers(url) + if (length(headers) == 0L) + return(character()) + + if (is.list(headers)) + headers <- unlist(headers, recursive = FALSE, use.names = TRUE) + + ok <- + is.character(headers) && + is.character(names(headers)) && + all(nzchar(names(headers))) + + if (!ok) + stop("invocation of 'renv.download.headers' did not return a named character vector") + + headers + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + spec <- renv_bootstrap_download_cran_latest_find(version) + type <- spec$type + repos <- spec$repos + + baseurl <- utils::contrib.url(repos = repos, type = type) + ext <- if (identical(type, "source")) + ".tar.gz" + else if (Sys.info()[["sysname"]] == "Windows") + ".zip" + else + ".tgz" + name <- sprintf("renv_%s%s", version, ext) + url <- paste(baseurl, name, sep = "/") + + destfile <- file.path(tempdir(), name) + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (inherits(status, "condition")) + return(FALSE) + + # report success and return + destfile + + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + + # check whether binaries are supported on this system + binary <- + getOption("renv.bootstrap.binary", default = TRUE) && + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") + + types <- c(if (binary) "binary", "source") + + # iterate over types + repositories + for (type in types) { + for (repos in renv_bootstrap_repos()) { + + # retrieve package database + db <- tryCatch( + as.data.frame( + utils::available.packages(type = type, repos = repos), + stringsAsFactors = FALSE + ), + error = identity + ) + + if (inherits(db, "error")) + next + + # check for compatible entry + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + # found it; return spec to caller + spec <- list(entry = entry, type = type, repos = repos) + return(spec) + + } + } + + # if we got here, we failed to find renv + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- renv_bootstrap_repos() + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) + return(destfile) + + } + + return(FALSE) + + } + + renv_bootstrap_download_tarball <- function(version) { + + # if the user has provided the path to a tarball via + # an environment variable, then use it + tarball <- Sys.getenv("RENV_BOOTSTRAP_TARBALL", unset = NA) + if (is.na(tarball)) + return() + + # allow directories + if (dir.exists(tarball)) { + name <- sprintf("renv_%s.tar.gz", version) + tarball <- file.path(tarball, name) + } + + # bail if it doesn't exist + if (!file.exists(tarball)) { + + # let the user know we weren't able to honour their request + fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + msg <- sprintf(fmt, tarball) + warning(msg) + + # bail + return() + + } + + catf("- Using local tarball '%s'.", tarball) + tarball + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) + return(FALSE) + + renv_bootstrap_download_augment(destfile) + + return(destfile) + + } + + # Add Sha to DESCRIPTION. This is stop gap until #890, after which we + # can use renv::install() to fully capture metadata. + renv_bootstrap_download_augment <- function(destfile) { + sha <- renv_bootstrap_git_extract_sha1_tar(destfile) + if (is.null(sha)) { + return() + } + + # Untar + tempdir <- tempfile("renv-github-") + on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) + untar(destfile, exdir = tempdir) + pkgdir <- dir(tempdir, full.names = TRUE)[[1]] + + # Modify description + desc_path <- file.path(pkgdir, "DESCRIPTION") + desc_lines <- readLines(desc_path) + remotes_fields <- c( + "RemoteType: github", + "RemoteHost: api.github.com", + "RemoteRepo: renv", + "RemoteUsername: rstudio", + "RemotePkgRef: rstudio/renv", + paste("RemoteRef: ", sha), + paste("RemoteSha: ", sha) + ) + writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) + + # Re-tar + local({ + old <- setwd(tempdir) + on.exit(setwd(old), add = TRUE) + + tar(destfile, compression = "gzip") + }) + invisible() + } + + # Extract the commit hash from a git archive. Git archives include the SHA1 + # hash as the comment field of the tarball pax extended header + # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) + # For GitHub archives this should be the first header after the default one + # (512 byte) header. + renv_bootstrap_git_extract_sha1_tar <- function(bundle) { + + # open the bundle for reading + # We use gzcon for everything because (from ?gzcon) + # > Reading from a connection which does not supply a 'gzip' magic + # > header is equivalent to reading from the original connection + conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) + on.exit(close(conn)) + + # The default pax header is 512 bytes long and the first pax extended header + # with the comment should be 51 bytes long + # `52 comment=` (11 chars) + 40 byte SHA1 hash + len <- 0x200 + 0x33 + res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) + + if (grepl("^52 comment=", res)) { + sub("52 comment=", "", res) + } else { + NULL + } + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + dir.create(library, showWarnings = FALSE, recursive = TRUE) + output <- renv_bootstrap_install_impl(library, tarball) + + # check for successful install + status <- attr(output, "status") + if (is.null(status) || identical(status, 0L)) + return(status) + + # an error occurred; report it + header <- "installation of renv failed" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- paste(c(header, lines, output), collapse = "\n") + stop(text) + + } + + renv_bootstrap_install_impl <- function(library, tarball) { + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + R <- file.path(bin, exe) + + args <- c( + "--vanilla", "CMD", "INSTALL", "--no-multiarch", + "-l", shQuote(path.expand(library)), + shQuote(path.expand(tarball)) + ) + + system2(R, args, stdout = TRUE, stderr = TRUE) + + } + + renv_bootstrap_platform_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- renv_bootstrap_platform_prefix_impl() + if (!is.na(prefix) && nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_platform_prefix_impl <- function() { + + # if an explicit prefix has been supplied, use it + prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) + if (!is.na(prefix)) + return(prefix) + + # if the user has requested an automatic prefix, generate it + auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (auto %in% c("TRUE", "True", "true", "1")) + return(renv_bootstrap_platform_prefix_auto()) + + # empty string on failure + "" + + } + + renv_bootstrap_platform_prefix_auto <- function() { + + prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) + if (inherits(prefix, "error") || prefix %in% "unknown") { + + msg <- paste( + "failed to infer current operating system", + "please file a bug report at https://github.com/rstudio/renv/issues", + sep = "; " + ) + + warning(msg) + + } + + prefix + + } + + renv_bootstrap_platform_os <- function() { + + sysinfo <- Sys.info() + sysname <- sysinfo[["sysname"]] + + # handle Windows + macOS up front + if (sysname == "Windows") + return("windows") + else if (sysname == "Darwin") + return("macos") + + # check for os-release files + for (file in c("/etc/os-release", "/usr/lib/os-release")) + if (file.exists(file)) + return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) + + # check for redhat-release files + if (file.exists("/etc/redhat-release")) + return(renv_bootstrap_platform_os_via_redhat_release()) + + "unknown" + + } + + renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { + + # read /etc/os-release + release <- utils::read.table( + file = file, + sep = "=", + quote = c("\"", "'"), + col.names = c("Key", "Value"), + comment.char = "#", + stringsAsFactors = FALSE + ) + + vars <- as.list(release$Value) + names(vars) <- release$Key + + # get os name + os <- tolower(sysinfo[["sysname"]]) + + # read id + id <- "unknown" + for (field in c("ID", "ID_LIKE")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + id <- vars[[field]] + break + } + } + + # read version + version <- "unknown" + for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + version <- vars[[field]] + break + } + } + + # join together + paste(c(os, id, version), collapse = "-") + + } + + renv_bootstrap_platform_os_via_redhat_release <- function() { + + # read /etc/redhat-release + contents <- readLines("/etc/redhat-release", warn = FALSE) + + # infer id + id <- if (grepl("centos", contents, ignore.case = TRUE)) + "centos" + else if (grepl("redhat", contents, ignore.case = TRUE)) + "redhat" + else + "unknown" + + # try to find a version component (very hacky) + version <- "unknown" + + parts <- strsplit(contents, "[[:space:]]")[[1L]] + for (part in parts) { + + nv <- tryCatch(numeric_version(part), error = identity) + if (inherits(nv, "error")) + next + + version <- nv[1, 1] + break + + } + + paste(c("linux", id, version), collapse = "-") + + } + + renv_bootstrap_library_root_name <- function(project) { + + # use project name as-is if requested + asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") + if (asis) + return(basename(project)) + + # otherwise, disambiguate based on project's path + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + paste(basename(project), id, sep = "-") + + } + + renv_bootstrap_library_root <- function(project) { + + prefix <- renv_bootstrap_profile_prefix() + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(paste(c(path, prefix), collapse = "/")) + + path <- renv_bootstrap_library_root_impl(project) + if (!is.null(path)) { + name <- renv_bootstrap_library_root_name(project) + return(paste(c(path, prefix, name), collapse = "/")) + } + + renv_bootstrap_paths_renv("library", project = project) + + } + + renv_bootstrap_library_root_impl <- function(project) { + + root <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(root)) + return(root) + + type <- renv_bootstrap_project_type(project) + if (identical(type, "package")) { + userdir <- renv_bootstrap_user_dir() + return(file.path(userdir, "library")) + } + + } + + renv_bootstrap_validate_version <- function(version, description = NULL) { + + # resolve description file + # + # avoid passing lib.loc to `packageDescription()` below, since R will + # use the loaded version of the package by default anyhow. note that + # this function should only be called after 'renv' is loaded + # https://github.com/rstudio/renv/issues/1625 + description <- description %||% packageDescription("renv") + + # check whether requested version 'version' matches loaded version of renv + sha <- attr(version, "sha", exact = TRUE) + valid <- if (!is.null(sha)) + renv_bootstrap_validate_version_dev(sha, description) + else + renv_bootstrap_validate_version_release(version, description) + + if (valid) + return(TRUE) + + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + remote <- if (!is.null(description[["RemoteSha"]])) { + paste("rstudio/renv", description[["RemoteSha"]], sep = "@") + } else { + paste("renv", description[["Version"]], sep = "@") + } + + # display both loaded version + sha if available + friendly <- renv_bootstrap_version_friendly( + version = description[["Version"]], + sha = description[["RemoteSha"]] + ) + + fmt <- paste( + "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", + "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) + + FALSE + + } + + renv_bootstrap_validate_version_dev <- function(version, description) { + expected <- description[["RemoteSha"]] + is.character(expected) && startswith(expected, version) + } + + renv_bootstrap_validate_version_release <- function(version, description) { + expected <- description[["Version"]] + is.character(expected) && identical(expected, version) + } + + renv_bootstrap_hash_text <- function(text) { + + hashfile <- tempfile("renv-hash-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warnify) + + # load the project + renv::load(project) + + TRUE + + } + + renv_bootstrap_profile_load <- function(project) { + + # if RENV_PROFILE is already set, just use that + profile <- Sys.getenv("RENV_PROFILE", unset = NA) + if (!is.na(profile) && nzchar(profile)) + return(profile) + + # check for a profile file (nothing to do if it doesn't exist) + path <- renv_bootstrap_paths_renv("profile", profile = FALSE, project = project) + if (!file.exists(path)) + return(NULL) + + # read the profile, and set it if it exists + contents <- readLines(path, warn = FALSE) + if (length(contents) == 0L) + return(NULL) + + # set RENV_PROFILE + profile <- contents[[1L]] + if (!profile %in% c("", "default")) + Sys.setenv(RENV_PROFILE = profile) + + profile + + } + + renv_bootstrap_profile_prefix <- function() { + profile <- renv_bootstrap_profile_get() + if (!is.null(profile)) + return(file.path("profiles", profile, "renv")) + } + + renv_bootstrap_profile_get <- function() { + profile <- Sys.getenv("RENV_PROFILE", unset = "") + renv_bootstrap_profile_normalize(profile) + } + + renv_bootstrap_profile_set <- function(profile) { + profile <- renv_bootstrap_profile_normalize(profile) + if (is.null(profile)) + Sys.unsetenv("RENV_PROFILE") + else + Sys.setenv(RENV_PROFILE = profile) + } + + renv_bootstrap_profile_normalize <- function(profile) { + + if (is.null(profile) || profile %in% c("", "default")) + return(NULL) + + profile + + } + + renv_bootstrap_path_absolute <- function(path) { + + substr(path, 1L, 1L) %in% c("~", "/", "\\") || ( + substr(path, 1L, 1L) %in% c(letters, LETTERS) && + substr(path, 2L, 3L) %in% c(":/", ":\\") + ) + + } + + renv_bootstrap_paths_renv <- function(..., profile = TRUE, project = NULL) { + renv <- Sys.getenv("RENV_PATHS_RENV", unset = "renv") + root <- if (renv_bootstrap_path_absolute(renv)) NULL else project + prefix <- if (profile) renv_bootstrap_profile_prefix() + components <- c(root, renv, prefix, ...) + paste(components, collapse = "/") + } + + renv_bootstrap_project_type <- function(path) { + + descpath <- file.path(path, "DESCRIPTION") + if (!file.exists(descpath)) + return("unknown") + + desc <- tryCatch( + read.dcf(descpath, all = TRUE), + error = identity + ) + + if (inherits(desc, "error")) + return("unknown") + + type <- desc$Type + if (!is.null(type)) + return(tolower(type)) + + package <- desc$Package + if (!is.null(package)) + return("package") + + "unknown" + + } + + renv_bootstrap_user_dir <- function() { + dir <- renv_bootstrap_user_dir_impl() + path.expand(chartr("\\", "/", dir)) + } + + renv_bootstrap_user_dir_impl <- function() { + + # use local override if set + override <- getOption("renv.userdir.override") + if (!is.null(override)) + return(override) + + # use R_user_dir if available + tools <- asNamespace("tools") + if (is.function(tools$R_user_dir)) + return(tools$R_user_dir("renv", "cache")) + + # try using our own backfill for older versions of R + envvars <- c("R_USER_CACHE_DIR", "XDG_CACHE_HOME") + for (envvar in envvars) { + root <- Sys.getenv(envvar, unset = NA) + if (!is.na(root)) + return(file.path(root, "R/renv")) + } + + # use platform-specific default fallbacks + if (Sys.info()[["sysname"]] == "Windows") + file.path(Sys.getenv("LOCALAPPDATA"), "R/cache/R/renv") + else if (Sys.info()[["sysname"]] == "Darwin") + "~/Library/Caches/org.R-project.R/R/renv" + else + "~/.cache/R/renv" + + } + + renv_bootstrap_version_friendly <- function(version, shafmt = NULL, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf(shafmt %||% " [sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = "") + } + + renv_bootstrap_exec <- function(project, libpath, version) { + if (!renv_bootstrap_load(project, libpath, version)) + renv_bootstrap_run(version, libpath) + } + + renv_bootstrap_run <- function(version, libpath) { + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(renv::load(project = getwd())) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + + } + + + renv_bootstrap_in_rstudio <- function() { + commandArgs()[[1]] == "RStudio" + } + + # Used to work around buglet in RStudio if hook uses readline + renv_bootstrap_flush_console <- function() { + tryCatch({ + tools <- as.environment("tools:rstudio") + tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE) + }, error = function(cnd) {}) + } + + renv_json_read <- function(file = NULL, text = NULL) { + + jlerr <- NULL + + # if jsonlite is loaded, use that instead + if ("jsonlite" %in% loadedNamespaces()) { + + json <- catch(renv_json_read_jsonlite(file, text)) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- catch(renv_json_read_default(file, text)) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) + else + stop(json) + + } + + renv_json_read_jsonlite <- function(file = NULL, text = NULL) { + text <- paste(text %||% read(file), collapse = "\n") + jsonlite::fromJSON(txt = text, simplifyVector = FALSE) + } + + renv_json_read_default <- function(file = NULL, text = NULL) { + + # find strings in the JSON + text <- paste(text %||% read(file), collapse = "\n") + pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + locs <- gregexpr(pattern, text, perl = TRUE)[[1]] + + # if any are found, replace them with placeholders + replaced <- text + strings <- character() + replacements <- character() + + if (!identical(c(locs), -1L)) { + + # get the string values + starts <- locs + ends <- locs + attr(locs, "match.length") - 1L + strings <- substring(text, starts, ends) + + # only keep those requiring escaping + strings <- grep("[[\\]{}:]", strings, perl = TRUE, value = TRUE) + + # compute replacements + replacements <- sprintf('"\032%i\032"', seq_along(strings)) + + # replace the strings + mapply(function(string, replacement) { + replaced <<- sub(string, replacement, replaced, fixed = TRUE) + }, strings, replacements) + + } + + # transform the JSON into something the R parser understands + transformed <- replaced + transformed <- gsub("{}", "`names<-`(list(), character())", transformed, fixed = TRUE) + transformed <- gsub("[[{]", "list(", transformed, perl = TRUE) + transformed <- gsub("[]}]", ")", transformed, perl = TRUE) + transformed <- gsub(":", "=", transformed, fixed = TRUE) + text <- paste(transformed, collapse = "\n") + + # parse it + json <- parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] + + # construct map between source strings, replaced strings + map <- as.character(parse(text = strings)) + names(map) <- as.character(parse(text = replacements)) + + # convert to list + map <- as.list(map) + + # remap strings in object + remapped <- renv_json_remap(json, map) + + # evaluate + eval(remapped, envir = baseenv()) + + } + + renv_json_remap <- function(json, map) { + + # fix names + if (!is.null(names(json))) { + lhs <- match(names(json), names(map), nomatch = 0L) + rhs <- match(names(map), names(json), nomatch = 0L) + names(json)[rhs] <- map[lhs] + } + + # fix values + if (is.character(json)) + return(map[[json]] %||% json) + + # handle true, false, null + if (is.name(json)) { + text <- as.character(json) + if (text == "true") + return(TRUE) + else if (text == "false") + return(FALSE) + else if (text == "null") + return(NULL) + } + + # recurse + if (is.recursive(json)) { + for (i in seq_along(json)) { + json[i] <- list(renv_json_remap(json[[i]], map)) + } + } + + json + + } + + # load the renv profile, if any + renv_bootstrap_profile_load(project) + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_platform_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + if (renv_bootstrap_in_rstudio()) { + # RStudio only updates console once .Rprofile is finished, so + # instead run code on sessionInit + setHook("rstudio.sessionInit", function(...) { + renv_bootstrap_exec(project, libpath, version) + renv_bootstrap_flush_console() + }) + } else { + renv_bootstrap_exec(project, libpath, version) + } + + invisible() + +}) diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 0000000..ffdbb32 --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,19 @@ +{ + "bioconductor.version": null, + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "ppm.enabled": null, + "ppm.ignored.urls": [], + "r.version": null, + "snapshot.type": "implicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} From d024eba85da7dd7466f989ab4997d8b388d57670 Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Sun, 17 Sep 2023 19:27:49 -0400 Subject: [PATCH 12/14] add docs --- R/data.R | 4 +- _pkgdown.yml | 4 + docs/404.html | 95 ++++++++--------- docs/LICENSE-text.html | 80 +++++++------- docs/LICENSE.html | 81 +++++++-------- docs/articles/index.html | 73 ++++++------- docs/authors.html | 98 ++++++++---------- docs/index.html | 99 +++++++++--------- docs/pkgdown.js | 172 ++++++++++++++++++++----------- docs/pkgdown.yml | 6 +- docs/reference/example_data.html | 97 +++++++++-------- docs/reference/hello.html | 105 +++++++++---------- docs/reference/index.html | 119 ++++++++++----------- 13 files changed, 509 insertions(+), 524 deletions(-) diff --git a/R/data.R b/R/data.R index 394dcb5..be00067 100644 --- a/R/data.R +++ b/R/data.R @@ -1,11 +1,11 @@ #' Example dataset #' #' A dataset containing a matrix with two columns that were generated -#' with a random normal distribution with a mean of 0 and stdev of 1. +#' with a random normal distribution with a mean of 0 and stdev of 1. #' #' @format A matrix with 100 rows and 2 columns #' @keywords datasets #' @usage data("example_data") #' @examples #' data("example_data") -"example_data" +"example_data" \ No newline at end of file diff --git a/_pkgdown.yml b/_pkgdown.yml index e69de29..d71acfb 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -0,0 +1,4 @@ +url: ~ +template: + bootstrap: 5 + diff --git a/docs/404.html b/docs/404.html index 794dfbf..11eae1d 100644 --- a/docs/404.html +++ b/docs/404.html @@ -4,95 +4,82 @@ - + Page not found (404) • DevelExample - - - + + + - - + - + + Skip to contents -
    -
    -
    - Content not found. Please use links in the navbar. -
    - - - +
    - -
    - diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 4732112..df93d80 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -1,46 +1,44 @@ -License • DevelExampleLicense • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    MIT License
    @@ -66,29 +64,21 @@ 

    License

    SOFTWARE.
    -
    - - +
    -
    - - -
    +
    - diff --git a/docs/LICENSE.html b/docs/LICENSE.html index b60e81a..a6f0433 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -1,78 +1,69 @@ -MIT License • DevelExampleMIT License • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    +

    Copyright (c) 2022 DevelExample authors

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    -
    - - - -
    - +
    -
    +
    - diff --git a/docs/articles/index.html b/docs/articles/index.html index 3905764..2d91a39 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,46 +1,43 @@ -Articles • DevelExampleArticles • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    @@ -50,23 +47,21 @@

    All vignettes

    R Development Example
    -
    -
    +
    -
    +
    - diff --git a/docs/authors.html b/docs/authors.html index 61c8a23..b9a9348 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,93 +1,85 @@ -Authors and Citation • DevelExampleAuthors and Citation • DevelExample + + Skip to contents -
    -
    -
    -
    - + +
    +
    +
    +
    +
    +

    Authors

    • Joshua Campbell. Author, maintainer.

    -
    -
    -

    Citation

    - -
    -
    +
    +

    Citation

    +

    -

    Campbell J (2022). +

    Campbell J (2023). DevelExample: A Basic R Package to Demonstrate a Cycle of Code Development. R package version 0.1.0.

    -
    @Manual{,
    +      
    @Manual{,
       title = {DevelExample: A Basic R Package to Demonstrate a Cycle of Code Development},
       author = {Joshua Campbell},
    -  year = {2022},
    +  year = {2023},
       note = {R package version 0.1.0},
     }
    - -
    - -
    - +
    +
    -
    +
    - diff --git a/docs/index.html b/docs/index.html index 379e1d7..7183e03 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,14 +4,17 @@ - + + A Basic R Package to Demonstrate a Cycle of Code Development • DevelExample - - - + + + - - + - + + Skip to contents + + +
    +
    +
    @@ -73,10 +70,7 @@

    For use with the coding tutorial “Adding code to an R package” which can be found at camplab.net under the “Articles” tab.

    -
    - - -
    - diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 6f0eee4..5fccd9c 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -2,70 +2,30 @@ (function($) { $(function() { - $('.navbar-fixed-top').headroom(); + $('nav.navbar').headroom(); - $('body').css('padding-top', $('.navbar').height() + 10); - $(window).resize(function(){ - $('body').css('padding-top', $('.navbar').height() + 10); + Toc.init({ + $nav: $("#toc"), + $scope: $("main h2, main h3, main h4, main h5, main h6") }); - $('[data-toggle="tooltip"]').tooltip(); - - var cur_path = paths(location.pathname); - var links = $("#navbar ul li a"); - var max_length = -1; - var pos = -1; - for (var i = 0; i < links.length; i++) { - if (links[i].getAttribute("href") === "#") - continue; - // Ignore external links - if (links[i].host !== location.host) - continue; - - var nav_path = paths(links[i].pathname); - - var length = prefix_length(nav_path, cur_path); - if (length > max_length) { - max_length = length; - pos = i; - } - } - - // Add class to parent
  • , and enclosing
  • if in dropdown - if (pos >= 0) { - var menu_anchor = $(links[pos]); - menu_anchor.parent().addClass("active"); - menu_anchor.closest("li.dropdown").addClass("active"); - } - }); - - function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / - - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); - } - - // Returns -1 if not found - function prefix_length(needle, haystack) { - if (needle.length > haystack.length) - return(-1); - - // Special case for length-0 haystack, since for loop won't run - if (haystack.length === 0) { - return(needle.length === 0 ? 0 : -1); + if ($('#toc').length) { + $('body').scrollspy({ + target: '#toc', + offset: $("nav.navbar").outerHeight() + 1 + }); } - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(i); - } + // Activate popovers + $('[data-bs-toggle="popover"]').popover({ + container: 'body', + html: true, + trigger: 'focus', + placement: "top", + sanitize: false, + }); - return(haystack.length); - } + $('[data-bs-toggle="tooltip"]').tooltip(); /* Clipboard --------------------------*/ @@ -78,7 +38,7 @@ if(ClipboardJS.isSupported()) { $(document).ready(function() { - var copyButton = ""; + var copyButton = ""; $("div.sourceCode").addClass("hasCopyButton"); @@ -89,20 +49,108 @@ $('.btn-copy-ex').tooltip({container: 'body'}); // Initialize clipboard: - var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + var clipboard = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); } }); - clipboardBtnCopies.on('success', function(e) { + clipboard.on('success', function(e) { changeTooltipMessage(e.trigger, 'Copied!'); e.clearSelection(); }); - clipboardBtnCopies.on('error', function() { + clipboard.on('error', function() { changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); }); + }); } + + /* Search marking --------------------------*/ + var url = new URL(window.location.href); + var toMark = url.searchParams.get("q"); + var mark = new Mark("main#main"); + if (toMark) { + mark.mark(toMark, { + accuracy: { + value: "complementary", + limiters: [",", ".", ":", "/"], + } + }); + } + + /* Search --------------------------*/ + /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ + // Initialise search index on focus + var fuse; + $("#search-input").focus(async function(e) { + if (fuse) { + return; + } + + $(e.target).addClass("loading"); + var response = await fetch($("#search-input").data("search-index")); + var data = await response.json(); + + var options = { + keys: ["what", "text", "code"], + ignoreLocation: true, + threshold: 0.1, + includeMatches: true, + includeScore: true, + }; + fuse = new Fuse(data, options); + + $(e.target).removeClass("loading"); + }); + + // Use algolia autocomplete + var options = { + autoselect: true, + debug: true, + hint: false, + minLength: 2, + }; + var q; +async function searchFuse(query, callback) { + await fuse; + + var items; + if (!fuse) { + items = []; + } else { + q = query; + var results = fuse.search(query, { limit: 20 }); + items = results + .filter((x) => x.score <= 0.75) + .map((x) => x.item); + if (items.length === 0) { + items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; + } + } + callback(items); +} + $("#search-input").autocomplete(options, [ + { + name: "content", + source: searchFuse, + templates: { + suggestion: (s) => { + if (s.title == s.what) { + return `${s.dir} >
    ${s.title}
    `; + } else if (s.previous_headings == "") { + return `${s.dir} >
    ${s.title}
    > ${s.what}`; + } else { + return `${s.dir} >
    ${s.title}
    > ${s.previous_headings} > ${s.what}`; + } + }, + }, + }, + ]).on('autocomplete:selected', function(event, s) { + window.location.href = s.path + "?q=" + q + "#" + s.id; + }); + }); })(window.jQuery || window.$) + + diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index de87fcb..8d6e697 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,7 +1,7 @@ -pandoc: 2.11.4 -pkgdown: 2.0.3 +pandoc: '2.18' +pkgdown: 2.0.7 pkgdown_sha: ~ articles: DevelExample: DevelExample.html -last_built: 2022-05-20T13:37Z +last_built: 2023-09-04T21:44Z diff --git a/docs/reference/example_data.html b/docs/reference/example_data.html index 07a79fd..fc8dfa1 100644 --- a/docs/reference/example_data.html +++ b/docs/reference/example_data.html @@ -1,90 +1,85 @@ -Example dataset — example_data • DevelExampleExample dataset — example_data • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    -
    +

    A dataset containing a matrix with two columns that were generated with a random normal distribution with a mean of 0 and stdev of 1.

    -
    -
    data("example_data")
    +
    +

    Usage

    +
    data("example_data")
    -
    -

    Format

    +
    +

    Format

    A matrix with 100 rows and 2 columns

    -
    -

    Examples

    -
    data("example_data")
    +    
    +

    Examples

    +
    data("example_data")
     
    -
    - -
    +
    -
    +
    - diff --git a/docs/reference/hello.html b/docs/reference/hello.html index 8a571fe..c474b9a 100644 --- a/docs/reference/hello.html +++ b/docs/reference/hello.html @@ -1,95 +1,92 @@ -Hello world — hello • DevelExampleHello world — hello • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    -
    +

    A simple function to print Hello world

    -
    -
    hello(withExcitement = TRUE)
    +
    +

    Usage

    +
    hello(withExcitement = TRUE)
    -
    -

    Arguments

    +
    +

    Arguments

    withExcitement

    Boolean. If TRUE, then the message will be printed with exlamation points. Default TRUE.

    +
    -
    -

    Value

    -

    A string with the hello world text

    +
    +

    Value

    + + +

    A string with the hello world text

    -
    -

    Examples

    -
    hello(withExcitement = TRUE)
    +    
    +

    Examples

    +
    hello(withExcitement = TRUE)
     #> [1] "Hello world!!!"
     
    -
    - -
    +
    -
    +
    - diff --git a/docs/reference/index.html b/docs/reference/index.html index b8bbf27..a63ffb6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,89 +1,82 @@ -Function reference • DevelExampleFunction reference • DevelExample + + Skip to contents -
    -
    -
    - +
    +
    +
    - - - - - - - - - -
    -

    All functions

    -

    -
    -

    .checkData()

    -

    Validity check

    -

    euclideanDist()

    -

    Euclidean distance

    -

    example_data

    -

    Example dataset

    -

    hello()

    -

    Hello world

    - - -
    +
    +

    All functions

    + + + + +
    + + + +
    + + example_data +
    +
    Example dataset
    +
    + + hello() +
    +
    Hello world
    +
    +
    -
    +
    - From d3f9cd429af6a6d66db2d38a9c112eb599ab3057 Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Thu, 28 Sep 2023 23:30:37 -0400 Subject: [PATCH 13/14] revert back R-CMD change and update version for BioC --- .github/workflows/BioC-check.yaml | 8 ++++---- .github/workflows/R-CMD-check.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/BioC-check.yaml b/.github/workflows/BioC-check.yaml index cd13eff..659030e 100644 --- a/.github/workflows/BioC-check.yaml +++ b/.github/workflows/BioC-check.yaml @@ -25,17 +25,17 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: rcmdcheck, BiocManager diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d9de82f..c57296f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -26,7 +26,7 @@ jobs: - {os: windows-latest, r: 'release'} # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, r: '3.6'} + - {os: windows-latest, r: '4.2.1'} # Use older ubuntu to maximise backward compatibility - {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'} From 8d236e3241feefa39795782482a45a0b22f37f4b Mon Sep 17 00:00:00 2001 From: Nathan Palamuttam Date: Thu, 28 Sep 2023 23:30:58 -0400 Subject: [PATCH 14/14] Revert R-CMD-check --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index c57296f..d9de82f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -26,7 +26,7 @@ jobs: - {os: windows-latest, r: 'release'} # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, r: '4.2.1'} + - {os: windows-latest, r: '3.6'} # Use older ubuntu to maximise backward compatibility - {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}