diff --git a/.Rbuildignore b/.Rbuildignore index 6c2c110..252df49 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,5 @@ ^LICENSE.md$ ^CONTRIBUTING.md$ ^CRAN-RELEASE$ +^packrat/ +^\.Rprofile$ diff --git a/.gitignore b/.gitignore index 09a72cb..e6df00c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .Rhistory .RData inst/doc +packrat/lib*/ +packrat +.Rprofile diff --git a/DESCRIPTION b/DESCRIPTION index 365d05f..5ddb495 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,4 +46,4 @@ Suggests: VignetteBuilder: knitr URL: https://github.com/cytomining/cytominer BugReports: https://github.com/cytomining/cytominer/issues -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.0 diff --git a/R/drop_na_rows.R b/R/drop_na_rows.R index 0856f20..6b1804d 100644 --- a/R/drop_na_rows.R +++ b/R/drop_na_rows.R @@ -1,12 +1,12 @@ -utils::globalVariables(c("key", "value", "rowname_temp", "coalesce")) -#' Drop rows that are \code{NA} in all variables. +utils::globalVariables(c("key", "value", "rowname_temp", "rowid", "coalesce")) +#' Drop rows that are \code{NA} in all specified variables. #' -#' \code{drop_na_rows} drops rows that are \code{NA} in all variables. +#' \code{drop_na_rows} drops rows that are \code{NA} in all specified variables. #' #' @param population tbl with grouping (metadata) and observation variables. #' @param variables character vector specifying observation variables. #' -#' @return \code{population} without rows that have \code{NA} in all variables. +#' @return \code{population} without rows that have \code{NA} in all specified variables. #' #' @examples #' population <- tibble::tibble( @@ -26,11 +26,12 @@ utils::globalVariables(c("key", "value", "rowname_temp", "coalesce")) drop_na_rows <- function(population, variables) { if (is.data.frame(population)) { population %>% - tibble::rownames_to_column(., var = "rowname_temp") %>% - tidyr::gather(key, value, variables) %>% + tibble::rowid_to_column() %>% + tidyr::pivot_longer(variables) %>% dplyr::filter(!is.na(value)) %>% - tidyr::spread(key, value) %>% - dplyr::select(-rowname_temp) + tidyr::pivot_wider(names_from = "name", values_from = "value") %>% + dplyr::select(-rowid) %>% + dplyr::select(names(population)) } else { # Coalesce() must have at least 2 arguments. diff --git a/R/extract_subpopulations.R b/R/extract_subpopulations.R index 40424f3..9b7ea12 100644 --- a/R/extract_subpopulations.R +++ b/R/extract_subpopulations.R @@ -70,7 +70,7 @@ extract_subpopulations <- as.matrix())[1, 2] } - data %<>% dplyr::mutate(cluster_id = kmeans_output$cluster) + data %<>% dplyr::mutate(cluster_id = unname(kmeans_output$cluster)) data %<>% dplyr::bind_cols( purrr::map_df( diff --git a/docs/404.html b/docs/404.html index 9a95554..3a19e6e 100644 --- a/docs/404.html +++ b/docs/404.html @@ -145,7 +145,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 1d2f992..b6d72f6 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -296,7 +296,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 8aa55fc..7223cae 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -148,7 +148,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 1dbd9d9..dbf5165 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -155,7 +155,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/cytominer-pipeline.html b/docs/articles/cytominer-pipeline.html index aad8a7d..e482976 100644 --- a/docs/articles/cytominer-pipeline.html +++ b/docs/articles/cytominer-pipeline.html @@ -85,7 +85,7 @@

Introduction to cytominer

Allen Goodman and Shantanu Singh

-

2020-04-28

+

2020-05-08

Source: vignettes/cytominer-pipeline.Rmd @@ -117,7 +117,7 @@

ext_metadata <-
   readr::read_csv(system.file("extdata", "metadata.csv",
                               package = "cytominer")) %>%
-  dplyr::rename(g_well = Well)
+ dplyr::rename(g_well = Well)
## Parsed with column specification:
 ## cols(
 ##   Well = col_character(),
@@ -134,7 +134,7 @@ 

dplyr::filter(g_well %in% c("A01", "A02", "A10", "A11"))

How many rows does this table have?

measurements %>%
-  dplyr::tally() %>%
+  dplyr::tally() %>%
   knitr::kable()
@@ -193,7 +193,7 @@

strata = c("g_plate", "g_pattern", "g_channel"), sample = na_rows_removed %>% - dplyr::inner_join( + dplyr::inner_join( ext_metadata %>% dplyr::filter(Type == "ctrl") %>% dplyr::select(g_well) @@ -335,7 +335,7 @@

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/index.html b/docs/articles/index.html index 5cbeed2..48c3128 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -144,7 +144,7 @@

All vignettes

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/authors.html b/docs/authors.html index e88ee78..3ec4670 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -160,7 +160,7 @@

Authors

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/index.html b/docs/index.html index 77c3dfc..09ffaa2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -174,7 +174,7 @@

Dev status

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/news/index.html b/docs/news/index.html index cbc2dcb..6e1d63a 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -183,7 +183,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 849c023..c9a7117 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,7 +1,7 @@ pandoc: 2.9.2.1 -pkgdown: 1.5.1 +pkgdown: 1.5.0 pkgdown_sha: ~ articles: cytominer-pipeline: cytominer-pipeline.html -last_built: 2020-04-29T02:38Z +last_built: 2020-05-08T23:08Z diff --git a/docs/reference/aggregate.html b/docs/reference/aggregate.html index 46ac2e5..f9aa26f 100644 --- a/docs/reference/aggregate.html +++ b/docs/reference/aggregate.html @@ -132,8 +132,14 @@

Aggregate data based on given grouping.

aggregate aggregates data based on the specified aggregation method.

-
aggregate(population, variables, strata, operation = "mean",
-  univariate = TRUE, ...)
+
aggregate(
+  population,
+  variables,
+  strata,
+  operation = "mean",
+  univariate = TRUE,
+  ...
+)

Arguments

@@ -205,7 +211,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/correlation_threshold.html b/docs/reference/correlation_threshold.html index efa534d..78e04ac 100644 --- a/docs/reference/correlation_threshold.html +++ b/docs/reference/correlation_threshold.html @@ -132,8 +132,7 @@

Remove redundant variables.

correlation_threshold returns list of variables such that no two variables have a correlation greater than a specified threshold.

-
correlation_threshold(variables, sample, cutoff = 0.9,
-  method = "pearson")
+
correlation_threshold(variables, sample, cutoff = 0.9, method = "pearson")

Arguments

@@ -204,7 +203,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/count_na_rows.html b/docs/reference/count_na_rows.html index 4321e9c..4b7e493 100644 --- a/docs/reference/count_na_rows.html +++ b/docs/reference/count_na_rows.html @@ -180,7 +180,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/covariance.html b/docs/reference/covariance.html index c5f552b..9bc2922 100644 --- a/docs/reference/covariance.html +++ b/docs/reference/covariance.html @@ -178,7 +178,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/drop_na_columns.html b/docs/reference/drop_na_columns.html index 3c2ff62..a3a1da0 100644 --- a/docs/reference/drop_na_columns.html +++ b/docs/reference/drop_na_columns.html @@ -182,7 +182,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/drop_na_rows.html b/docs/reference/drop_na_rows.html index 99b5fbd..7688263 100644 --- a/docs/reference/drop_na_rows.html +++ b/docs/reference/drop_na_rows.html @@ -6,7 +6,7 @@ -Drop rows that are <code>NA</code> in all variables. — drop_na_rows • cytominer +Drop rows that are <code>NA</code> in all specified variables. — drop_na_rows • cytominer @@ -39,8 +39,8 @@ - - + + @@ -123,13 +123,13 @@
-

drop_na_rows drops rows that are NA in all variables.

+

drop_na_rows drops rows that are NA in all specified variables.

drop_na_rows(population, variables)
@@ -149,7 +149,7 @@

Arg

Value

-

population without rows that have NA in all variables.

+

population without rows that have NA in all specified variables.

Examples

population <- tibble::tibble( @@ -187,7 +187,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/extract_subpopulations.html b/docs/reference/extract_subpopulations.html index ccd7c30..7d9270f 100644 --- a/docs/reference/extract_subpopulations.html +++ b/docs/reference/extract_subpopulations.html @@ -229,7 +229,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/generalized_log.html b/docs/reference/generalized_log.html index 4b2ca6c..98c5770 100644 --- a/docs/reference/generalized_log.html +++ b/docs/reference/generalized_log.html @@ -183,7 +183,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/generate_component_matrix.html b/docs/reference/generate_component_matrix.html index 0bf1389..60a32ca 100644 --- a/docs/reference/generate_component_matrix.html +++ b/docs/reference/generate_component_matrix.html @@ -8700,7 +8700,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/index.html b/docs/reference/index.html index 2789f4a..b47ca64 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -180,7 +180,7 @@

drop_na_rows()

-

+

Drop rows that are NA in all variables.

Drop rows that are NA in all specified variables.

@@ -272,7 +272,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/normalize.html b/docs/reference/normalize.html index 86cb9e2..946ffc1 100644 --- a/docs/reference/normalize.html +++ b/docs/reference/normalize.html @@ -132,8 +132,14 @@

Normalize observation variables.

normalize normalizes observation variables based on the specified normalization method.

-
normalize(population, variables, strata, sample,
-  operation = "standardize", ...)
+
normalize(
+  population,
+  variables,
+  strata,
+  sample,
+  operation = "standardize",
+  ...
+)

Arguments

@@ -207,7 +213,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/replicate_correlation.html b/docs/reference/replicate_correlation.html index c0af771..f24ba56 100644 --- a/docs/reference/replicate_correlation.html +++ b/docs/reference/replicate_correlation.html @@ -132,8 +132,15 @@

Measure replicate correlation of variables.

`replicate_correlation` measures replicate correlation of variables.

-
replicate_correlation(sample, variables, strata, replicates,
-  replicate_by = NULL, split_by = NULL, cores = NULL)
+
replicate_correlation(
+  sample,
+  variables,
+  strata,
+  replicates,
+  replicate_by = NULL,
+  split_by = NULL,
+  cores = NULL
+)

Arguments

@@ -216,7 +223,7 @@

Examp cores = 1 )
#> # A tibble: 3 x 4 #> variable median min max -#> <chr> <dbl> <dbl> <dbl> +#> * <chr> <dbl> <dbl> <dbl> #> 1 x 1.00 1.00 1.00 #> 2 y 0.996 0.993 0.999 #> 3 z 0.627 0.290 0.964
@@ -235,7 +242,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/sparse_random_projection.html b/docs/reference/sparse_random_projection.html index 365e23b..53902c1 100644 --- a/docs/reference/sparse_random_projection.html +++ b/docs/reference/sparse_random_projection.html @@ -190,7 +190,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/svd_entropy.html b/docs/reference/svd_entropy.html index 820560b..0b4ac4f 100644 --- a/docs/reference/svd_entropy.html +++ b/docs/reference/svd_entropy.html @@ -184,7 +184,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/transform.html b/docs/reference/transform.html index dd22b7a..2612b59 100644 --- a/docs/reference/transform.html +++ b/docs/reference/transform.html @@ -187,7 +187,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/variable_importance.html b/docs/reference/variable_importance.html index ba329f6..309318b 100644 --- a/docs/reference/variable_importance.html +++ b/docs/reference/variable_importance.html @@ -132,8 +132,12 @@

Measure variable importance.

variable_importance measures importance of variables based on specified methods.

-
variable_importance(sample, variables,
-  operation = "replicate_correlation", ...)
+
variable_importance(
+  sample,
+  variables,
+  operation = "replicate_correlation",
+  ...
+)

Arguments

@@ -205,7 +209,7 @@

Examp cores = 1 )
#> # A tibble: 3 x 4 #> variable median min max -#> <chr> <dbl> <dbl> <dbl> +#> * <chr> <dbl> <dbl> <dbl> #> 1 x 1.00 1.00 1.00 #> 2 y 0.996 0.993 0.999 #> 3 z 0.627 0.290 0.964
@@ -224,7 +228,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/variable_select.html b/docs/reference/variable_select.html index 24c84ac..acd7925 100644 --- a/docs/reference/variable_select.html +++ b/docs/reference/variable_select.html @@ -132,8 +132,13 @@

Select observation variables.

variable_select selects observation variables based on the specified variable selection method.

-
variable_select(population, variables, sample = NULL,
-  operation = "variance_threshold", ...)
+
variable_select(
+  population,
+  variables,
+  sample = NULL,
+  operation = "variance_threshold",
+  ...
+)

Arguments

@@ -223,7 +228,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/variance_threshold.html b/docs/reference/variance_threshold.html index cb0010d..d438e99 100644 --- a/docs/reference/variance_threshold.html +++ b/docs/reference/variance_threshold.html @@ -177,7 +177,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/whiten.html b/docs/reference/whiten.html index 9917321..129eed4 100644 --- a/docs/reference/whiten.html +++ b/docs/reference/whiten.html @@ -188,7 +188,7 @@

Contents

-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.5.0.

diff --git a/man/aggregate.Rd b/man/aggregate.Rd index d0bc9e0..213d44a 100644 --- a/man/aggregate.Rd +++ b/man/aggregate.Rd @@ -4,8 +4,14 @@ \alias{aggregate} \title{Aggregate data based on given grouping.} \usage{ -aggregate(population, variables, strata, operation = "mean", - univariate = TRUE, ...) +aggregate( + population, + variables, + strata, + operation = "mean", + univariate = TRUE, + ... +) } \arguments{ \item{population}{tbl with grouping (metadata) and observation variables.} diff --git a/man/correlation_threshold.Rd b/man/correlation_threshold.Rd index cafe624..de975bc 100644 --- a/man/correlation_threshold.Rd +++ b/man/correlation_threshold.Rd @@ -4,8 +4,7 @@ \alias{correlation_threshold} \title{Remove redundant variables.} \usage{ -correlation_threshold(variables, sample, cutoff = 0.9, - method = "pearson") +correlation_threshold(variables, sample, cutoff = 0.9, method = "pearson") } \arguments{ \item{variables}{character vector specifying observation variables.} diff --git a/man/drop_na_rows.Rd b/man/drop_na_rows.Rd index 9a3e0ad..c24c707 100644 --- a/man/drop_na_rows.Rd +++ b/man/drop_na_rows.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/drop_na_rows.R \name{drop_na_rows} \alias{drop_na_rows} -\title{Drop rows that are \code{NA} in all variables.} +\title{Drop rows that are \code{NA} in all specified variables.} \usage{ drop_na_rows(population, variables) } @@ -12,10 +12,10 @@ drop_na_rows(population, variables) \item{variables}{character vector specifying observation variables.} } \value{ -\code{population} without rows that have \code{NA} in all variables. +\code{population} without rows that have \code{NA} in all specified variables. } \description{ -\code{drop_na_rows} drops rows that are \code{NA} in all variables. +\code{drop_na_rows} drops rows that are \code{NA} in all specified variables. } \examples{ population <- tibble::tibble( diff --git a/man/normalize.Rd b/man/normalize.Rd index fbfcace..a1718e5 100644 --- a/man/normalize.Rd +++ b/man/normalize.Rd @@ -4,8 +4,14 @@ \alias{normalize} \title{Normalize observation variables.} \usage{ -normalize(population, variables, strata, sample, - operation = "standardize", ...) +normalize( + population, + variables, + strata, + sample, + operation = "standardize", + ... +) } \arguments{ \item{population}{tbl with grouping (metadata) and observation variables.} diff --git a/man/replicate_correlation.Rd b/man/replicate_correlation.Rd index ebdbfd1..bef9279 100644 --- a/man/replicate_correlation.Rd +++ b/man/replicate_correlation.Rd @@ -4,8 +4,15 @@ \alias{replicate_correlation} \title{Measure replicate correlation of variables.} \usage{ -replicate_correlation(sample, variables, strata, replicates, - replicate_by = NULL, split_by = NULL, cores = NULL) +replicate_correlation( + sample, + variables, + strata, + replicates, + replicate_by = NULL, + split_by = NULL, + cores = NULL +) } \arguments{ \item{sample}{tbl containing sample used to estimate parameters.} diff --git a/man/variable_importance.Rd b/man/variable_importance.Rd index b74c6ed..8b9cb6a 100644 --- a/man/variable_importance.Rd +++ b/man/variable_importance.Rd @@ -4,8 +4,12 @@ \alias{variable_importance} \title{Measure variable importance.} \usage{ -variable_importance(sample, variables, - operation = "replicate_correlation", ...) +variable_importance( + sample, + variables, + operation = "replicate_correlation", + ... +) } \arguments{ \item{sample}{tbl containing sample used to estimate parameters.} diff --git a/man/variable_select.Rd b/man/variable_select.Rd index f17501f..28d84b4 100644 --- a/man/variable_select.Rd +++ b/man/variable_select.Rd @@ -4,8 +4,13 @@ \alias{variable_select} \title{Select observation variables.} \usage{ -variable_select(population, variables, sample = NULL, - operation = "variance_threshold", ...) +variable_select( + population, + variables, + sample = NULL, + operation = "variance_threshold", + ... +) } \arguments{ \item{population}{tbl with grouping (metadata) and observation variables.} diff --git a/tests/testthat/test-aggregate.R b/tests/testthat/test-aggregate.R index dcc3b75..37e9eb0 100644 --- a/tests/testthat/test-aggregate.R +++ b/tests/testthat/test-aggregate.R @@ -27,7 +27,8 @@ test_that("`aggregate` aggregates data", { dplyr::summarise_at( .funs = ~ MEDIAN(.), .vars = c("x", "y") - ) + ) %>% + dplyr::collect() ) expect_equal( @@ -43,7 +44,8 @@ test_that("`aggregate` aggregates data", { dplyr::summarise_at( .funs = ~ MEDIAN(.), .vars = c("x", "y") - ) + ) %>% + dplyr::collect() ) expect_equal( @@ -59,7 +61,8 @@ test_that("`aggregate` aggregates data", { dplyr::summarise_at( .funs = c(~ mean(., na.rm = T), ~ sd(., na.rm = T)), .vars = c("x", "y") - ) + ) %>% + dplyr::collect() ) cov_a <- diff --git a/tests/testthat/test-cytominer.R b/tests/testthat/test-cytominer.R index 6dbf048..4b74168 100644 --- a/tests/testthat/test-cytominer.R +++ b/tests/testthat/test-cytominer.R @@ -11,7 +11,7 @@ test_that("cytominer can process dataset with a normalized schema", { package = "cytominer" ) - db <- dplyr::src_sqlite(path = fixture) + db <- DBI::dbConnect(RSQLite::SQLite(), fixture) ext_metadata <- readr::read_csv(system.file( @@ -194,6 +194,8 @@ test_that("cytominer can process dataset with a normalized schema", { ), paste0("undefined operation 'dummy'") ) + + DBI::dbDisconnect(db) }) test_that("cytominer can process dataset with a CellProfiler schema", { diff --git a/tests/testthat/test-drop_na_rows.R b/tests/testthat/test-drop_na_rows.R index aff1fa1..8a6a1e5 100644 --- a/tests/testthat/test-drop_na_rows.R +++ b/tests/testthat/test-drop_na_rows.R @@ -12,10 +12,16 @@ test_that("`drop_na_rows` removes rows have only NAs", { data %<>% dplyr::filter(x != 1) drop_na_rows_data_frame <- function(population, variables) { + # TODO: this is a reimplementation of the code within `drop_na_rows` + # so this method should be probably be replaced with a different + # implementation population %>% - tidyr::gather(key, value, variables) %>% + tibble::rowid_to_column() %>% + tidyr::pivot_longer(variables) %>% dplyr::filter(!is.na(value)) %>% - tidyr::spread(key, value) + tidyr::pivot_wider(names_from = "name", values_from = "value") %>% + dplyr::select(-rowid) %>% + dplyr::select(names(population)) } expect_equal( diff --git a/tests/testthat/test-extract_subpopulations.R b/tests/testthat/test-extract_subpopulations.R index 604537d..375f77d 100644 --- a/tests/testthat/test-extract_subpopulations.R +++ b/tests/testthat/test-extract_subpopulations.R @@ -48,7 +48,8 @@ test_that( # find nearest cluster center and distance to it cluster_assign <- function(data, centers, variables, k) { - dist_to_clusters <- cross_dist(data[, variables], centers) + dist_to_clusters <- + cross_dist(data[, variables], centers) apply( dist_to_clusters, 1, @@ -59,7 +60,8 @@ test_that( ) } ) %>% - dplyr::bind_rows() + dplyr::bind_rows() %>% + dplyr::mutate(cluster_id = unname(cluster_id)) } population_clusters <- @@ -87,13 +89,17 @@ test_that( # test whether the cluster assignment and distance to the clusters # are consistent with the returned cluster centers expect_equal( - subpops$population_clusters[, c("dist_to_cluster", "cluster_id")], - as.data.frame(population_clusters) + subpops$population_clusters[, c("dist_to_cluster", "cluster_id")] %>% + as.data.frame(), + population_clusters %>% + as.data.frame() ) expect_equal( - subpops$reference_clusters[, c("dist_to_cluster", "cluster_id")], - as.data.frame(reference_clusters) + subpops$reference_clusters[, c("dist_to_cluster", "cluster_id")] %>% + as.data.frame(), + reference_clusters %>% + as.data.frame() ) # test whether the summation of cluster proportions is equal to one diff --git a/tests/testthat/test-generalized_log.R b/tests/testthat/test-generalized_log.R index d5ed6cc..1f4498b 100644 --- a/tests/testthat/test-generalized_log.R +++ b/tests/testthat/test-generalized_log.R @@ -16,7 +16,8 @@ test_that("`generalized_log` generalized_logs data", { generalized_log( population = data, variables = c("x", "y") - ) %>% dplyr::collect(), + ) %>% dplyr::collect() %>% + as.data.frame(), glog(data %>% dplyr::collect()) )