Closed raffaelevacca closed 1 year ago
As far as I can tell print.egor()
uses a deprecated way of printing tibbles. I'm looking into fixing it.
Thank you @mbojan! Printing works well now.
@mbojan the ANSI code style string for coloring "active" in green in print.egor()
output is giving me problems when rendering to pdf an Rmarkdown with egor print output. It's the \033[32m
and \033[39m
part in this line:
https://github.com/tilltnet/egor/blob/e5980a565c7805bfc59b7151668b75b36c5a96ef/R/egor.R#L337
When rendering Rmarkdown to pdf for some reason those strings create an invalid character that Latex can't render to pdf regardless of the latex engine (pdflatex, xelatex or lualatex). The result is the Rmd can't be rendered to pdf due to invalid character error (Text line contains an invalid character
). It's similar to the issue described here, except no latex engine works: https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
Can I remove that part (\033[32m
and \033[39m
) i.e. remove the green coloring from print.egor()
output? Or do you want to look into that first? Note there is no green coloring of "active" in the tidygraph
print output.
Reproducible:
---
title: "Test"
output:
pdf_document:
latex_engine: xelatex
date: '2022-12-05'
editor_options:
chunk_output_type: console
---
```{r}
library(tidyverse)
library(egor)
# Create egor
e1 <- egor(alters = alters32,
egos = egos32,
aaties = aaties32,
ID.vars = list(
ego = ".EGOID",
alter = ".ALTID",
source = ".SRCID",
target = ".TGTID"))
# Print egor
e1
# Note no green coloring in tidygraph print output
library(tidygraph)
as_igraph(e1) |>
pluck(1) |>
as_tbl_graph()
I'll be happy to get rid of it all together, but it's a baby of @tilltnet ;) imho we need to either do some sort of output-specifc-printing (i don't remember how pillar does it) or get rid of it.
@tilltnet what do you think? Do you see any other solution (other than getting rid of it) to avoid that error when rendering to pdf?
Also note that the \033 character is disregarded and green coloring is not rendered in htlm, see for example the egor vignette: https://cran.r-project.org/web/packages/egor/vignettes/using_egor.html#base-r
If we want to keep the coloring, the cli package could be used for colored print output. crayon is deprecated but works.
@mbojan Yes, please go ahead and remove the coloring or feel free to look into how to do it with cli
or crayon
. Thank you so much either way for looking into this!
I removed the coloring string for now (b6155ca), it's easy to put it back in if needed, or we can look into other coloring solutions. That should probably be a separate issue though, so I'm closing this issue. Pdf rendering works now, thank you @mbojan and @tilltnet.
When printing an egor object no data head is displayed, just NULL. This happens even though the egor object can be correctly analyzed. It seems to happen for any egor object, including those created in the main egor vignette.
Reproducible:
Print output in my console:
Session info: