|
1 | 1 | # Adapted from: https://github.com/geanders/hurricaneexposure/blob/master/R/zzz.R |
2 | 2 |
|
3 | | -.pkgenv <- new.env(parent = emptyenv()) |
| 3 | +# .pkgenv <- new.env(parent = emptyenv()) |
4 | 4 |
|
5 | | -.onLoad <- function(libname, pkgname) { |
| 5 | +# .onLoad <- function(libname, pkgname) { |
6 | 6 |
|
7 | | - has_data <- all(requireNamespace("RandomFields", quietly = TRUE), |
8 | | - requireNamespace("RandomFieldsUtils", quietly = TRUE)) |
| 7 | +# has_data <- all(requireNamespace("RandomFields", quietly = TRUE), |
| 8 | +# requireNamespace("RandomFieldsUtils", quietly = TRUE)) |
9 | 9 |
|
10 | | - .pkgenv[["has_data"]] <- has_data |
| 10 | +# .pkgenv[["has_data"]] <- has_data |
11 | 11 |
|
12 | | -} |
| 12 | +# } |
13 | 13 |
|
14 | | -.onAttach <- function(libname, pkgname) { |
| 14 | +# .onAttach <- function(libname, pkgname) { |
15 | 15 |
|
16 | | - if (!.pkgenv$has_data) { |
| 16 | +# if (!.pkgenv$has_data) { |
17 | 17 |
|
18 | | - message <- paste("Some functions in this package require the 'RandomFields'", |
19 | | - "and 'RandomFieldsUtil' packages which are not available on CRAN anymore.", |
20 | | - "To install them, please run 'install.packages('RandomFields',", |
21 | | - "repos = 'https://predictiveecology.r-universe.dev', type = 'source')'.") |
| 18 | +# message <- paste("Some functions in this package require the 'RandomFields'", |
| 19 | +# "and 'RandomFieldsUtil' packages which are not available on CRAN anymore.", |
| 20 | +# "To install them, please run 'install.packages('RandomFields',", |
| 21 | +# "repos = 'https://predictiveecology.r-universe.dev', type = 'source')'.") |
22 | 22 |
|
23 | | - message <- paste(strwrap(message), collapse = "\n") |
| 23 | +# message <- paste(strwrap(message), collapse = "\n") |
24 | 24 |
|
25 | | - packageStartupMessage(message) |
| 25 | +# packageStartupMessage(message) |
26 | 26 |
|
27 | | - } |
28 | | -} |
| 27 | +# } |
| 28 | +# } |
29 | 29 |
|
30 | | -hasData <- function(has_data = .pkgenv$has_data) { |
| 30 | +# hasData <- function(has_data = .pkgenv$has_data) { |
31 | 31 |
|
32 | | - if (!has_data) { |
| 32 | +# if (!has_data) { |
33 | 33 |
|
34 | | - message <- paste("This function requires the 'RandomFields' or 'RandomFieldsUtil'", |
35 | | - "packages which are not available on CRAN anymore. To install them,", |
36 | | - "please run 'install.packages('RandomFields',", |
37 | | - "repos = 'https://predictiveecology.r-universe.dev', type = 'source')'.") |
| 34 | +# message <- paste("This function requires the 'RandomFields' or 'RandomFieldsUtil'", |
| 35 | +# "packages which are not available on CRAN anymore. To install them,", |
| 36 | +# "please run 'install.packages('RandomFields',", |
| 37 | +# "repos = 'https://predictiveecology.r-universe.dev', type = 'source')'.") |
38 | 38 |
|
39 | | - message <- paste(strwrap(message), collapse = "\n") |
| 39 | +# message <- paste(strwrap(message), collapse = "\n") |
40 | 40 |
|
41 | | - stop(message, call. = FALSE) |
42 | | - } |
43 | | -} |
| 41 | +# stop(message, call. = FALSE) |
| 42 | +# } |
| 43 | +# } |
0 commit comments