Problem (possibly) related to tibble printing and pandoc

reprex
pandoc
#1

The code below cannot be reprex()ed (doesn't raise error, but waits forever) on my Windows (using the dev versions of tibble, pillar, locale is Japanese_Japan.932), but I cannot find the cause so far. It's really wierd that if I repeat bundle_column() 3 times or 5 times, it succeeds. But, if 4 times, it won't.

Does this succeeds on other OS?

bundle_column <- function(data, ..., .key = "data") {
  key_var <- rlang::as_string(rlang::ensym(.key))
  
  bundle_vars <- unname(tidyselect::vars_select(names(data), ...))
  group_vars <- setdiff(names(data), bundle_vars)

  out <- dplyr::select(data, !!! rlang::syms(group_vars))
  out[[key_var]] <- dplyr::select(data, !!! rlang::syms(bundle_vars))
  out
}

library(dplyr, warn.conflicts = FALSE)

iris <- tibble::as_tibble(iris)

# If the repetition is 3 times or 5 times, it succeeds. But, 4 won't...
bundle_column(iris, -Species)
bundle_column(iris, -Species)
bundle_column(iris, -Species)
bundle_column(iris, -Species)

If I use the bare data.frame, this succeeds. So I guess this is basically a problem from somewhere in between tibble and pandoc. Do you know similar kind of issues?

Backtrace:
    x
 1. \-reprex::reprex()
 2.   \-rmarkdown::render(...)
 3.     \-rmarkdown:::convert(output_file, run_citeproc)
 4.       \-rmarkdown::pandoc_convert(...)
0 Likes

#2

I'm not getting any issues when running this multiple times - have you tried using debug() or similar to try and diagnose which part of the function might be causing issues?

1 Like

#3

Thanks for the information. Are you using macOS or Linux? I guess this happens only on Windows (probably something related to encoding).

0 Likes

#4

I'm on windows 10 also and the reprex renders normally, but lately it has been some issues with pandoc on windows systems with custom input methods, this is probably your case since you are using japanese.

1 Like

#5

Sorry, I should have specified: I'm also on Windows, although my locale is English_United States.1252 and not Japanese.

1 Like

#6

Thanks, you really helped me!

I thought this was a problem of Windows, but your answers indicated it was not. Actually, it seems some Pandoc's bug. I found this because you suggested

have you tried using debug()

and, by debugging rmarkdown::pandoc_convert(), I saw it hanged here, which actually executes pandoc command by system().

Then, I guessed, if this was a pandoc's bug, this would be solved if I updated RStudio. Actually, I could render the reprex on the latest preview version of RStudio (v1.2.1244, pandoc version: 2.5). So, it seems something was wrong with the pandoc I used (pandoc version: 2.1.3, bundled in RStudio v1.2.1114).

Thanks again for your help!

1 Like

#7

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

0 Likes

#8

I did :slight_smile:

0 Likes

closed #9

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.

0 Likes