Skip to content

Commit

Permalink
Refresh package for the New Year (#5)
Browse files Browse the repository at this point in the history
* Bump package
Update roxygen2
Add GitHub URLs

* Start new release notes

* Rename rproj

* Update cran comments

* Fix citation...

* Promote to functions

* Improve documentation
Expand error messages
Update copyright

* Remove TravisCI

* Add GitHub Actions

* Update README page

* No test coverage is needed right now...
  • Loading branch information
coatless authored Jan 1, 2020
1 parent bf8173b commit f0b3875
Show file tree
Hide file tree
Showing 37 changed files with 372 additions and 136 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ README\.md
cran-comments\.md
^LICENSE\.md$
^cran-comments\.md$
^\.github$
66 changes: 66 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on: [push, pull_request]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'release'}
- { os: windows-latest, r: 'devel'}
- { os: macOS-latest, r: 'release'}
- { os: macOS-latest, r: 'devel'}
- { os: ubuntu-16.04, r: '3.5', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- { os: ubuntu-16.04, r: 'release', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}

steps:
- uses: actions/checkout@v1

- uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@master

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "install.packages('remotes')" -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: Rscript -e "install.packages('remotes')" -e "remotes::install_deps(dependencies = TRUE)" -e "remotes::install_cran('rcmdcheck')"

- name: Check
run: Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')"

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

#- name: Test coverage
# if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'release'
# run: |
# Rscript -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
47 changes: 47 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
issue_comment:
types: [created]
name: Commands
jobs:
document:
if: startsWith(github.event.comment.body, '/document')
name: document
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
- name: Install dependencies
run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)'
- name: Document
run: Rscript -e 'roxygen2::roxygenise()'
- name: commit
run: |
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
style:
if: startsWith(github.event.comment.body, '/style')
name: document
runs-on: macOS-latest
steps:
- uses: actions/checkout@master
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
- name: Install dependencies
run: Rscript -e 'install.packages("styler")'
- name: style
run: Rscript -e 'styler::style_pkg()'
- name: commit
run: |
git add \*.R
git commit -m 'style'
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: jjb
Type: Package
Title: Balamuta Miscellaneous
Version: 0.1.0
Version: 0.1.1
Authors@R: c(
person("James", "Balamuta", email = "[email protected]",
role = c("aut", "cre", "cph"),
Expand All @@ -10,7 +10,9 @@ Authors@R: c(
License: GPL (>= 2)
Description: Set of common functions used for manipulating colors,
detecting and interacting with 'RStudio', modeling, formatting, determining
users' operating system, feature scaling, and more!
RoxygenNote: 6.1.0
users' operating system, feature scaling, and more!
URL: https://github.com/coatless/jjb
BugReports: https://github.com/coatless/jjb/issues
RoxygenNote: 7.0.2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export(feature_norm)
export(feature_rescale)
export(feature_standardize)
export(floor_and_cap)
export(get_arch)
export(get_graphic_driver)
export(int_to_hex)
export(is_linux)
export(is_macos)
Expand All @@ -40,6 +38,8 @@ export(require_windows)
export(rgb_to_hex)
export(rmse)
export(shade)
export(system_arch)
export(system_graphic_driver)
export(tint)
export(tr)
export(url_title)
Expand Down
12 changes: 10 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# jjb 0.1.0
## jjb 0.1.1

## Highlights
### Features

### Changes

- Improved error messages with more specific detail.

## jjb 0.1.0

### Features

- RGB Color Modification
- Project circles within a `matrix`
Expand Down
16 changes: 11 additions & 5 deletions R/colors.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2015 - 2018 James Balamuta
# Copyright (C) 2015 - 2020 James Balamuta
#
# This file is part of `jjb` R Package
#
Expand All @@ -20,7 +20,9 @@
#'
#' @param n An `int`
#'
#' @return A `string` of length 2.
#' @return
#' A `string` of length 2.
#'
#' @export
#' @examples
#' int_to_hex(22)
Expand All @@ -45,7 +47,9 @@ int_to_hex = function(n) {
#' @param pound A `bool` that indicates whether a pound sign should be
#' prepended to the hexadecimal.
#'
#' @return A `string` containing the hexadecimal information.
#' @return
#' A `string` containing the hexadecimal information.
#'
#' @export
#' @examples
#' # Hexadecimal with pound sign
Expand All @@ -70,7 +74,8 @@ rgb_to_hex = function(R, G, B, pound = TRUE) {
#' @param rgb_value A `vector` with length \eqn{3 \times 1}{3 x 1}.
#' @param tint_factor A `double` that ranges between \eqn{[0, 1]}.
#'
#' @return A `matrix` with dimensions \eqn{3 \times 1}{3 x 1}.
#' @return
#' A `matrix` with dimensions \eqn{3 \times 1}{3 x 1}.
#'
#' @export
#' @examples
Expand Down Expand Up @@ -99,7 +104,8 @@ tint = function(rgb_value, tint_factor = 0.2) {
#' @param rgb_value A `vector` with length \eqn{3 \times 1}{3 x 1}.
#' @param shade_factor A `double` that ranges between \eqn{[0, 1]}.
#'
#' @return A `matrix` with dimensions \eqn{3 \times 1}{3 x 1}.
#' @return
#' A `matrix` with dimensions \eqn{3 \times 1}{3 x 1}.
#'
#' @export
#' @examples
Expand Down
19 changes: 15 additions & 4 deletions R/feature-scaling.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2015 - 2018 James Balamuta
# Copyright (C) 2015 - 2020 James Balamuta
#
# This file is part of `jjb` R Package
#
Expand All @@ -16,11 +16,17 @@
#' Feature Scaling
#'
#' Scale features in a datasets.
#'
#' @param x Numeric values
#' @param x_min Minimum non-normalized numeric value
#' @param x_max Maximum non-normalized numeric value
#' @return A `numeric` vector.
#' @author James Balamuta
#'
#' @return
#' A `numeric` vector.
#'
#' @author
#' James Balamuta
#'
#' @details
#' The following functions provide a means to either scale features or
#' to descale the features and return them to normal. These functions
Expand Down Expand Up @@ -93,15 +99,17 @@ feature_rescale = function(x, x_min = NULL, x_max = NULL) {
}

#' @param x_rescaled Rescaled values of `x`.
#'
#' @rdname feature_scaling
#' @export
feature_derescale = function(x_rescaled, x_min, x_max){
stopifnot( all(is.numeric(x_rescaled)) & is.numeric(x_min) & is.numeric(x_max) )
x_rescaled * (x_max - x_min) + x_min
}

#' @rdname feature_scaling
#' @param x_norm Euclidean norm of x
#'
#' @rdname feature_scaling
#' @export
feature_norm = function(x, x_norm = NULL) {

Expand All @@ -115,6 +123,7 @@ feature_norm = function(x, x_norm = NULL) {
}

#' @param x_norm_std Euclidean vector of normalized `x` values.
#'
#' @rdname feature_scaling
#' @export
#' @examples
Expand All @@ -139,6 +148,7 @@ feature_denorm = function(x_norm_std, x_norm = NULL) {

#' @param x_mean Mean of `x` values
#' @param x_sd Standard Deviation of `x` values
#'
#' @rdname feature_scaling
#' @export
#' @importFrom stats sd
Expand All @@ -154,6 +164,7 @@ feature_standardize = function(x, x_mean = NULL, x_sd = NULL) {
}

#' @param x_std Z-transformed `x` values
#'
#' @rdname feature_scaling
#' @export
#' @examples
Expand Down
22 changes: 17 additions & 5 deletions R/formatting.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2015 - 2018 James Balamuta
# Copyright (C) 2015 - 2020 James Balamuta
#
# This file is part of `jjb` R Package
#
Expand All @@ -16,10 +16,16 @@
#' Pad Numeric Numbers
#'
#' Add zeros before start of the number
#'
#' @param x A `vector`
#' @return A `character vector` that is padded to the length of the
#'
#' @return
#' A `character vector` that is padded to the length of the
#' maximum entry.
#' @author James Balamuta
#'
#' @author
#' James Balamuta
#'
#' @export
#' @examples
#' # Padding applied
Expand All @@ -39,9 +45,15 @@ pad_number = function(x){
#' Create a "safe" url title
#'
#' Takes a string, forces characters to lower case, then removes punctuation and switch spaces to - instead of _
#'
#' @param st A \code{string} that needs to be a title in a url
#' @return A \code{string} with the aforementioned modifications.
#' @author James Balamuta
#'
#' @return
#' A \code{string} with the aforementioned modifications.
#'
#' @author
#' James Balamuta
#'
#' @export
#' @examples
#' url_title("My Name is Jaime!")
Expand Down
12 changes: 8 additions & 4 deletions R/ints.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2015 - 2018 James Balamuta
# Copyright (C) 2015 - 2020 James Balamuta
#
# This file is part of `jjb` R Package
#
Expand All @@ -19,9 +19,11 @@
#'
#' @param x A `numeric` value to check to see if it is an `integer`.
#'
#' @return A `boolean` value indicating whether the value is an `integer` or not.
#' @return
#' A `boolean` value indicating whether the value is an `integer` or not.
#'
#' @author James J Balamuta
#' @author
#' James Balamuta
#'
#' @export
#' @examples
Expand All @@ -30,4 +32,6 @@
#' is_whole(c(1,2,3))
#' is_whole(c(.4,.5,.6))
#' is_whole(c(7,.8,9))
is_whole = function(x) { is.numeric(x) && all(floor(x) == x) }
is_whole = function(x) {
is.numeric(x) && all(floor(x) == x)
}
Loading

0 comments on commit f0b3875

Please sign in to comment.