Skip to content

geom_sf : error when using comma as decimal separator #3365

Closed
@dicorynia

Description

@dicorynia

Hi.

There is an error when plotting a map of a sf object if the decimal separator is set to the comma in R options.

library(tidyverse)
library(sf)

nc <- st_read(system.file("shape/nc.shp", package = "sf"))

# works fine
ggplot() +
  geom_sf(data = nc)

# raises an error
 options(OutDec = ",")
 ggplot() +
   geom_sf(data = nc)

#>Error in parse(text = text[[i]]) : <text>:1:3: unexpected ','
#>1: 34,
      ^
traceback
traceback()
#>15: parse(text = text[[i]])
#>14: parse_safe(graticule$degree_label[needs_parsing])
#>13: f(..., self = self)
#>12: self$fixup_graticule_labels(graticule, scale_x, scale_y, params)
#>11: f(..., self = self)
#>10: self$coord$setup_panel_params(scale_x, scale_y, params = self$coord_params)
#>9: (function (scale_x, scale_y) 
#>   {
#>       self$coord$setup_panel_params(scale_x, scale_y, params = self$coord_params)
#>   })(dots[[1L]][[1L]], dots[[2L]][[1L]])
#>8: mapply(FUN = f, ..., SIMPLIFY = FALSE)
#>7: Map(setup_panel_params, scales_x, scales_y)
#>6: f(..., self = self)
#>5: layout$setup_panel_params()
#>4: ggplot_build.ggplot(x)
#>3: ggplot_build(x)
#>2: print.ggplot(x)
#>1: (function (x, ...) 
#>   UseMethod("print"))(x)

As a workaround we can revert to the dot decimal separator before the plot...

session info ``` sessionInfo() #> R version 3.6.0 (2019-04-26) #> Platform: x86_64-w64-mingw32/x64 (64-bit) #> Running under: Windows 7 x64 (build 7601) Service Pack 1 #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 #> [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C #> [5] LC_TIME=French_France.1252 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] sf_0.7-4 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.1 #> [5] purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.2 #> [9] ggplot2_3.1.1 tidyverse_1.2.1 #> #> loaded via a namespace (and not attached): #> [1] tidyselect_0.2.5 xfun_0.7 haven_2.1.0 #> [4] lattice_0.20-38 colorspace_1.4-1 generics_0.0.2 #> [7] htmltools_0.3.6 yaml_2.2.0 rlang_0.3.4 #> [10] e1071_1.7-1 pillar_1.4.1 glue_1.3.1 #> [13] withr_2.1.2 DBI_1.0.0 modelr_0.1.4 #> [16] readxl_1.3.1 plyr_1.8.4 munsell_0.5.0 #> [19] gtable_0.3.0 cellranger_1.1.0 rvest_0.3.4 #> [22] evaluate_0.14 knitr_1.23 class_7.3-15 #> [25] highr_0.8 broom_0.5.2 Rcpp_1.0.1 #> [28] KernSmooth_2.23-15 scales_1.0.0 backports_1.1.4 #> [31] classInt_0.3-3 jsonlite_1.6 hms_0.4.2 #> [34] digest_0.6.19 stringi_1.4.3 grid_3.6.0 #> [37] cli_1.1.0 tools_3.6.0 magrittr_1.5 #> [40] lazyeval_0.2.2 crayon_1.3.4 pkgconfig_2.0.2 #> [43] xml2_1.2.0 lubridate_1.7.4 assertthat_0.2.1 #> [46] rmarkdown_1.13 httr_1.4.0 R6_2.4.0 #> [49] units_0.6-3 nlme_3.1-139 compiler_3.6.0 ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorcoord 🗺️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions