Skip to content

Commit

Permalink
prepare CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaMeyer committed Jun 10, 2024
1 parent 133ebb2 commit ed4987d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ URL: https://github.com/HannaMeyer/CAST,
Encoding: UTF-8
LazyData: false
Depends: R (>= 4.1.0)
Imports: caret, stats, utils, ggplot2, graphics, FNN, plyr, zoo, methods, grDevices, data.table, sf, forcats, twosamples, terra
Imports: caret, stats, utils, ggplot2, graphics, FNN, plyr, zoo, methods, grDevices, data.table, sf, forcats, twosamples, terra, sp
Suggests:
doParallel,
lubridate,
Expand Down
1 change: 0 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# `CAST` 1.0.2
* bug fix: tests run conditionally
* modifications: dependence on sp replaced by sf

# `CAST` 1.0.1
* bug fix: fix failed tests in global_validation
Expand Down
17 changes: 9 additions & 8 deletions R/geodist.R
Original file line number Diff line number Diff line change
Expand Up @@ -640,16 +640,17 @@ sampleFromArea <- function(modeldomain, samplesize, type,variables,sampling, cat
sf::st_as_sf(modeldomainextent) |>
sf::st_transform(4326) -> bb

#methods::as(bb, "Spatial") |>
# sp::spsample(n = samplesize, type = sampling) |>
# sf::st_as_sfc() |>
# sf::st_set_crs(4326) -> predictionloc
# predictionloc <- sf::st_as_sf(predictionloc)

predictionloc <- sf::st_sample(sf::st_make_valid(bb),size=samplesize,type=sampling)
sf::st_crs(predictionloc) <- 4326
methods::as(bb, "Spatial") |>
sp::spsample(n = samplesize, type = sampling) |>
sf::st_as_sfc() |>
sf::st_set_crs(4326) -> predictionloc
predictionloc <- sf::st_as_sf(predictionloc)

# sf version:
# predictionloc <- sf::st_sample(sf::st_make_valid(bb),size=samplesize,type=sampling)
# sf::st_crs(predictionloc) <- 4326
# predictionloc <- sf::st_as_sf(predictionloc)




Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-geodist.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_that("geodist works with points and polygon in geographic space", {

expect_equal(mean_sample2sample, 20321)
expect_equal(mean_CV_distances, 25616)
expect_equal(nrow_dist, 3405) #3410
expect_equal(nrow_dist, 3410)


})
Expand Down Expand Up @@ -247,7 +247,7 @@ test_that("geodist works with categorical variables in feature space", {
mean_CV_distance <- round(mean(dist[dist$what=="CV-distances","dist"]), 4)

expect_equal(mean_sample2sample, 0.0459)
expect_equal(mean_prediction2sample, 0.161) #0.1625
expect_equal(mean_prediction2sample, 0.1625) #0.1625
expect_equal(mean_test2sample, 0.2358)
expect_equal(mean_CV_distance, 0.0663)
})
Expand Down

0 comments on commit ed4987d

Please sign in to comment.