This article describes how to add an interactive R visualization to a blog in under 30 seconds.
This particular example doesn't represent anything, but the purpose of my post here is just to show the technology. The total time to set this visualization up and include it on this blog was about 30 seconds.
Requirements
A Displayr document.
Method
Eight steps to include your interactive R visualization in a blog
Step 1: Open this example in Displayr.
Step 2: From the toolbar, select Calculation > Custom Code.
Step 3: Drag the cursor on the page to create an output, and paste your R CODE into Displayr or the code I used is below and click Calculate. If you do not have this prepared, it will take a lot longer than 30 seconds. 😉 A good place to start looking for examples is www.htmlwidgets.org. If you want to use a package that is not in Displayr, just send us an email on support@displayr.com, and we typically add it in a few days.
library(networkD3)
data(MisLinks, MisNodes)
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
Group = "group", opacity = 0.4)
Step 4: With the object still selected, from the toolbar, go to Publish > Embed Object > Code Snippet.
Step 5: Review any warnings and click Snapshot and View.
Step 6: Copy the HTML snippet (i.e., <script src=…) and click Done.
Step 7: Insert the HTML snippet into your blog page. For example, to do this in WordPress, just click on the Text tab and paste the code in.
Step 8: Publish your blog!
Next
How to Embed Outputs in Web Pages