Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^LICENSE\.md$
^.*\.Rproj$
^\.Rproj\.user$
Expand All @@ -6,3 +8,5 @@
^docs$
^pkgdown$
^\.lintr$
^data-raw$
^renv.*
22 changes: 11 additions & 11 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
- {os: windows-latest, r: '3.6'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-18.04, r: 'oldrel-3'}
- {os: ubuntu-18.04, r: 'oldrel-4'}
- {os: ubuntu-20.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-20.04, r: 'release'}
- {os: ubuntu-20.04, r: 'oldrel-1'}
- {os: ubuntu-20.04, r: 'oldrel-2'}
- {os: ubuntu-20.04, r: 'oldrel-3'}
- {os: ubuntu-20.04, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -43,19 +43,19 @@ jobs:
steps:
- uses: actions/checkout@v2

- 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
extra-packages: rcmdcheck, knitr

- uses: r-lib/actions/check-r-package@v1
- uses: r-lib/actions/check-r-package@v2

- name: Show testthat output
if: always()
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: lintr

- name: Lint
run: lintr::lint_package()
run: lintr::lint_package(linters = lintr::linters_with_defaults(object_name_linter = lintr::object_name_linter("camelCase")))
shell: Rscript {0}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ vignettes/*.pdf
.Renviron
inst/doc
docs

.Rprofile
renv/
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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.1
Authors@R:
person(given = "Joshua",
family = "Campbell",
Expand All @@ -15,10 +15,12 @@ Encoding: UTF-8
biocViews: Clustering
LazyData: false
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
Depends:
R (>= 2.10)
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(euclideanDist)
export(hello)
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes in Version 0.0.1 (2022-05-08)
# Changes in Version 0.1.1 (2023-04-09)
* Created package
* Added Hello World function
* Added documentation, unit tests, and vignettes
* Added a `NEWS.md` file to track changes to the package.
* Added function to calculate euclidean dist
9 changes: 9 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#' 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"
30 changes: 30 additions & 0 deletions R/distance.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' @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
.check_data(a)
.check_data(b)

# Perform calculation
res <- sqrt(sum((a-b)^2))
return(res)
}

.check_data <- function(input) {
if (any(is.na(input))) {
stop("'input' must not contain NAs")
}
}
3 changes: 2 additions & 1 deletion R/functions.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#' @title Hello world
#' @description A simple function to print Hello world
#'
Expand All @@ -14,4 +15,4 @@ hello <- function(withExcitement = TRUE) {
str <- "Hello world."
}
return(str)
}
}
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: ~
template:
bootstrap: 5

6 changes: 6 additions & 0 deletions data-raw/example_data.R
Original file line number Diff line number Diff line change
@@ -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)
Binary file added data/example_data.rda
Binary file not shown.
26 changes: 26 additions & 0 deletions man/euclideanDist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/example_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading