Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings generated when saving the non-wear plot of a data whose filename has special characters #2

Closed
verasls opened this issue Jan 20, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@verasls
Copy link
Owner

verasls commented Jan 20, 2022

remove_nonwear() generates warnings when you try to save the non-wear plot into a file and the filename attribute of the impactr_data object has some special characters.

This is due to the fact that the pdf device opened to save the plot does not support some special characters and then throws the warning when it fails to convert them.

library(impactr)

# install_accdata()
d <- import_dataset("daily_acc_3d")
# Make the data smaller to the code run faster
d <- define_region(
  d,
  start_time = "2016-01-20 00:01:00",
  end_time = "2016-01-20 23:59:59"
)
# Force the filename to have some special characters
attributes(d)$filename <- "Sáv"
invisible(remove_nonwear(d, save_plot = tempfile(fileext = ".pdf")))
#> Warning in title(...): conversion failure on 'Sáv' in 'mbcsToSbcs': dot
#> substituted for <cc>
#> Warning in title(...): conversion failure on 'Sáv' in 'mbcsToSbcs': dot
#> substituted for <81>
#> Warning in title(...): conversion failure on 'Sáv' in 'mbcsToSbcs': dot
#> substituted for <cc>
#> Warning in title(...): conversion failure on 'Sáv' in 'mbcsToSbcs': dot
#> substituted for <81>

Created on 2022-01-20 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.2 (2021-11-01)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_GB.UTF-8                 
#>  ctype    en_GB.UTF-8                 
#>  tz       Europe/Lisbon               
#>  date     2022-01-20                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  accdata       0.1.0   2022-01-14 [1] local         
#>  backports     1.2.1   2020-12-09 [1] CRAN (R 4.1.0)
#>  cli           3.1.0   2021-10-27 [1] CRAN (R 4.1.0)
#>  crayon        1.4.2   2021-10-29 [1] CRAN (R 4.1.0)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.0)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.0)
#>  generics      0.1.1   2021-10-25 [1] CRAN (R 4.1.1)
#>  glue          1.6.0   2021-12-17 [1] CRAN (R 4.1.0)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.0)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.0)
#>  impactr     * 0.4.0   2022-01-16 [1] CRAN (R 4.1.2)
#>  knitr         1.36    2021-09-29 [1] CRAN (R 4.1.0)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.0)
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.0)
#>  lvmisc        0.1.1   2021-04-05 [1] CRAN (R 4.1.0)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.1.0)
#>  pillar        1.6.4   2021-10-18 [1] CRAN (R 4.1.0)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.0)
#>  Rcpp          1.0.7   2021-07-07 [1] CRAN (R 4.1.0)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.0)
#>  rlang         0.4.12  2021-10-18 [1] CRAN (R 4.1.0)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.0)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.0)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.0)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.0)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.0)
#>  styler        1.5.1   2021-07-13 [1] CRAN (R 4.1.0)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.0)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.0)
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.0)
#>  xfun          0.27    2021-10-18 [1] CRAN (R 4.1.0)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
@verasls verasls added the bug Something isn't working label Jan 20, 2022
@verasls verasls reopened this Jan 21, 2022
@verasls
Copy link
Owner Author

verasls commented Jan 21, 2022

Reopening this issue, reverting the commit that closed it (f0e68b8).

The previous choice to solve the issue was to replace the graphics device from grDevices::pdf() to grDevices::cairo_pdf(). However, the use of Cairo graphics on macOS depends on the installation of a X11 window sytem (like XQuartz). The absence of this installation caused an R CMD check failure on GH Actions (see link).

Also, this solution would require the {impactr} package user on macOS to install X11 if it's not previously installed, placing an unecessary burden on the user.

Another solution, therefore, needs to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant