From f7912617e91696ba6b042a34917e5d0e91e8bec8 Mon Sep 17 00:00:00 2001 From: huizezhang-sherry Date: Thu, 16 Nov 2023 14:12:52 +1100 Subject: [PATCH] test covergage now 87% --- NAMESPACE | 1 - R/as-cubble.R | 33 - R/cubble-update.R | 25 +- R/matching.R | 78 +- R/unfold.R | 9 +- man/update.Rd | 10 - tests/testthat/_snaps/as-cubble.md | 41 +- tests/testthat/_snaps/check-key.md | 4 +- tests/testthat/_snaps/checks.md | 20 + tests/testthat/_snaps/cubble-class.md | 13 +- tests/testthat/_snaps/dplyr.md | 28 +- .../testthat/_snaps/face-spatial-temporal.md | 4 +- tests/testthat/_snaps/matching.md | 982 ++++++++++++++++-- tests/testthat/_snaps/tsibble.md | 20 +- tests/testthat/_snaps/unfold.md | 51 + tests/testthat/test-as-cubble.R | 48 +- tests/testthat/test-checks.R | 14 + tests/testthat/test-cubble-class.R | 2 +- tests/testthat/test-matching.R | 15 +- tests/testthat/test-unfold.R | 2 + 20 files changed, 1153 insertions(+), 247 deletions(-) create mode 100644 tests/testthat/_snaps/checks.md create mode 100644 tests/testthat/test-checks.R diff --git a/NAMESPACE b/NAMESPACE index c6d46d35..ab10489e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -49,7 +49,6 @@ S3method(unfold,temporal_cubble_df) S3method(ungroup,spatial_cubble_df) S3method(ungroup,temporal_cubble_df) S3method(update_cubble,spatial_cubble_df) -S3method(update_cubble,temporal_cubble_df) export(as_cubble) export(bind_cols.spatial_cubble_df) export(bind_cols.temporal_cubble_df) diff --git a/R/as-cubble.R b/R/as-cubble.R index 05cec0ff..4987d389 100644 --- a/R/as-cubble.R +++ b/R/as-cubble.R @@ -193,39 +193,6 @@ as_cubble.stars <- function(data, key, index, coords, ...){ } } - -parse_dimension <- function(obj){ - - if (!is.null(obj$value)) { - out <- obj$value - } else if (is.numeric(obj$from) & - is.numeric(obj$to) & - inherits(obj$delta, "numeric")){ - out <- seq(obj$offset, obj$offset + - (obj$to - 1) * obj$delta, by = obj$delta) - } else if (!is.na(obj$refsys)){ - if (obj$refsys == "udunits"){ - tstring <- attr(obj$offset, "units")$numerator - origin <- parse_time(tstring) - - if (is.null(origin)) - cli::cli_abort( - "The units is currently too complex for {.field cubble} to parse.") - - tperiod <- sub(" .*", "\\1", tstring) - time <- seq(obj$from,obj$to, as.numeric(obj$delta)) - out <- origin %m+% do.call(tperiod, list(x = floor(time))) - } else if (obj$refsys == "POSIXct"){ - out <- obj$value - } - } else{ - cli::cli_abort( - "The units is currently too complex for {.field cubble} to parse.") - } - - out -} - #' @rdname as_cubble #' @export as_cubble.sftime <- function(data, key, index, coords, ...){ diff --git a/R/cubble-update.R b/R/cubble-update.R index 23a52d55..78b1eb4d 100644 --- a/R/cubble-update.R +++ b/R/cubble-update.R @@ -23,16 +23,15 @@ update_cubble.spatial_cubble_df <- function(data, key = NULL, } #' @rdname update -#' @export -update_cubble.temporal_cubble_df <- function(data, key = NULL, - index = NULL, coords = NULL, - spatial = NULL, ...){ - - key <- key_vars(data) - index <- index_var(data) - coords <- coords(data) - - spatial <- spatial(data) - data |> new_temporal_cubble( - key = key, index = index, coords = coords, spatial = spatial) -} +# update_cubble.temporal_cubble_df <- function(data, key = NULL, +# index = NULL, coords = NULL, +# spatial = NULL, ...){ +# +# key <- key_vars(data) +# index <- index_var(data) +# coords <- coords(data) +# +# spatial <- spatial(data) +# data |> new_temporal_cubble( +# key = key, index = index, coords = coords, spatial = spatial) +# } diff --git a/R/matching.R b/R/matching.R index 954e84cd..74262406 100644 --- a/R/matching.R +++ b/R/matching.R @@ -64,7 +64,7 @@ match_sites <- function(df1, df2, crs = sf::st_crs("OGC:CRS84"), if (temporal_matching){ - out <- out |> + out <- out |> map(~.x |> match_temporal( data_id = !!enquo(data_id), match_id = !!enquo(match_id), temporal_match_fn = match_peak, @@ -107,41 +107,41 @@ match_spatial <- function(df1, df2, if (is.null(which)) which <- ifelse(isTRUE(sf::st_is_longlat(df1)), "Great Circle", "Euclidean") - dist_df <- sf::st_distance(df1, df2, which = which, par = par) |> - as_tibble() |> - mutate(from = key_val) |> - dplyr::rename_with(~ c(key_val2, "from")) |> + dist_df <- sf::st_distance(df1, df2, which = which, par = par) |> + as_tibble() |> + mutate(from = key_val) |> + dplyr::rename_with(~ c(key_val2, "from")) |> tidyr::pivot_longer(cols = -.data$from, names_to = "to", values_to = "dist") - gp_return <- dist_df |> - dplyr::slice_min(.data$dist, n = 1, by = .data$from) |> - dplyr::slice_min(.data$dist, n = spatial_n_group) |> + gp_return <- dist_df |> + dplyr::slice_min(.data$dist, n = 1, by = .data$from) |> + dplyr::slice_min(.data$dist, n = spatial_n_group) |> mutate(group = dplyr::row_number()) - dist_df2 <- dist_df |> - inner_join(gp_return |> select(-.data$dist, -.data$to), by = "from") |> - dplyr::slice_min(.data$dist, n = spatial_n_each, by = .data$from) |> + dist_df2 <- dist_df |> + inner_join(gp_return |> select(-.data$dist, -.data$to), by = "from") |> + dplyr::slice_min(.data$dist, n = spatial_n_each, by = .data$from) |> arrange(.data$group) if (return_cubble){ - res1 <- df1 |> - inner_join(dist_df2 |> - select(.data$from, .data$group) |> + res1 <- df1 |> + inner_join(dist_df2 |> + select(.data$from, .data$group) |> rename(!!key := .data$from), - by = key) |> + by = key) |> update_cubble() - res2 <- df2 |> - inner_join(dist_df2 |> - select(-.data$from) |> + res2 <- df2 |> + inner_join(dist_df2 |> + select(-.data$from) |> rename(!!key := .data$to), - by = key) |> - update_cubble() |> + by = key) |> + update_cubble() |> arrange(.data$dist) - dist_df2 <- bind_rows(res1, res2) |> - dplyr::group_split(.data$group) |> + dist_df2 <- bind_rows(res1, res2) |> + dplyr::group_split(.data$group) |> map(update_cubble) } @@ -164,28 +164,28 @@ match_temporal <- function(data, key <- key_vars(data) index <- index_var(data) - multiple_match <- any(data |> - group_by(!!match_id) |> + multiple_match <- any(data |> + group_by(!!match_id) |> dplyr::group_size() != 2) if (multiple_match){ - data <- data |> - dplyr::group_split(!!match_id) |> - map(~.x |> update_cubble() |> group_by(type) |> - mutate(group2 = dplyr::row_number()) |> - dplyr::group_split(.data$group2)) |> - unlist(recursive = FALSE) |> + data <- data |> + dplyr::group_split(!!match_id) |> + map(~.x |> update_cubble() |> group_by(type) |> + mutate(group2 = dplyr::row_number()) |> + dplyr::group_split(.data$group2)) |> + unlist(recursive = FALSE) |> map(update_cubble) } else{ - data <- data |> + data <- data |> dplyr::group_split(!!match_id) } - data_long <- data |> - map(~.x |> - dplyr::group_split(!!data_id) |> - purrr::map2(var_names, ~.x |> - face_temporal() |> - dplyr::select(key, index, .y) |> + data_long <- data |> + map(~.x |> + dplyr::group_split(!!data_id) |> + purrr::map2(var_names, ~.x |> + face_temporal() |> + dplyr::select(key, index, .y) |> dplyr::rename(matched = .y))) vecs <- data_long |> map(~map(.x, ~.x$matched)) @@ -205,8 +205,8 @@ match_temporal <- function(data, res <- out |> dplyr::bind_cols(match_res = res) if (return_cubble){ - res <- data_long |> - map(~map(.x, ~face_spatial(.x)) |> bind_rows()) |> + res <- data_long |> + map(~map(.x, ~face_spatial(.x)) |> bind_rows()) |> map2(res$match_res, ~.x |> mutate(match_res = .y)) } diff --git a/R/unfold.R b/R/unfold.R index 9db3edb3..8d102381 100644 --- a/R/unfold.R +++ b/R/unfold.R @@ -36,15 +36,10 @@ unfold.temporal_cubble_df <- function(data, ...){ to_join <- sp |> as_tibble() |> select(c(key_vars(data), ...)) out <- as_tibble(data) |> left_join(to_join, by = key) - if (nrow(out) != nrow(data)){ - var <- names(dots) - cli::cli_alert_warning( - "The key and unfoldd variable{?s} {.field {var}} are not one-to-one." - ) - } - if (is_tsibble(data)){ index <- data %@% index + out <- out |> tsibble::as_tsibble(key = !!key, index = index) + tsibble_attr <- attributes(out) } else{ index <- as_name(index) } diff --git a/man/update.Rd b/man/update.Rd index 88435d3d..6260ebe5 100644 --- a/man/update.Rd +++ b/man/update.Rd @@ -3,21 +3,11 @@ \name{update_cubble} \alias{update_cubble} \alias{update_cubble.spatial_cubble_df} -\alias{update_cubble.temporal_cubble_df} \title{Temporary update cubble if the sf class take precedent of cubble classes} \usage{ update_cubble(data, key, index, coords, ...) \method{update_cubble}{spatial_cubble_df}(data, key = NULL, index = NULL, coords = NULL, ...) - -\method{update_cubble}{temporal_cubble_df}( - data, - key = NULL, - index = NULL, - coords = NULL, - spatial = NULL, - ... -) } \arguments{ \item{data, key, index, coords, spatial, ...}{skdflsjkd} diff --git a/tests/testthat/_snaps/as-cubble.md b/tests/testthat/_snaps/as-cubble.md index fc245d6f..ef6e002c 100644 --- a/tests/testthat/_snaps/as-cubble.md +++ b/tests/testthat/_snaps/as-cubble.md @@ -27,6 +27,30 @@ 2 ASN00086077 145. -38.0 12.1 moorabbin airport 94870 3 ASN00086282 145. -37.7 113. melbourne airport 94866 +--- + + Code + as_cubble(nest(climate_flat, data = date:tmin), key = id, index = date, coords = c( + long, lat)) + Output + # cubble: key: id [3], index: date, nested form + # spatial: [144.8321, -37.98, 145.0964, -37.6655], Missing CRS! + # temporal: date [date], prcp [dbl], tmax [dbl], tmin [dbl] + id long lat elev name wmo_id ts + + 1 ASN00086038 145. -37.7 78.4 essendon airport 95866 + 2 ASN00086077 145. -38.0 12.1 moorabbin airport 94870 + 3 ASN00086282 145. -37.7 113. melbourne airport 94866 + +--- + + Code + as_cubble(nest(climate_flat, data = prcp:tmin), key = id, index = date, coords = c( + long, lat)) + Condition + Error in `as_cubble()`: + ! Can't' find the index variable in the data. Please check. + --- Code @@ -64,10 +88,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(longlat) + data %>% select(longlat) # Now: - data |> select(all_of(longlat)) + data %>% select(all_of(longlat)) See . Message @@ -199,3 +223,16 @@ 2 ASN00086077 12.1 moora~ 94870 (145.0964 -37.98) 145. -38.0 3 ASN00086282 113. melbo~ 94866 (144.8321 -37.6655) 145. -37.7 +--- + + Code + as_cubble(data_stars, key = id, index = time) + Output + # cubble: key: id [2], index: time, nested form, [sf] + # spatial: [130, -44, 140, -38], WGS 84 + # temporal: time [date], var1 [dbl] + id long lat station ts + * + 1 1 130 -38 (130 -38) + 2 2 140 -44 (140 -44) + diff --git a/tests/testthat/_snaps/check-key.md b/tests/testthat/_snaps/check-key.md index 19ab7e41..5d56b1c9 100644 --- a/tests/testthat/_snaps/check-key.md +++ b/tests/testthat/_snaps/check-key.md @@ -81,10 +81,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(by) + data %>% select(by) # Now: - data |> select(all_of(by)) + data %>% select(all_of(by)) See . Output diff --git a/tests/testthat/_snaps/checks.md b/tests/testthat/_snaps/checks.md new file mode 100644 index 00000000..8186d27e --- /dev/null +++ b/tests/testthat/_snaps/checks.md @@ -0,0 +1,20 @@ +# multiplication works + + Code + make_cubble(spatial = lga, temporal = covid, potential_match = check_res) + Condition + Warning: + st_centroid assumes attributes are constant over geometries + Error in `check_key_tbl()`: + ! The obj need to be the result from `check_key()`. + +--- + + Code + make_cubble(lga, covid, potential_match = check_res, key_use = "aaa") + Condition + Warning: + st_centroid assumes attributes are constant over geometries + Error in `check_key_tbl()`: + ! The obj need to be the result from `check_key()`. + diff --git a/tests/testthat/_snaps/cubble-class.md b/tests/testthat/_snaps/cubble-class.md index c1797567..0e9b9490 100644 --- a/tests/testthat/_snaps/cubble-class.md +++ b/tests/testthat/_snaps/cubble-class.md @@ -8,10 +8,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(by) + data %>% select(by) # Now: - data |> select(all_of(by)) + data %>% select(all_of(by)) See . Output @@ -24,3 +24,12 @@ 2 ASN00086077 145. -38.0 12.1 moorabbin airport 94870 3 ASN00086282 145. -37.7 113. melbourne airport 94866 +--- + + Code + key(climate_mel) + Output + [[1]] + id + + diff --git a/tests/testthat/_snaps/dplyr.md b/tests/testthat/_snaps/dplyr.md index 68e96628..ba6896f7 100644 --- a/tests/testthat/_snaps/dplyr.md +++ b/tests/testthat/_snaps/dplyr.md @@ -106,8 +106,8 @@ --- Code - cb_long |> group_by(first_5 = ifelse(lubridate::day(date) <= 5, 1, 2)) |> - summarise(tmax = mean(tmax)) + summarise(group_by(cb_long, first_5 = ifelse(lubridate::day(date) <= 5, 1, 2)), + tmax = mean(tmax)) Output # cubble: key: id [3], index: first_5, long form, groups: first_5 [2] # temporal: 1 -- 2 [1], no gaps @@ -124,17 +124,17 @@ --- Code - cb_long |> mutate(first_5 = ifelse(lubridate::day(date) <= 5, 1, 2)) |> - summarise(t = mean(tmax), .by = first_5) + summarise(mutate(cb_long, first_5 = ifelse(lubridate::day(date) <= 5, 1, 2)), + t = mean(tmax), .by = first_5) Condition Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.by) + data %>% select(.by) # Now: - data |> select(all_of(.by)) + data %>% select(all_of(.by)) See . Output @@ -166,10 +166,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Output @@ -193,10 +193,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Output @@ -220,10 +220,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Output @@ -255,10 +255,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Output diff --git a/tests/testthat/_snaps/face-spatial-temporal.md b/tests/testthat/_snaps/face-spatial-temporal.md index 1ddb7c28..fb3f5aea 100644 --- a/tests/testthat/_snaps/face-spatial-temporal.md +++ b/tests/testthat/_snaps/face-spatial-temporal.md @@ -29,10 +29,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key_name) + data %>% select(key_name) # Now: - data |> select(all_of(key_name)) + data %>% select(all_of(key_name)) See . Output diff --git a/tests/testthat/_snaps/matching.md b/tests/testthat/_snaps/matching.md index 51e377b4..4e3fed60 100644 --- a/tests/testthat/_snaps/matching.md +++ b/tests/testthat/_snaps/matching.md @@ -7,20 +7,20 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Message @@ -59,20 +59,20 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Message @@ -111,20 +111,20 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key2) + data %>% select(key2) # Now: - data |> select(all_of(key2)) + data %>% select(all_of(key2)) See . Message @@ -160,6 +160,772 @@ 9 ASN00084145 221224 63127. 2 10 ASN00084145 224217 79816. 2 +--- + + Code + match_spatial(climate_aus, river, spatial_n_each = 5, spatial_n_group = 2, + return_cubble = TRUE) + Condition + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key2) + + # Now: + data %>% select(all_of(key2)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key2) + + # Now: + data %>% select(all_of(key2)) + + See . + Message + Use OGC:CRS84 by default for distance calculation... + Condition + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"dist"` instead of `.data$dist` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"to"` instead of `.data$to` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"group"` instead of `.data$group` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"to"` instead of `.data$to` + Output + [[1]] + # cubble: key: id [6], index: date, nested form, [sf] + # spatial: [144.490577, -37.098955, 145.056144, -36.947179], WGS 84 + # temporal: date [date], prcp [dbl], tmax [dbl], tmin [dbl] + id long lat elev name wmo_id ts type geometry + + 1 ASN0~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) + 2 ASN0~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) + 3 ASN0~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) + 4 ASN0~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) + 5 ASN0~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) + 6 4062~ 145. -37.0 NA CAMP~ NA river (144.5403 -37.01512) + 7 4062~ 144. -37.0 NA COLI~ NA river (144.4906 -36.96145) + 8 4062~ 145. -36.9 NA WILD~ NA river (144.6647 -36.94718) + 9 4052~ 145. -37.1 NA SUGA~ NA river (145.055 -37.05963) + 10 4052~ 145. -37.1 NA SUND~ NA river (145.0561 -37.09895) + # i 2 more variables: group , dist [m] + + [[2]] + # cubble: key: id [6], index: date, nested form, [sf] + # spatial: [147.572223, -37.815, 149.156689, -37.538647], WGS 84 + # temporal: date [date], prcp [dbl], tmax [dbl], tmin [dbl] + id long lat elev name wmo_id ts type geometry + + 1 ASN0~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) + 2 ASN0~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) + 3 ASN0~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) + 4 ASN0~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) + 5 ASN0~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) + 6 2222~ 148. -37.7 NA SNOW~ NA river (148.451 -37.70739) + 7 2222~ 149. -37.8 NA SNOW~ NA river (148.5278 -37.79889) + 8 2232~ 148. -37.8 NA TAMB~ NA river (147.8491 -37.75731) + 9 2212~ 149. -37.5 NA CANN~ NA river (149.1567 -37.53865) + 10 2242~ 148. -37.8 NA MITC~ NA river (147.5722 -37.815) + # i 2 more variables: group , dist [m] + + +--- + + Code + match_sites(climate_aus, river, data_id = type, match_id = group, temporal_by = c( + prcp = "Water_course_level")) + Condition + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key2) + + # Now: + data %>% select(all_of(key2)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key2) + + # Now: + data %>% select(all_of(key2)) + + See . + Message + Use OGC:CRS84 by default for distance calculation... + Condition + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"dist"` instead of `.data$dist` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"to"` instead of `.data$to` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"group"` instead of `.data$group` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"from"` instead of `.data$from` + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"to"` instead of `.data$to` + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(index) + + # Now: + data %>% select(all_of(index)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(loc) + + # Now: + data %>% select(all_of(loc)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(.y) + + # Now: + data %>% select(all_of(.y)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key_name) + + # Now: + data %>% select(all_of(key_name)) + + See . + Output + [[1]] + [[1]][[1]] + # cubble: key: id [2], index: date, nested form, [sf] + # spatial: [144.5203, -37.0194, 144.540295, -37.015122], WGS 84 + # temporal: date [date], matched [dbl] + id long lat elev name wmo_id type geometry group + + 1 ASN00088~ 145. -37.0 290 rede~ 94859 clim~ (144.5203 -37.0194) 1 + 2 406213 145. -37.0 NA CAMP~ NA river (144.5403 -37.01512) 1 + # i 3 more variables: dist [m], ts , match_res + + + [[2]] + [[2]][[1]] + # cubble: key: id [2], index: date, nested form, [sf] + # spatial: [148.45095, -37.707393, 148.4667, -37.6922], WGS 84 + # temporal: date [date], matched [dbl] + id long lat elev name wmo_id type geometry group + + 1 ASN00084~ 148. -37.7 62.7 orbo~ 95918 clim~ (148.4667 -37.6922) 2 + 2 222201 148. -37.7 NA SNOW~ NA river (148.451 -37.70739) 2 + # i 3 more variables: dist [m], ts , match_res + + + [[3]] + [[3]][[1]] + # cubble: key: id [2], index: date, nested form, [sf] + # spatial: [147.127818, -38.144913, 147.1322, -38.1156], WGS 84 + # temporal: date [date], matched [dbl] + id long lat elev name wmo_id type geometry group + + 1 ASN00085~ 147. -38.1 4.6 east~ 94907 clim~ (147.1322 -38.1156) 3 + 2 226027 147. -38.1 NA LA T~ NA river (147.1278 -38.14491) 3 + # i 3 more variables: dist [m], ts , match_res + + + [[4]] + [[4]][[1]] + # cubble: key: id [2], index: date, nested form, [sf] + # spatial: [144.7642, -36.1647, 144.76931, -36.128657], WGS 84 + # temporal: date [date], matched [dbl] + id long lat elev name wmo_id type geometry group + + 1 ASN00080~ 145. -36.2 96 echu~ 94861 clim~ (144.7642 -36.1647) 4 + 2 406704 145. -36.1 NA DEAK~ NA river (144.7693 -36.12866) 4 + # i 3 more variables: dist [m], ts , match_res + + + --- Code @@ -169,480 +935,480 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(index) + data %>% select(index) # Now: - data |> select(all_of(index)) + data %>% select(all_of(index)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(loc) + data %>% select(loc) # Now: - data |> select(all_of(loc)) + data %>% select(all_of(loc)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(.y) + data %>% select(.y) # Now: - data |> select(all_of(.y)) + data %>% select(all_of(.y)) See . Output diff --git a/tests/testthat/_snaps/tsibble.md b/tests/testthat/_snaps/tsibble.md index 72d59cdf..70afd4b4 100644 --- a/tests/testthat/_snaps/tsibble.md +++ b/tests/testthat/_snaps/tsibble.md @@ -7,20 +7,20 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Output @@ -50,10 +50,10 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Output @@ -83,20 +83,20 @@ Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0. i Please use `all_of()` or `any_of()` instead. # Was: - data |> select(key) + data %>% select(key) # Now: - data |> select(all_of(key)) + data %>% select(all_of(key)) See . Output diff --git a/tests/testthat/_snaps/unfold.md b/tests/testthat/_snaps/unfold.md index e00d370b..bee1dd3b 100644 --- a/tests/testthat/_snaps/unfold.md +++ b/tests/testthat/_snaps/unfold.md @@ -42,3 +42,54 @@ 10 ASN00086038 2020-01-10 0 34 19.6 145. -37.7 # i 20 more rows +--- + + Code + unfold(climate_mel) + Condition + Error in `unfold()`: + ! `unfold()` currently can only be used on a long form cubble (class `spatial_cubble_df`) + +--- + + Code + unfold(make_temporal_tsibble(face_temporal(climate_mel)), long, lat) + Condition + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Warning: + Using an external vector in selections was deprecated in tidyselect 1.1.0. + i Please use `all_of()` or `any_of()` instead. + # Was: + data %>% select(key) + + # Now: + data %>% select(all_of(key)) + + See . + Output + # cubble: key: id [3], index: date, long form, [tsibble] + # temporal: 2020-01-01 -- 2020-01-10 [1D], no gaps + # spatial: long [dbl], lat [dbl], elev [dbl], name [chr], wmo_id [dbl] + id date prcp tmax tmin long lat + + 1 ASN00086038 2020-01-01 0 26.8 11 145. -37.7 + 2 ASN00086038 2020-01-02 0 26.3 12.2 145. -37.7 + 3 ASN00086038 2020-01-03 0 34.5 12.7 145. -37.7 + 4 ASN00086038 2020-01-04 0 29.3 18.8 145. -37.7 + 5 ASN00086038 2020-01-05 18 16.1 12.5 145. -37.7 + 6 ASN00086038 2020-01-06 104 17.5 11.1 145. -37.7 + 7 ASN00086038 2020-01-07 14 20.7 12.1 145. -37.7 + 8 ASN00086038 2020-01-08 0 26.4 16.4 145. -37.7 + 9 ASN00086038 2020-01-09 0 33.1 17.4 145. -37.7 + 10 ASN00086038 2020-01-10 0 34 19.6 145. -37.7 + # i 20 more rows + diff --git a/tests/testthat/test-as-cubble.R b/tests/testthat/test-as-cubble.R index 6c67793c..20831ecb 100644 --- a/tests/testthat/test-as-cubble.R +++ b/tests/testthat/test-as-cubble.R @@ -11,6 +11,18 @@ test_that("as_cubble() works", { as_cubble(key = id, index = date, coords = c(long, lat)) ) + expect_snapshot( + climate_flat |> + nest(data = date:tmin) |> + as_cubble(key = id, index = date, coords = c(long, lat)) + ) + + expect_snapshot( + climate_flat |> + nest(data = prcp:tmin) |> + as_cubble(key = id, index = date, coords = c(long, lat)), error = TRUE + ) + # only need `coords` if created from a tsibble dt <- climate_flat |> tsibble::as_tsibble(key = id, index = date) expect_snapshot(dt |> as_cubble(coords = c(long, lat))) @@ -37,8 +49,40 @@ test_that("as_cubble() works", { ) # don't have to supply coords if create from a sftime - dt <- climate_flat |> - sf::st_as_sf(coords = c("long", "lat"), crs = sf::st_crs("OGC:CRS84")) |> + dt <- climate_flat |> + sf::st_as_sf(coords = c("long", "lat"), crs = sf::st_crs("OGC:CRS84")) |> sftime::st_as_sftime() expect_snapshot(dt |> as_cubble(key = id, index = date)) + + library(tibble) + library(sf) + library(stars) + # a vector data cube example + spatial_sf <- tibble( + id = c(1,2), + long = c(130, 140), + lat = c(-38, -44), + name = c("station 1", "station 2") + ) |> + sf::st_as_sf(coords = c("long", "lat"), crs = 4326) + + temporal <- tibble( + id = c(rep(1, each = 5), rep(2, each = 5)), + time = c(seq(as.Date("2023-03-21"), as.Date("2023-03-25"), 1), + seq(as.Date("2023-03-21"), as.Date("2023-03-25"), 1)), + var1 = c(3, 6, 8, 2, 5, 7, 9, 14, 5, 9) + ) + + # with stars + station_vec <- st_geometry(spatial_sf) + time_vec <- unique(temporal$time) + var_vec <- spatial_sf$name + d <- st_dimensions(station = station_vec, time = time_vec) + var1_array <- temporal$var1 |> + matrix(byrow = TRUE, nrow = 2, ncol = 5) |> + array(dim = dim(d)) + data_stars <- st_as_stars(list(var1 = var1_array), dimensions = d) + expect_snapshot(data_stars |> as_cubble(key = id, index= time)) + + }) diff --git a/tests/testthat/test-checks.R b/tests/testthat/test-checks.R new file mode 100644 index 00000000..a253f9aa --- /dev/null +++ b/tests/testthat/test-checks.R @@ -0,0 +1,14 @@ +test_that("multiplication works", { + colnames(lga) <- c("lga", "geometry") + check_res <- check_key(stations, meteo) + class(check_res) <- "list" + expect_snapshot( + make_cubble(spatial = lga, temporal = covid, potential_match = check_res), + error = TRUE + ) + + expect_snapshot( + make_cubble(lga, covid, potential_match = check_res, key_use = "aaa"), + error = TRUE + ) +}) diff --git a/tests/testthat/test-cubble-class.R b/tests/testthat/test-cubble-class.R index 2fab8cc0..0ba1abfb 100644 --- a/tests/testthat/test-cubble-class.R +++ b/tests/testthat/test-cubble-class.R @@ -14,5 +14,5 @@ test_that("creating cubble works", { key = id, index = date, coords = c(long, lat)) ) - + expect_snapshot(key(climate_mel)) }) diff --git a/tests/testthat/test-matching.R b/tests/testthat/test-matching.R index e1be76dd..e03f731d 100644 --- a/tests/testthat/test-matching.R +++ b/tests/testthat/test-matching.R @@ -6,11 +6,24 @@ test_that("matching examples work", { expect_snapshot(match_spatial(climate_aus, river, which = "Hausdorff")) # tune the number of matches in each group expect_snapshot( - match_spatial(climate_aus, river, spatial_n_each = 5, spatial_n_group = 2)) + match_spatial(climate_aus, river, spatial_n_each = 5, spatial_n_group = 2) + ) + expect_snapshot( + match_spatial(climate_aus, river, spatial_n_each = 5, spatial_n_group = 2, + return_cubble = TRUE) + ) + + expect_snapshot( + match_sites( + climate_aus, river, data_id = type, match_id = group, + temporal_by = c("prcp" = "Water_course_level") + ) + ) a1 <- match_spatial(climate_aus, river, return_cubble = TRUE) |> bind_rows() expect_snapshot( match_temporal(a1, data_id = type, match_id = group, temporal_by = c("prcp" = "Water_course_level")) ) + }) diff --git a/tests/testthat/test-unfold.R b/tests/testthat/test-unfold.R index 4c1ad607..a1c8c116 100644 --- a/tests/testthat/test-unfold.R +++ b/tests/testthat/test-unfold.R @@ -1,4 +1,6 @@ test_that("unfold() works", { expect_snapshot(climate_mel |> face_temporal() |> unfold(long, lat)) expect_snapshot(climate_mel |> face_temporal() |> unfold(dplyr::starts_with("l"))) + expect_snapshot(climate_mel |> unfold(), error = TRUE) + expect_snapshot(climate_mel |> face_temporal() |> make_temporal_tsibble() |> unfold(long, lat)) })