dieghernan / tidyterra

tidyverse and ggplot2 methods for terra spatial objects

Home Page:https://dieghernan.github.io/tidyterra/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Startup message when including tidyterra in other package

schonhose opened this issue · comments

Hi,

I have written a package that uses the tidyterra package. Whenever I load my package, tidyterra displays a startup message. I have not found any way to solve this using the default methods, based on the current code to show the message.

However, from my understanding it works when the message is shown using packageStartupMessage(), commonly located in a file named zzz.R inside the R folder.

The only other way I can think of is to set the variable to not show the message and then load the package manually while my own package is attached. However, that would defeat the purpose, as it will introduce another thing I always need to check ;-)

Hi,

Is that package public so I can have a look to your source code? Thanks in advance

Also, please note that after tidyterra 0.3.0 the messages produced by the package changed, so now the only message you would see (I presume) is:

library(tidyterra)

#> Attaching package: 'tidyterra'
#> The following object is masked from 'package:stats':
#> 
#>  filter

This is unavoidable due to filter.SpatRaster method created on tidyterra, however it does not necessarily pop up on your package. It would depend on how you are using tidyterra on your package;

  • If tidyterra is listed on your DESCRIPTION file under Depends it would pop-up, however Depends is discouraged by CRAN (use Imports instead)
  • If you are importing tidyterra on your NAMESPACE (i.e. import(tidyterra)) it would pop up as well. Recommended approach is to use tidyterra::geom_spatraster() instead on your source code.

Having access to your source code woul help me to understand better the issue.

Hi,

With tidyterra (>= 0.3.0) I don't see any startup message related with tidyterra, can you please recheck if there is still an issue on your side?

# remotes::install_github("rivm-syso/me2tools")

library(me2tools)
#> Welcome to ME2tools version 0.1.0.
#> 
#> ✔ rnaturalearth
#> ✔ rnaturalearthdata
#> ✔ rnaturalearthhires
#> 
#> ♥ Happy Source Apportioning ♥
#> 
#> Turn this message off using 'suppressPackageStartupMessages(library(me2tools))'

# Read the MetCor grid file
metcor_grid <- metcor_import(file = system.file("extdata",
  "metcor_example.txt",
  package = "me2tools"
))

# Create the first plot
metcor_plot(metcor.raster = metcor_grid)
#> - processing options
#> - preparing world map
#> - raster is used for mid point calculation, based on coordinate
#>               distribution peaks
#>    - setting automatic xlim
#>    - setting automatic ylim
#> - creating legend labels based on the break values
#> - applying display smoothing to raster
#> - preparing raster for plotting
#> - creating the plot
#> - applying legend breaks and colors
#> SpatRaster resampled to ncells = 501260
#> - adding scale bar
#> - applying theme
#> Done!

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31 ucrt)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Spanish_Spain.utf8
#>  ctype    Spanish_Spain.utf8
#>  tz       Europe/Paris
#>  date     2022-12-25
#>  pandoc   2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package           * version  date (UTC) lib source
#>    assertthat          0.2.1    2019-03-21 [1] CRAN (R 4.2.0)
#>    bit                 4.0.5    2022-11-15 [1] CRAN (R 4.2.2)
#>    bit64               4.0.5    2020-08-30 [1] CRAN (R 4.2.0)
#>    cellranger          1.1.0    2016-07-27 [1] CRAN (R 4.2.0)
#>    class               7.3-20   2022-01-16 [2] CRAN (R 4.2.2)
#>    classInt            0.4-8    2022-09-29 [1] CRAN (R 4.2.1)
#>    cli                 3.5.0    2022-12-20 [1] CRAN (R 4.2.2)
#>    cluster             2.1.4    2022-08-22 [1] CRAN (R 4.2.1)
#>    codetools           0.2-18   2020-11-04 [2] CRAN (R 4.2.2)
#>    colorspace          2.0-3    2022-02-21 [1] CRAN (R 4.2.1)
#>    commonmark          1.8.1    2022-10-14 [1] CRAN (R 4.2.1)
#>    crayon              1.5.2    2022-09-29 [1] CRAN (R 4.2.1)
#>    data.table          1.14.6   2022-11-16 [1] CRAN (R 4.2.2)
#>    DBI                 1.1.3    2022-06-18 [1] CRAN (R 4.2.1)
#>    deldir              1.0-6    2021-10-23 [1] CRAN (R 4.2.0)
#>    dichromat           2.0-0.1  2022-05-02 [1] CRAN (R 4.2.0)
#>    digest              0.6.31   2022-12-11 [1] CRAN (R 4.2.2)
#>    dplyr               1.0.10   2022-09-01 [1] CRAN (R 4.2.2)
#>    e1071               1.7-12   2022-10-24 [1] CRAN (R 4.2.2)
#>    ellipsis            0.3.2    2021-04-29 [1] CRAN (R 4.2.0)
#>    evaluate            0.19     2022-12-13 [1] CRAN (R 4.2.2)
#>  D fansi               1.0.3    2022-03-24 [1] CRAN (R 4.2.0)
#>    farver              2.1.1    2022-07-06 [1] CRAN (R 4.2.1)
#>    fastmap             1.1.0    2021-01-25 [1] CRAN (R 4.2.0)
#>    fs                  1.5.2    2021-12-08 [1] CRAN (R 4.2.0)
#>    generics            0.1.3    2022-07-05 [1] CRAN (R 4.2.1)
#>    ggnewscale          0.4.8    2022-10-06 [1] CRAN (R 4.2.1)
#>    ggplot2             3.4.0    2022-11-04 [1] CRAN (R 4.2.2)
#>    ggspatial           1.1.7    2022-11-24 [1] CRAN (R 4.2.2)
#>    ggtext              0.1.2    2022-09-16 [1] CRAN (R 4.2.2)
#>  D glue                1.6.2    2022-02-24 [1] CRAN (R 4.2.0)
#>    gridtext            0.1.5    2022-09-16 [1] CRAN (R 4.2.2)
#>    gtable              0.3.1    2022-09-01 [1] CRAN (R 4.2.1)
#>    hexbin              1.28.2   2021-01-08 [1] CRAN (R 4.2.1)
#>    highr               0.10     2022-12-22 [1] CRAN (R 4.2.2)
#>    hms                 1.1.2    2022-08-19 [1] CRAN (R 4.2.1)
#>    htmltools           0.5.4    2022-12-07 [1] CRAN (R 4.2.2)
#>    interp              1.1-3    2022-07-13 [1] CRAN (R 4.2.2)
#>    jpeg                0.1-10   2022-11-29 [1] CRAN (R 4.2.2)
#>    KernSmooth          2.23-20  2021-05-03 [2] CRAN (R 4.2.2)
#>    knitr               1.41     2022-11-18 [1] CRAN (R 4.2.2)
#>    lattice             0.20-45  2021-09-22 [2] CRAN (R 4.2.2)
#>    latticeExtra        0.6-30   2022-07-04 [1] CRAN (R 4.2.2)
#>    lifecycle           1.0.3    2022-10-07 [1] CRAN (R 4.2.1)
#>    lubridate           1.9.0    2022-11-06 [1] CRAN (R 4.2.1)
#>  D magrittr            2.0.3    2022-03-30 [1] CRAN (R 4.2.0)
#>    mapproj             1.2.9    2022-10-30 [1] CRAN (R 4.2.2)
#>    maps                3.4.1    2022-10-30 [1] CRAN (R 4.2.2)
#>    markdown            1.4      2022-11-16 [1] CRAN (R 4.2.2)
#>    MASS                7.3-58.1 2022-08-03 [1] CRAN (R 4.2.1)
#>    Matrix              1.5-3    2022-11-11 [1] CRAN (R 4.2.2)
#>    me2tools          * 0.1.0    2022-12-25 [1] Github (rivm-syso/me2tools@c6de880)
#>    mgcv                1.8-41   2022-10-21 [2] CRAN (R 4.2.2)
#>    munsell             0.5.0    2018-06-12 [1] CRAN (R 4.2.0)
#>    nlme                3.1-161  2022-12-15 [1] CRAN (R 4.2.2)
#>    openair             2.12     2022-11-08 [1] CRAN (R 4.2.2)
#>    pals                1.7      2021-04-17 [1] CRAN (R 4.2.2)
#>    pillar              1.8.1    2022-08-19 [1] CRAN (R 4.2.1)
#>    pkgconfig           2.0.3    2019-09-22 [1] CRAN (R 4.2.0)
#>    png                 0.1-8    2022-11-29 [1] CRAN (R 4.2.2)
#>    proxy               0.4-27   2022-06-09 [1] CRAN (R 4.2.0)
#>    purrr               1.0.0    2022-12-20 [1] CRAN (R 4.2.2)
#>    R.cache             0.16.0   2022-07-21 [1] CRAN (R 4.2.1)
#>    R.methodsS3         1.8.2    2022-06-13 [1] CRAN (R 4.2.0)
#>    R.oo                1.25.0   2022-06-12 [1] CRAN (R 4.2.0)
#>    R.utils             2.12.2   2022-11-11 [1] CRAN (R 4.2.2)
#>    R6                  2.5.1    2021-08-19 [1] CRAN (R 4.2.0)
#>    raster              3.6-11   2022-11-28 [1] CRAN (R 4.2.2)
#>    RColorBrewer        1.1-3    2022-04-03 [1] CRAN (R 4.2.0)
#>    Rcpp                1.0.9    2022-07-08 [1] CRAN (R 4.2.1)
#>    readr               2.1.3    2022-10-01 [1] CRAN (R 4.2.1)
#>    readxl              1.4.1    2022-08-17 [1] CRAN (R 4.2.1)
#>    reprex              2.0.2    2022-08-17 [1] CRAN (R 4.2.1)
#>    rlang               1.0.6    2022-09-24 [1] CRAN (R 4.2.1)
#>    rmarkdown           2.19     2022-12-15 [1] CRAN (R 4.2.2)
#>    rnaturalearth       0.1.0    2017-03-21 [1] CRAN (R 4.2.0)
#>    rnaturalearthdata   0.1.0    2017-02-21 [1] CRAN (R 4.2.1)
#>    rstudioapi          0.14     2022-08-22 [1] CRAN (R 4.2.1)
#>    scales              1.2.1    2022-08-20 [1] CRAN (R 4.2.1)
#>    sessioninfo         1.2.2    2021-12-06 [1] CRAN (R 4.2.0)
#>    sf                  1.0-9    2022-11-08 [1] CRAN (R 4.2.2)
#>    sp                  1.5-1    2022-11-07 [1] CRAN (R 4.2.2)
#>    stringi             1.7.8    2022-07-11 [1] CRAN (R 4.2.1)
#>    stringr             1.5.0    2022-12-02 [1] CRAN (R 4.2.2)
#>    styler              1.8.1    2022-11-07 [1] CRAN (R 4.2.2)
#>    terra               1.6-47   2022-12-02 [1] CRAN (R 4.2.2)
#>    tibble              3.1.8    2022-07-22 [1] CRAN (R 4.2.1)
#>    tidyr               1.2.1    2022-09-08 [1] CRAN (R 4.2.1)
#>    tidyselect          1.2.0    2022-10-10 [1] CRAN (R 4.2.1)
#>    tidyterra           0.3.1    2022-11-09 [1] CRAN (R 4.2.2)
#>    timechange          0.1.1    2022-11-04 [1] CRAN (R 4.2.2)
#>    tzdb                0.3.0    2022-03-28 [1] CRAN (R 4.2.1)
#>    units               0.8-1    2022-12-10 [1] CRAN (R 4.2.2)
#>    utf8                1.2.2    2021-07-24 [1] CRAN (R 4.2.0)
#>    vctrs               0.5.1    2022-11-16 [1] CRAN (R 4.2.2)
#>    vroom               1.6.0    2022-09-30 [1] CRAN (R 4.2.1)
#>    withr               2.5.0    2022-03-03 [1] CRAN (R 4.2.1)
#>    xfun                0.36     2022-12-21 [1] CRAN (R 4.2.2)
#>    xml2                1.3.3    2021-11-30 [1] CRAN (R 4.2.0)
#>    yaml                2.3.6    2022-10-18 [1] CRAN (R 4.2.1)
#> 
#>  [1] C:/Users/diego/AppData/Local/R/win-library/4.2
#>  [2] C:/Program Files/R/R-4.2.2/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2022-12-25 with reprex v2.0.2

Thanks for your swift response, it seems that I still have an old version of tidyterra. Thanks for checking and your response.