tidyverse / tidyverse/ggplot2

label_bquote turns numeric values into factors (?) when as.table = FALSE in facet_grid

Open
#6,864 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

facets :gem:
Dominant language
R
Stars
7k
Forks
2.1k
Avg merge
59m
Merged PRs (30d)
2

Description

I found a problem with label_bquote. I was trying to use an expression show the value of a parameter in the facet labels and I found that when I used as.table = FALSE the values of the rows were instead turned into integers. I am guessing this is because the values were first turned into factors and then faceted, but I am not sure.

Here is the code to reproduce the bug:

library(tidyverse)

expand_grid(a = c(0.15, 0.85),
            b = c(0.001, 0.0025, 0.005), 
            x = rnorm(10), 
            y = rnorm(10)) %>% 
ggplot(., aes(x,y)) + 
  geom_point() + 
  facet_grid(a ~ b, 
             as.table = F, # <- works when this is TRUE
             labeller = label_bquote(rows = alpha==.(a), 
                                     cols = beta==.(b)))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproducible R example with ggplot2, facet_grid(), as.table = FALSE, and label_bquote(). Trace how row values are transformed while facet labels are built, then check the related labelling and faceting tests. Done means numeric row values such as 0.15 and 0.85 remain correctly represented in the labels when as.table is FALSE.

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
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.