Advice on reproducible map_coloring?
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 43
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I was wondering whether it is possible to have a replicable output with map_coloring, i.e. that is constant across calls? This is particularly useful when one is trying to use testhat snapshots.
I realize that setting minimize=TRUE avoids the call to sample(), so that is already a workaround. Should one want more colors than the strict minimum, the output seems to change each time. Do you see an easy way to add maybe a seed argument?
Thanks!
library(tmaptools)
packageVersion("tmap")
#> [1] '3.3.2'
packageVersion("tmaptools")
#> [1] '3.1.1'
library(tmap)
data(World)
color <- map_coloring(World, palette="Pastel2")
color2 <- map_coloring(World, palette="Pastel2")
all.equal(color, color2)
#> [1] "152 string mismatches"
color <- map_coloring(World, palette="Pastel2", minimize=TRUE)
color2 <- map_coloring(World, palette="Pastel2", minimize=TRUE)
all.equal(color, color2)
#> [1] TRUE
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the map_coloring entry point and reproduce the two examples in the issue, including the testhat snapshot use case. Investigate how sampling affects non-minimized output and determine the expected behavior for a seed argument or another reproducibility mechanism. Done means repeated calls can produce comparable output when reproducibility is requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100