forked from tidyverse/ggplot2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace parse() with parse_safe() in geom_text() (tidyverse#2867)
Closes issue tidyverse#2864 * use parse_safe() in geom_text() The built in `parse()` function silently drops items: length(parse(text = c("alpha", "", "gamma"))) We expect the length to be 3, but instead it is 2. So, we add a new function `parse_safe()` that keeps all items. * update parse_safe() Use Hadley's code to parse the expressions once instead of twice. Use `parse(..., keep.source = FALSE)`, as Claus recommended. Add an example to demonstrate why `parse_safe()` is needed. * add tests for parse_safe() * add note about parse(text = NULL) * use parse_safe() in sf.R This patch fixes an example that triggers an error: library(ggplot2) nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) ggplot(nc) + geom_sf(aes(fill = AREA)) + scale_y_continuous( breaks = c(34, 35, 36), labels = c("34*degree*N", "", "36*degree*N") ) #> Error in parse(text = x)[[1]]: subscript out of bounds See tidyverse#2867 for more details. * move parse_safe() tests to test-utilities.r * change parse_safe(text = x) to parse_safe(x) * modify comment for parse_safe() add URL to GitHub issue tidyverse#2864 * fix parsing degree labels in geom_sf() * add news item about parse_safe() * fix typo * move parse() into fixup_graticule_labels() * change description of parse_safe() * modify news item about parse_safe() * add stopifnot() to parse_safe() * simplify parsing code in sf.R * improve news item about parse_safe() * do not test parse_safe(factor(...)) `parse_safe()` takes a character vector, not a factor
- Loading branch information
1 parent
6e545dc
commit 3f93180
Showing
6 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters