vtree
vtree copied to clipboard
Error in rsvg_format
I think this may be a bug I just discovered the other day. Does one of your variables have an apostrophe (') in one of its values? For example:
x <- data.frame(thing=c("Do","Don't"))
vtree(x,"thing")
When you knit this, vtree tries to produce an SVG file, but it runs into a problem. I will try to fix this.
For now, if this is the problem, try replacing the apostrophe with a back tick (`), for example:
x <- data.frame(thing=c("Do","Don`t"))
vtree(x,"thing")
If this is a different problem, please could you give me more details?
Thank you very much for your quick response. Indeed, the issue was originated from an accent mark that I was specifying on one of the labels. Hope you can debug this issue, for the moment I will try with a back thick as you suggest for that accent mark.
Regards
I may have fixed the problem. If you install the latest development version, you can try it. But first, you will need to install the utf8 package from CRAN. After doing that, install the development version using this command:
remotes::install_github("nbarrowman/[email protected]",build_vignettes=TRUE)
I tested it like this:
d <- data.frame(words=c("más vale maña","que fuerza"))
vtree(d,"words")
Hi @nbarrowman! Thank you very much for your assistance. Despite that now is possible to get mark accents on the plots, it seems that still a bug when I try to knit it.
It is important to stress that I have the utf8 package updated from the CRAN and the tree package from the command that you provided me.
Thanks for letting me know. I’ll take another look at it.
If you are knitting to HTML, try setting pngknit=FALSE
when you call vtree. (By default vtree generates a PNG file that is embedded in the HTML, which has some advantages. But it seems that the rsvg package cannot handle UTF8 characters properly. Setting pngknit=FALSE
embeds htmlwidgets rather than PNG.)
One further note: it works fine (without having to set pngknit=FALSE
) when running R on a Mac. This suggests that the problem may be with the Windows version of the librsvg2 library used by the R package rsvg. I will post an issue on the github project for rsvg.