trelliscopejs doesn't work with blogdown
I try to post a blog with trelliscopejs staff using yihui blogdown package. But I get this error.
library(ggplot2)
library(trelliscopejs)
library(gapminder)
# Create the plot
ggplot(gapminder, aes(year, lifeExp)) +
geom_line() +
# Facet on country and continent
facet_trelliscope(~ country + continent)
#> using data from the first layer
#> Error in if (!grepl("^[A-Za-z0-9_]", orig_path)) stop_nice("Path for trelliscope output while inside knitr must be relative."): 参数长度为零
Created on 2018-10-20 by the reprex package (v0.2.0).
I find trelliscopejs works in one Ryan Hafen‘s blog.
I haven't yet migrated to blogdown, but it's probably similar. You need to do facet_trelliscope(..., path = "some_relative_path"). Another alternative is to publish your display somewhere (github pages, netlify, etc.) and then stick it in an iframe in your post.
Hi @hafen , Thank you for your sugguestion, it works for me, and I will show the solution here.
- specify the path to output the trelliscope files you can find.
- copy it in the blogdown's folder and drop it in the
static- this soluton is to deploy others html files on the blog, you can find the source on the Yihui's online book (Xie 2018; Mastny 2018).
- run
blogdown:::serve_site(), deploy it and you can access atyouweburl/yourtrelliscopefilespath.
Reference
Mastny, Tim. 2018. “Embed Slides in Your Blog.” https://timmastny.rbind.io/blog/embed-slides-knitr-blogdown/.
Xie, Yihui. 2018. “Adding R Markdown Documents of Other Output Formats.” https://blogdown-demo.rbind.io/2017/09/06/adding-r-markdown-documents-of-other-output-formats/.