Add shape.name to tm_shape #129
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Martijn,
First off, thank you so much for such an excellent package. I had been trying to migrate from ggplot to leaflet, but there was so much missing functionality, that I had begun to loose hope in being able to reproduce an interactive version of my work. The tmap package has been a great boon.
I wanted to plot several attributes on the same map and allow the user to use the legend to turn on and off layers as appropriate. An attribute to override the name of the shp object seems to solve the problem nicely. I must apologize in advance; I've never submitted a pull request before, so I could be going about this the entirely wrong way.
Cheers,
John
Code proposed (not sure my pull request will work)
tm_shape <- function(shp,
shape.name = NULL,
is.master = NA,
projection=NULL,
bbox = NULL,
unit = getOption("tmap.unit"),
simplify = 1,
line.center.type = c("segment", "midpoint"),
...) {
shp_name <- ifelse(is.null(shape.name) == TRUE, deparse(substitute(shp))[1], shape.name)
g <- list(tm_shape=c(as.list(environment()), list(...)))
class(g) <- "tmap"
g
}