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

Development version of units seems to fail with spaces in labels #297

Closed
bart1 opened this issue Jan 19, 2022 · 4 comments · Fixed by #298
Closed

Development version of units seems to fail with spaces in labels #297

bart1 opened this issue Jan 19, 2022 · 4 comments · Fixed by #298
Labels

Comments

@bart1
Copy link
Contributor

bart1 commented Jan 19, 2022

I was working with the development version the package. I seem to get error when i introduce spaces in labels, for both make_unit_label and plot and with ggplot. Either something is messed up in my system or it would be quite an annoying bug

require(units)
#> Loading required package: units
#> udunits database from /usr/share/xml/udunits/udunits2.xml
make_unit_label('s df',set_units(3,'Hz'))
#> Error in parse(text = str): <text>:1:3: unexpected symbol
#> 1: s df
#>       ^
d<-data.frame(a=set_units(1:5,'m'),b=set_units(5:1,'Hz')) 
plot(d$a, d$b, xlab='sd df')
#> Error in parse(text = str): <text>:1:4: unexpected symbol
#> 1: sd df
#>        ^
require(ggplot2)
#> Loading required package: ggplot2
ggplot(d, aes(a,b))+geom_point()+xlab('sa df')
#> Error in parse(text = str): <text>:1:4: unexpected symbol
#> 1: sa df
#>        ^
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=nl_NL.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=nl_NL.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=nl_NL.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_3.3.5 units_0.8-0  
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.8        pillar_1.6.4      compiler_4.1.2    highr_0.9        
#>  [5] R.methodsS3_1.8.1 R.utils_2.11.0    tools_4.1.2       digest_0.6.29    
#>  [9] evaluate_0.14     lifecycle_1.0.1   tibble_3.1.6      gtable_0.3.0     
#> [13] R.cache_0.15.0    pkgconfig_2.0.3   rlang_0.4.12      reprex_2.0.1     
#> [17] DBI_1.1.2         yaml_2.2.1        xfun_0.28         fastmap_1.1.0    
#> [21] dplyr_1.0.7       withr_2.4.3       styler_1.6.2      stringr_1.4.0    
#> [25] knitr_1.36        generics_0.1.1    fs_1.5.1          vctrs_0.3.8      
#> [29] tidyselect_1.1.1  grid_4.1.2        glue_1.6.0        R6_2.5.1         
#> [33] fansi_1.0.2       rmarkdown_2.11    farver_2.1.0      purrr_0.3.4      
#> [37] magrittr_2.0.1    backports_1.4.0   scales_1.1.1      ellipsis_0.3.2   
#> [41] htmltools_0.5.2   assertthat_0.2.1  colorspace_2.0-2  labeling_0.4.2   
#> [45] utf8_1.2.2        stringi_1.7.6     munsell_0.5.0     crayon_1.4.2     
#> [49] R.oo_1.24.0

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

@Enchufa2 Enchufa2 added the bug label Jan 20, 2022
@Enchufa2
Copy link
Member

Thanks for spotting this.

  • make_unit_label has not been touched since... years now, so it's the same behaviour as in most (all?) previous versions,
  • which means that this issue was present already in ggforce, because I just copied their implementation.
  • In base plot, the issue is new, certainly, because I copied also the usage that ggforce made of make_unit_label there.

In other words, it's probably make_unit_label what needs to be fixed, because apparently the usage is not clear. :)

@bart1
Copy link
Contributor Author

bart1 commented Jan 20, 2022

@Enchufa2 Thanks for having a look I originally encountered the issue in ggforce indeed but then started testing and traced it down to make_unit_label.

@Enchufa2
Copy link
Member

@bart1 Could you please install the branch in #298 and test it a bit?

@bart1
Copy link
Contributor Author

bart1 commented Jan 20, 2022

@Enchufa2 thanks for the quick solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants