Publishing R markdown files as blog post

纵饮孤独 提交于 2021-02-06 14:55:52

问题


I want to publish a basic blog post like this: (Example blog post) using my R markdown files.

But I want to publish it in Wordpress (not wordpress.com).

  • The most promising solution seems to be Yihui's function. I tried that but got many errors and stop trying. I'm using Windows and it seems like Yihui's knit2wp function works stable at Linux. (I deduct this from one of the comments in his page)
  • Following posts did not help as well: this, this.
  • I tried to publish my markdown in GitHub like (this) as mentioned in Jerom Anglim's blog post (very informative blog post BTW). Can't figure out how to embed the GitHub file into Wordpress.
  • I considered moving my whole blog to Jekyll as one very good example, but it seemed very daunting to change the whole blog structure.

None of the solutions worked for me. I give up. Copying and pasting code and formatting are very inefficient. I cannot align my r output properly.
Is there any other way that I did not stumble upon and possibly solve (or ease) my problem?
Thanks in advance for any response.


回答1:


Have you tried "Pretty R syntax highlighter" (http://www.inside-r.org/pretty-r/tool)? It might be a nice temporary fix until you get something else working.

This code:

y <- 1:10
plot(y)

gets turned into this:

`<div style="overflow:auto;"><div class="geshifilter"><pre class="r geshifilter-R" style="font-family:monospace;">y <span style="">&lt;-</span> <span style="color: #cc66cc;">1</span><span style="">:</span><span style="color: #cc66cc;">10</span>
<a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span></pre></div></div><p><a href="http://www.inside-r.org/pretty-r" title="Created by Pretty R at inside-R.org">Created by Pretty R at inside-R.org</a></p>`

which, when imbedded in your html, displays like this:

y <- 1:10

plot(y)

Created by Pretty R at inside-R.org



来源:https://stackoverflow.com/questions/17057118/publishing-r-markdown-files-as-blog-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!