Continuous color causes error when x or y is factor
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When I try to take color from numeric variable and one of the axes is factor, it raises error Error in Summary.factor(...) : ‘range’ not meaningful for factors:
data(mpg)
mpg$classF <- as.factor(mpg$class)
# error when x is factor AND color is numeric:
mpg %>%
plot_ly(x = ~classF, y = ~cyl, color = ~displ) %>%
add_markers()
# Error in Summary.factor(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, :
# ‘range’ not meaningful for factors
# works fine when x is character:
mpg %>%
plot_ly(x = ~class, y = ~cyl, color = ~displ) %>%
add_markers()
# also works fine if color is factor or character:
mpg %>%
plot_ly(x = ~classF, y = ~cyl, color = ~as.character(displ)) %>%
add_markers()
Contributor guide
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 by running the supplied mpg examples in an R session to reproduce the factor-axis and numeric-color failure. Trace the color handling that calls range on factor data; done means the failing example works without error while the character-axis and factor-or-character-color cases continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100