wordpress and leaflet

239 views
Skip to first unread message

Jarrett Byrnes

unread,
Apr 2, 2015, 8:35:32 AM4/2/15
to kn...@googlegroups.com
Lately, I've been doing some work with RStudio's Leaflet library, which is awesome. I've wanted to post this work to wordpress, but using knit2wp has yielded...odd results. Does anyone have experience with getting knitted docs into wordpress with leaflet, threejs, or other R-javascript packages?

Yihui Xie

unread,
Apr 2, 2015, 10:46:19 AM4/2/15
to Jarrett Byrnes, knitr
That is expected. HTML widgets are not only about the HTML output, but
more importantly, the dependencies that they carry. For example,
Leaflet requires leaflet.js/leaflet.css/... The rmarkdown and shiny
packages are smart enough to figure out these dependencies and insert
them into the HTML head. For WordPress, authors normally don't have
write access to the HTML head at the time of publishing a blog post.
If you are the site admin, you can probably change your template files
to include these dependencies in the head.

Other options include: 1) publish these widgets separately to
RPubs.com or ShinyApps.io; 2) use R Markdown v2 to write blog posts
instead of WordPress.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Web: http://yihui.name

Jarrett Byrnes

unread,
Apr 2, 2015, 6:36:37 PM4/2/15
to kn...@googlegroups.com, jarrett...@gmail.com
Hrm. OK, I see how you can embed with iFrames. I guess two questions, then, to go for the extra mile.

1) I'm unclear what you mean by using R Markdown v2 to write the blog post. That is what I'm doing (I have done that for a while - and then just used knit2wp to post)

2) If I did want to just stick with WP and publish using knit2wp - as it's so delightfully convenient (sorry, you made something awesome!) could I put a set of headers into my WP template (it's my install - long running blog, so I don't want to move to another platform)

Feel free to send me to an obvious tutorial I've missed via bad google-fu.

Yihui Xie

unread,
Apr 2, 2015, 10:29:35 PM4/2/15
to Jarrett Byrnes, knitr
1. I mean building the entire website based on R Markdown like
http://rmarkdown.rstudio.com, which does not seem to be an option for
you.

2. Yes, if it is your own install. It is a bit complicated to tell you
clearly which js/css files are required, but you can take a look at
the HTML source of http://rstudio.github.io/leaflet/

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Web: http://yihui.name


> --
> You received this message because you are subscribed to the Google Groups
> "knitr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to knitr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages