diff --git a/.Rbuildignore b/.Rbuildignore index bfc05b1..b3b405d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ README\.md cran-comments\.md ^LICENSE\.md$ ^cran-comments\.md$ +^\.github$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..33a7f53 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -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}}")' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..2b2eebc --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -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 }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 194b30b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: r -sudo: false -cache: packages \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 760af81..43c794d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "balamut2@illinois.edu", role = c("aut", "cre", "cph"), @@ -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) diff --git a/NAMESPACE b/NAMESPACE index 052ab50..a7c6634 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) diff --git a/NEWS.md b/NEWS.md index 4c9716e..4fac899 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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` diff --git a/R/colors.R b/R/colors.R index 7e9f770..d1c56fd 100644 --- a/R/colors.R +++ b/R/colors.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/R/feature-scaling.R b/R/feature-scaling.R index 8250d6b..a059afd 100644 --- a/R/feature-scaling.R +++ b/R/feature-scaling.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -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 @@ -93,6 +99,7 @@ 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){ @@ -100,8 +107,9 @@ feature_derescale = function(x_rescaled, x_min, 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) { @@ -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 @@ -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 @@ -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 diff --git a/R/formatting.R b/R/formatting.R index 6ab96be..4560601 100644 --- a/R/formatting.R +++ b/R/formatting.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -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 @@ -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!") diff --git a/R/ints.R b/R/ints.R index 74b6b29..6696957 100644 --- a/R/ints.R +++ b/R/ints.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -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 @@ -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) +} diff --git a/R/is_os.R b/R/is_os.R index 741a0da..6a08e2f 100644 --- a/R/is_os.R +++ b/R/is_os.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -14,55 +14,62 @@ # If not, see . # Store system name -sys.name = Sys.info()[['sysname']] - -# Figure out OS type -sys.arch = if( Sys.info()['machine'] == "x86_64" ) { "x64" } else { "x32" } - +system_name = function() { + Sys.info()[['sysname']] +} #' Check for an Operating System #' #' Performs a check to determine the OS -#' @return Either \code{TRUE} or \code{FALSE} +#' +#' @return +#' Either \code{TRUE} or \code{FALSE} +#' +#' @author +#' James Joseph Balamuta +#' #' @rdname is_os #' @export -#' @author James Joseph Balamuta is_windows = function(){ - sys.name == "Windows" + system_name() == "Windows" } #' @rdname is_os #' @export is_macos = function(){ - sys.name == "Darwin" + system_name() == "Darwin" } #' @rdname is_os #' @export is_linux = function(){ - sys.name == "Linux" + system_name() == "Linux" } #' @rdname is_os #' @export is_sun = function(){ - sys.name == "SunOS" + system_name() == "SunOS" } #' Require a Specific Operating System #' #' Mandates the presence of an operating system +#' #' @details #' If any of these functions are called #' on the wrong operating system. A stop error #' is triggered and the function will fail. +#' +#' @author +#' James Joseph Balamuta +#' #' @rdname require_os #' @export -#' @author James Joseph Balamuta require_linux = function(){ if(!is_linux()){ - stop("This function is only supported on Linux!") + stop("This function is only supported on Linux!", call. = FALSE) } } @@ -70,7 +77,7 @@ require_linux = function(){ #' @export require_windows = function(){ if(!is_windows()){ - stop("This function is only supported on Windows!") + stop("This function is only supported on Windows!", call. = FALSE) } } @@ -78,7 +85,7 @@ require_windows = function(){ #' @export require_macos = function(){ if(!is_macos()){ - stop("This function is only supported on MacOS!") + stop("This function is only supported on MacOS!", call. = FALSE) } } @@ -86,7 +93,7 @@ require_macos = function(){ #' @export require_sun = function(){ if(!is_sun()){ - stop("This function is only supported on Solaris!") + stop("This function is only supported on Solaris!", call. = FALSE) } } @@ -94,6 +101,9 @@ require_sun = function(){ #' #' @return Either "x64" or "x32" #' @export -get_arch = function(){ - sys.arch +system_arch = function() { + if( Sys.info()['machine'] == "x86_64" ) + "x64" + else + "x32" } diff --git a/R/jjb-package.R b/R/jjb-package.R index 7d4ccbf..cde7c04 100644 --- a/R/jjb-package.R +++ b/R/jjb-package.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # diff --git a/R/mat.R b/R/mat.R index fd20de9..c7cc748 100644 --- a/R/mat.R +++ b/R/mat.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -17,18 +17,26 @@ #' #' Calculates and returns the trace of a square matrix. #' -#' @param x A \code{matrix} that is square e.g. \eqn{N \times N}{N x N} +#' @param x A `matrix` that is square e.g. \eqn{N \times N}{N x N} #' -#' @return A \code{matrix} with circles imprinted within its dimensions. +#' @return +#' A `matrix` with circles imprinted within its dimensions. +#' +#' @author +#' James Balamuta #' -#' @author James J Balamuta #' @export #' @examples #' # I_2 matrix #' tr(diag(2)) tr = function(x){ - if(!is.matrix(x)){stop("x is not a matrix.")} - if(nrow(x) != ncol(x)){stop("Trace is not defined on a non-square matrix.")} + if (!is.matrix(x)) { + stop(sprintf("`x` is not a matrix. `x` is %s", class(x)), call. = FALSE) + } + if (nrow(x) != ncol(x)) { + stop(sprintf("`x` must be a square matrix. `x` is %i x %i", nrow(x), ncol(x)), + call. = FALSE) + } sum(diag(x)) } @@ -44,12 +52,14 @@ tr = function(x){ #' @param f A `vector` of values that specify what the inside of the #' circles should be. #' -#' @return A `matrix` with circles imprinted within its dimensions. +#' @return +#' A `matrix` with circles imprinted within its dimensions. +#' +#' @author +#' James Balamuta #' -#' @author James J Balamuta #' @export #' @examples -#' #' # Generate a basic circle matrix #' circle_matrix(10, 10, 3, 4, 2) #' diff --git a/R/misc.R b/R/misc.R index ae65ee3..b07a4ab 100644 --- a/R/misc.R +++ b/R/misc.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -18,7 +18,8 @@ #' #' Provides the default operating system graphics utility #' -#' @return A `string` that is either: +#' @return +#' A `string` that is either: #' #' - `"quartz"`: if on MacOS #' - `"windows"`: if on Windows @@ -26,13 +27,15 @@ #' #' @seealso [is_rstudio] #' -#' @author James Joseph Balamuta +#' @author +#' James Balamuta +#' #' @export #' @examples #' # Returns a string depending on test platform -#' get_graphic_driver() -get_graphic_driver = function(){ - switch(tolower(sys.name), +#' system_graphic_driver() +system_graphic_driver = function(){ + switch(tolower(system_name()), "darwin" = "quartz", "linux" = "x11", "windows" = "windows", @@ -46,7 +49,10 @@ get_graphic_driver = function(){ #' #' @return #' A `logical` value that indicates whether R is open in RStudio. -#' @author JJB +#' +#' @author +#' James Balamuta +#' #' @export #' @examples #' is_rstudio() @@ -61,6 +67,11 @@ is_rstudio = function(){ #' #' @param ext A `logical` indicating whether the graph should be done externally #' or internally in RStudio. +#' +#' @return +#' There is no return value. Instead, once finished, the function will cause a +#' side effect to occur. See details for more. +#' #' @details #' Depending on the operating system, the default drivers attempted to be #' used are: @@ -75,7 +86,9 @@ is_rstudio = function(){ #' Also, the active graphing environment will be killed. As a result, any graphs #' that are open will be deleted. You will have to regraph them. #' -#' @author JJB +#' @author +#' James Balamuta +#' #' @export #' @examples #' \donttest{ @@ -85,11 +98,10 @@ is_rstudio = function(){ #' # Turn off external graphs #' external_graphs(FALSE) #' } -external_graphs = function(ext = TRUE){ - if( is_rstudio() ){ - if(isTRUE(ext)){ - a = get_graphic_driver() - options("device" = a) +external_graphs = function(ext = TRUE) { + if (is_rstudio()) { + if (isTRUE(ext)) { + options("device" = system_graphic_driver()) } else{ options("device" = "RStudioGD") } diff --git a/R/modeling.R b/R/modeling.R index 4377d2b..997fabc 100644 --- a/R/modeling.R +++ b/R/modeling.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -21,7 +21,8 @@ #' @param y A `vector` of the true \eqn{y} values #' @param yhat A `vector` of predicted \eqn{\hat{y}}{y hat} values. #' -#' @return The accuracy of the classification in `numeric` form. +#' @return +#' The accuracy of the classification in `numeric` form. #' #' @export #' @examples @@ -48,7 +49,8 @@ acc = function(y, yhat) { #' #' @inheritParams acc #' -#' @return The MSE in `numeric` form. +#' @return +#' The MSE in `numeric` form. #' #' @details #' The equation for MSE is: @@ -79,7 +81,8 @@ mse = function(y, yhat) { #' #' @inheritParams acc #' -#' @return The RMSE in `numeric` form +#' @return +#' The RMSE in `numeric` form #' #' @details #' The formula for RMSE is: @@ -114,7 +117,8 @@ rmse = function(y, yhat) { #' @param probs A `vector` containing two values between 0 and 1, with the #' first being less than the second. #' -#' @return A `vector` with the values floored and capped. +#' @return +#' A `vector` with the values floored and capped. #' #' @export #' @examples @@ -162,7 +166,8 @@ floor_and_cap = function(x, probs = c(.025, 0.975)) { #' @param cast A `string vector` containing either: #' `"n"` (numeric), `"c"` (character), or `"f"` (factor). #' -#' @return A `data.frame` with converted column types. +#' @return +#' A `data.frame` with converted column types. #' #' @export #' @examples diff --git a/R/order.R b/R/order.R index da2163c..1da609b 100644 --- a/R/order.R +++ b/R/order.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -37,7 +37,8 @@ retrieve_sorted_elements = function(x, n = 1, find_max = TRUE) { #' @param x Data vector #' @param n Number of observations to select #' -#' @return A `vector` containing the maximum/minimum of \eqn{n} elements. +#' @return +#' A `vector` containing the maximum/minimum of \eqn{n} elements. #' #' @details #' The underlying function sorts the data using [base::sort()] and then extracts diff --git a/R/strs.R b/R/strs.R index 0f56c8e..47b3c35 100644 --- a/R/strs.R +++ b/R/strs.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -20,9 +20,12 @@ #' @param x A `character vector` to extract position from. #' @param index An `integer` between 1 and length _n_. #' -#' @return A `character vector` of length `index`. +#' @return +#' A `character vector` of length `index`. +#' +#' @author +#' James J Balamuta #' -#' @author James J Balamuta #' @export #' @examples #' # Example string diff --git a/R/utilities.R b/R/utilities.R index 29a5266..e90d83d 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -18,9 +18,16 @@ #' #' Create a directory using either a relative path or an absolute path. #' -#' @param dir A \code{string} indicating the directory to make. -#' @param r A \code{boolean} that indicates whether the directories should be made recursively -#' @return New directory on file system +#' @param dir A `string` indicating the directory to make. +#' @param r A `boolean` that indicates whether the directories should be +#' made recursively +#' +#' @return +#' New directory on file system +#' +#' @author +#' James Balamuta +#' #' @export #' @examples #' \donttest{ @@ -46,16 +53,25 @@ mkdir = function(dir, r = TRUE) { #' Lag Vector Values #' #' Provides a lagging mechanism for vector data. -#' @param x A \code{vec} of data. -#' @param lag An \code{integer}. -#' @return A \code{vector} with lagged values / NAs. +#' +#' @param x A `vec` of data. +#' @param lag An `integer` value. +#' +#' @return +#' A `vector` with lagged values and `NA`s. +#' +#' @author +#' James Balamuta +#' #' @export #' @examples #' x = rnorm(10) #' #' lagged(x, 2) -lagged = function(x, lag = 1){ - if(lag == 0){return(x)} +lagged = function(x, lag = 1) { + if (lag == 0) { + return(x) + } x[1:lag] = NA return(x) diff --git a/R/weather.R b/R/weather.R index 23e50c2..8a4efed 100644 --- a/R/weather.R +++ b/R/weather.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 - 2018 James Balamuta +# Copyright (C) 2015 - 2020 James Balamuta # # This file is part of `jjb` R Package # @@ -20,7 +20,10 @@ #' Converts temperature recorded in Celsius to Fahrenheit. #' #' @param t_celsius Temperature recorded in Celsius. -#' @return A `numeric` vector. +#' +#' @return +#' A `numeric` vector. +#' #' @export #' @examples #' @@ -38,7 +41,10 @@ celsius_to_fahrenheit = function(t_celsius) { #' Converts temperature recorded in Fahrenheit to Celsius. #' #' @param t_fahrenheit Temperature recorded in Fahrenheit. -#' @return A `numeric` vector. +#' +#' @return +#' A `numeric` vector. +#' #' @export #' #' @examples @@ -58,7 +64,10 @@ fahrenheit_to_celsius = function(t_fahrenheit) { #' Converts temperature recorded in Kelvin to Celsius. #' #' @param t_kelvin Temperature recorded in Kelvin. -#' @return A `numeric` vector. +#' +#' @return +#' A `numeric` vector. +#' #' @export #' #' @examples @@ -77,7 +86,9 @@ kelvin_to_celsius = function(t_kelvin) { #' #' @param t_celsius Temperature recorded in Celsius. #' -#' @return A `numeric` vector. +#' @return +#' A `numeric` vector. +#' #' @export #' @examples #' celsius_to_kelvin(92) @@ -96,7 +107,9 @@ celsius_to_kelvin = function(t_celsius) { #' #' @param t_fahrenheit Temperature recorded in Fahrenheit. #' -#' @return A `numeric` vector. +#' @return +#' A `numeric` vector. +#' #' @export #' @examples #' fahrenheit_to_kelvin(92) @@ -114,7 +127,9 @@ fahrenheit_to_kelvin = function(t_fahrenheit) { #' #' @param t_kelvin Temperature recorded in Kelvin. #' -#' @return A `numeric` vector. +#' @return +#' A `numeric` vector. +#' #' @export #' @examples #' kelvin_to_fahrenheit(92) diff --git a/README.md b/README.md index 98bdff5..1e363e5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ ## `jjb` -[![Linux Build Status](https://travis-ci.org/coatless/jjb.svg?branch=master)](https://travis-ci.org/coatless/jjb) + +[![R build +status](https://github.com/coatless/jjb/workflows/R-CMD-check/badge.svg)](https://github.com/coatless/jjb/actions) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/jjb)](http://www.r-pkg.org/pkg/jjb) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/jjb)](http://cran.r-project.org/package=jjb) + The goal of `jjb` is to provide tools frequently used in analyses. As a result, the package contains a large amount of functions I use in day to day diff --git a/cran-comments.md b/cran-comments.md index bc0dadb..b0cca38 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,7 @@ ## Test environments -* local OS X install, R 3.5.1 -* ubuntu 14.04 (on travis-ci), R 3.5.1 +* local OS X install, R 3.6.2 +* ubuntu 14.04 (on travis-ci), R 3.6.2 * win-builder (devel and release) ## R CMD check results @@ -10,17 +10,6 @@ * This is a new release. -## Feedback - -The previously submitted version of this package had a CRAN maintainer -request that instances of `\dontrun{}` were substituted with `\donttest{}`. -This has been done. - -Regarding feedback about the missing author, the code snippet was taken from -an answer on StackOverflow. As the IP rights were not explicit, the routine has -been removed from the package. Thus, we've opted to avoid adding another author -or contributor to the package via `Authors@R`. - ## Reverse dependencies This is a new release, so there are no reverse dependencies. diff --git a/inst/CITATION b/inst/CITATION index 2ded642..986a45e 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,15 +1,15 @@ year <- sub("-.*", "", meta$Date) note <- sprintf("R package (version %s)", meta$Version) -citHeader("To cite balamuta in publications use:") +citHeader("To cite `jjb` in publications use:") citEntry(entry = "Misc", title = "Balamuta Miscellaneous", author = person("James", "Balamuta"), year = year, howpublished = note, - note = "GitHub repository: \\url{https://github.com/coatless/bmisc}", + note = "GitHub repository: \\url{https://github.com/coatless/jjb}", url = "https://cran.r-project.org/package=jjb", textVersion = paste0("James Balamuta (", year,"). Balamuta Miscellaneous. ", - note, ". GitHub repository: https://github.com/coatless/bmisc.") + note, ". GitHub repository: https://github.com/coatless/jjb.") ) diff --git a/bmisc.Rproj b/jjb.Rproj similarity index 100% rename from bmisc.Rproj rename to jjb.Rproj diff --git a/man/char_at.Rd b/man/char_at.Rd index 2820a59..e8e103d 100644 --- a/man/char_at.Rd +++ b/man/char_at.Rd @@ -7,12 +7,12 @@ char_at(x, index) } \arguments{ -\item{x}{A \code{character vector} to extract position from.} +\item{x}{A \verb{character vector} to extract position from.} \item{index}{An \code{integer} between 1 and length \emph{n}.} } \value{ -A \code{character vector} of length \code{index}. +A \verb{character vector} of length \code{index}. } \description{ Returns the character at location \emph{i} inside the string. diff --git a/man/circle_matrix.Rd b/man/circle_matrix.Rd index fca39e3..e46fb36 100644 --- a/man/circle_matrix.Rd +++ b/man/circle_matrix.Rd @@ -27,7 +27,6 @@ A \code{matrix} with circles imprinted within its dimensions. Takes a default matrix and embeds circles within the matrix. } \examples{ - # Generate a basic circle matrix circle_matrix(10, 10, 3, 4, 2) @@ -38,5 +37,5 @@ circle_matrix(10, 20, c(3,6), c(4,6), c(2,2)) circle_matrix(10, 20, c(3,6), c(4,6), c(2,2), f = c(1,2)) } \author{ -James J Balamuta +James Balamuta } diff --git a/man/convert_cols.Rd b/man/convert_cols.Rd index aa7d03a..ea5e8d3 100644 --- a/man/convert_cols.Rd +++ b/man/convert_cols.Rd @@ -12,7 +12,7 @@ convert_cols(d, cast) \arguments{ \item{d}{A \code{data.frame} that needs to have specific columns converted.} -\item{cast}{A \code{string vector} containing either: +\item{cast}{A \verb{string vector} containing either: \code{"n"} (numeric), \code{"c"} (character), or \code{"f"} (factor).} } \value{ diff --git a/man/external_graphs.Rd b/man/external_graphs.Rd index 2f1bb92..c23ccda 100644 --- a/man/external_graphs.Rd +++ b/man/external_graphs.Rd @@ -10,6 +10,10 @@ external_graphs(ext = TRUE) \item{ext}{A \code{logical} indicating whether the graph should be done externally or internally in RStudio.} } +\value{ +There is no return value. Instead, once finished, the function will cause a +side effect to occur. See details for more. +} \description{ Checks to see if the user is in RStudio. If so, then it changes the device to a popup window. @@ -39,5 +43,5 @@ external_graphs(FALSE) } } \author{ -JJB +James Balamuta } diff --git a/man/is_rstudio.Rd b/man/is_rstudio.Rd index a0a049b..d6ae7d8 100644 --- a/man/is_rstudio.Rd +++ b/man/is_rstudio.Rd @@ -16,5 +16,5 @@ Detects whether R is open in RStudio. is_rstudio() } \author{ -JJB +James Balamuta } diff --git a/man/is_whole.Rd b/man/is_whole.Rd index 77ea257..78a653d 100644 --- a/man/is_whole.Rd +++ b/man/is_whole.Rd @@ -23,5 +23,5 @@ is_whole(c(.4,.5,.6)) is_whole(c(7,.8,9)) } \author{ -James J Balamuta +James Balamuta } diff --git a/man/jjb-package.Rd b/man/jjb-package.Rd index 71ea730..994e30b 100644 --- a/man/jjb-package.Rd +++ b/man/jjb-package.Rd @@ -9,8 +9,16 @@ Set of common functions used for manipulating colors, detecting and interacting with 'RStudio', modeling, formatting, determining users' operating system, feature scaling, and more! +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/coatless/jjb} + \item Report bugs at \url{https://github.com/coatless/jjb/issues} +} + } \author{ -\strong{Maintainer}: James Balamuta \email{balamut2@illinois.edu} (0000-0003-2826-8458) [copyright holder] +\strong{Maintainer}: James Balamuta \email{balamut2@illinois.edu} (\href{https://orcid.org/0000-0003-2826-8458}{ORCID}) [copyright holder] } diff --git a/man/lagged.Rd b/man/lagged.Rd index 98825e9..173e145 100644 --- a/man/lagged.Rd +++ b/man/lagged.Rd @@ -9,10 +9,10 @@ lagged(x, lag = 1) \arguments{ \item{x}{A \code{vec} of data.} -\item{lag}{An \code{integer}.} +\item{lag}{An \code{integer} value.} } \value{ -A \code{vector} with lagged values / NAs. +A \code{vector} with lagged values and \code{NA}s. } \description{ Provides a lagging mechanism for vector data. @@ -22,3 +22,6 @@ x = rnorm(10) lagged(x, 2) } +\author{ +James Balamuta +} diff --git a/man/mkdir.Rd b/man/mkdir.Rd index b763257..6f8a5e1 100644 --- a/man/mkdir.Rd +++ b/man/mkdir.Rd @@ -9,7 +9,8 @@ mkdir(dir, r = TRUE) \arguments{ \item{dir}{A \code{string} indicating the directory to make.} -\item{r}{A \code{boolean} that indicates whether the directories should be made recursively} +\item{r}{A \code{boolean} that indicates whether the directories should be +made recursively} } \value{ New directory on file system @@ -27,3 +28,6 @@ mkdir("toad") mkdir("C:/path/to/dir/toad") } } +\author{ +James Balamuta +} diff --git a/man/pad_number.Rd b/man/pad_number.Rd index 30f5378..bca55e2 100644 --- a/man/pad_number.Rd +++ b/man/pad_number.Rd @@ -10,7 +10,7 @@ pad_number(x) \item{x}{A \code{vector}} } \value{ -A \code{character vector} that is padded to the length of the +A \verb{character vector} that is padded to the length of the maximum entry. } \description{ diff --git a/man/get_arch.Rd b/man/system_arch.Rd similarity index 78% rename from man/get_arch.Rd rename to man/system_arch.Rd index 723379a..a0c6e8c 100644 --- a/man/get_arch.Rd +++ b/man/system_arch.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/is_os.R -\name{get_arch} -\alias{get_arch} +\name{system_arch} +\alias{system_arch} \title{System Architecture} \usage{ -get_arch() +system_arch() } \value{ Either "x64" or "x32" diff --git a/man/get_graphic_driver.Rd b/man/system_graphic_driver.Rd similarity index 80% rename from man/get_graphic_driver.Rd rename to man/system_graphic_driver.Rd index 0228120..eb18ecb 100644 --- a/man/get_graphic_driver.Rd +++ b/man/system_graphic_driver.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/misc.R -\name{get_graphic_driver} -\alias{get_graphic_driver} +\name{system_graphic_driver} +\alias{system_graphic_driver} \title{Natural Graphics Driver for Operating System} \usage{ -get_graphic_driver() +system_graphic_driver() } \value{ A \code{string} that is either: @@ -19,11 +19,11 @@ Provides the default operating system graphics utility } \examples{ # Returns a string depending on test platform -get_graphic_driver() +system_graphic_driver() } \seealso{ \link{is_rstudio} } \author{ -James Joseph Balamuta +James Balamuta } diff --git a/man/tr.Rd b/man/tr.Rd index 2aa59c0..b806939 100644 --- a/man/tr.Rd +++ b/man/tr.Rd @@ -20,5 +20,5 @@ Calculates and returns the trace of a square matrix. tr(diag(2)) } \author{ -James J Balamuta +James Balamuta }