Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glimpse confuses factors with commas in levels #384

alistaire47 opened this issue Feb 9, 2018 · 3 comments

glimpse confuses factors with commas in levels #384

alistaire47 opened this issue Feb 9, 2018 · 3 comments


Copy link

alistaire47 commented Feb 9, 2018

I suspect it's a rare case, but because glimpse doesn't quote factors like it does strings, if the factor level has a comma in it, it looks like they're two observations, e.g.


    tibble(x = factor(c('foo, bar', 'baz')),
           y = factor(c('hello, world', 'howdy'), ordered = TRUE),
           z = c('foo, bar', 'baz'))
#> Observations: 2
#> Variables: 3
#> $ x <fct> foo, bar, baz
#> $ y <ord> hello, world, howdy
#> $ z <chr> "foo, bar", "baz"

The evident solution would be to quote levels. Factors would be less differentiable from strings, though no worse than integers that happen to be stored as doubles, e.g. mtcars$gear.

Copy link

anhqle commented Feb 28, 2018

@krlmlr what's your take on quoting factor levels (i.e. with "level")? Or perhaps quote using backticks?

Copy link

krlmlr commented Mar 1, 2018

I think we should use regular quotes here.

anhqle pushed a commit to anhqle/tibble that referenced this issue Apr 24, 2018
Currently, if factor levels have commas, glimpse looks like .
By adding quotes, we make it clear that there are two factor levels, not 3, i.e.
@krlmlr krlmlr closed this as completed in 5d541d1 May 23, 2018
krlmlr added a commit that referenced this issue May 23, 2018
- `glimpse()` disambiguates outputs for factors if the levels contain commas (#384, @anhqle).
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

No branches or pull requests

3 participants