Skip to content

Commit

Permalink
Merge pull request #14 from Ulthran/setup-CI
Browse files Browse the repository at this point in the history
Setup CI
  • Loading branch information
kylebittinger authored May 24, 2024
2 parents a5ad939 + 1350864 commit 1c40d52
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 370 deletions.
15 changes: 9 additions & 6 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^\.travis\.yml$
^cran-comments\.md$
^CRAN-RELEASE$
^renv$
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^\.travis\.yml$
^cran-comments\.md$
^CRAN-RELEASE$
^\.github$
5 changes: 3 additions & 2 deletions DESCRIPTION
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Description: Functions to re-arrange, extract, and work with distances.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Suggests:
testthat,
tibble,
tidyr (>= 1.0.0),
rlang,
future.apply
future.apply,
ggplot2
4 changes: 4 additions & 0 deletions NAMESPACE
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export(dist_subset)
export(dist_to_centroids)
export(pivot_to_matrix)
export(pivot_to_numeric_matrix)
importFrom(rlang,as_name)
importFrom(rlang,ensym)
importFrom(tibble,column_to_rownames)
importFrom(tidyr,pivot_wider)
13 changes: 1 addition & 12 deletions R/dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,7 @@ dist_get <- function (d, idx1, idx2) {
#' dist_subset(dm4, c("A", "B", "C"))
#' dist_subset(dm4, c("D", "C", "B", "A"))
dist_subset <- function (d, idx) {
m <- as.matrix(d)
l <- length(colnames(m))

if(is.logical(idx) & length(idx) > l) {
message("Logical vector too long for given distance matrix")
} else if (is.numeric(idx) & (any(idx < 0) | any(idx >= l + 1))) {
message(paste("Numeric vector inputs out of bounds: ", paste(idx[(idx < 0) | (idx >= l)], collapse = ", ")))
} else if (any(!(idx %in% colnames(m)))) {
message(paste("Character vector inputs don't match matrix column names: ", paste(idx[!(idx %in% colnames(m))], collapse = ", ")))
}

stats::as.dist(m[idx, idx])
stats::as.dist(as.matrix(d)[idx, idx])
}

#' Create a data frame of distances between groups of items.
Expand Down
4 changes: 4 additions & 0 deletions R/long_format.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#' @param obs_col,feature_col,value_col The same as \code{rows_from},
#' \code{cols_from}, and \code{values_from}, respectively.
#'
#' @importFrom tidyr pivot_wider
#' @importFrom tibble column_to_rownames
#' @importFrom rlang as_name ensym
#'
#' @details
#' The parameters \code{rows_from}, \code{cols_from}, and \code{values_from}
#' should be provided as bare column names.
Expand Down
9 changes: 6 additions & 3 deletions README.Rmd
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- README.md is generated from README.Rmd. Please edit README.Rmd -->

```{r, echo = FALSE}
knitr::opts_chunk$set(
Expand All @@ -19,7 +19,10 @@ set.seed(0)

This package provides useful functions for distance matrix objects in R.

[![Travis-CI Build Status](https://travis-ci.org/kylebittinger/usedist.svg?branch=master)](https://travis-ci.org/kylebittinger/usedist)
<!-- Badges start -->
[![R-CMD-check](https://github.com/kylebittinger/usedist/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/kylebittinger/usedist/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/kylebittinger/usedist/branch/master/graph/badge.svg)](https://app.codecov.io/gh/kylebittinger/usedist?branch=master)
<!-- Badges end -->

## Installation

Expand Down Expand Up @@ -235,4 +238,4 @@ parallel to save time.
library(future.apply)
future::plan(future::multisession)
dist_make(data_matrix, rms_distance)
```
```
Loading

0 comments on commit 1c40d52

Please sign in to comment.