embed R leaflet map in wordpress embed R leaflet map in wordpress wordpress wordpress

embed R leaflet map in wordpress


U can try to save the widget to a .html file and import this .html file to your media library.

library(htmlwidgets) library(DT) a <- datatable(iris) saveWidget(a, "datatable-iris-example.html")

Next, import the .html file to your media library. Then, add the shortcode to your post. Here's how to encode it in the page when editing the blog post:

<iframe seamless src="http://www.phillipburger.net/wordpress/wp-content/uploads/2015/05/datatable-iris-example.html" width="100%" height="500"></iframe>

All credits go to Phillip Burger and his post.

Anyone got a better method?


I have not qa tested this but... my logic is use the raw HTML widget and add a simple php include line. kinda like this

<h3>My aweseome R map</h3><?php include 'saved_file.html';?>

The concept comes from Static Content CMS concepts where you import so to speak existing pieces.


Steps:

1) Install the plugin which allows embedding extra File Extensions, and check .html in that plugin's options page.

2) now try to upload .html file in WP.

3) embed the uploaded file as <iframe> element, or use plugins like : include-me or include-url or simple-include