When I read in a file I couldn't work out why two similar character variables were printing differently using tibble - one with quotation marks and the other one without. After a bit of digging, I noticed that one contained trailing white space and the other one didn't.
Is white space the only reason why a character variable would be printed with quotation marks? I can't see any reference to this behaviour on the tibble site.
Example:
library(tidyverse)
df <- tibble(a = c("hjhjh", "popopo"), d = c(1, 2))
df
# # A tibble: 2 x 2
# a d
# <chr> <dbl>
# 1 hjhjh 1
# 2 popopo 2
df_with_space <- tibble(a = c("hjhjh ", "popopo"), d = c(1, 2))
df_with_space
#quotation marks:
# # A tibble: 2 x 2
# a d
# <chr> <dbl>
# 1 "hjhjh " 1
# 2 "popopo" 2
tibble uses pillar for printing options, compare:
> pillar::pillar("abc")
<pillar>
<chr>
abc
> pillar::pillar(" def")
<pillar>
<chr>
" def"
As of tibble 3.1.0, printing is handled entirely by the pillar package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With