documentation for tibble/pillar quoting of 'hidden' spaces in character variables

For teaching purposes, I'm trying to track down any explicit documentation about how tibble/pillar/colformat makes strings with leading or trailing spaces evident through quotes. I love the feature, btw.

I found this issue by Noam Ross, but so far nothing in the documentation or vignettes about how or why this was incorporated.

Any leads?

its implemented through pillar_shaft.character method

function (x, ..., min_width = NULL) 
  x <- utf8::utf8_encode(x)
  out <- x
  needs_quotes <- which(is_ambiguous_string(x))
  if (has_length(needs_quotes)) {
    out[needs_quotes] <- gsub("\"", "\\\"", x[needs_quotes], 
      fixed = TRUE)
    out[!] <- paste0(style_subtle("\""), out[!], 
    na_indent <- 1


I suppose you may be enquiring mostly about pillar:::is_ambiguous_string

function (x) 
    ! & grepl("^$|^ | $|\\\\|\"", x)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

This is exactly what I was looking for.

Do you know if this is stated explicitly in a function's help, or if 'ambiguous strings' are defined somewhere?
(defined verbally and not just through a regexp)