Create blog posts from RStudio to WordPress
来源:互联网 发布:ecshop大京东2.5源码 编辑:程序博客网 时间:2024/05/01 11:43
In a couple of courses I’ve used RPubs and GitHub for publishing my R code and work. As I have a own website withWordPress I want to blog from R to my own blog instead only through sharing R code via RPubs and GitHub. After searching over the internet I find some usefull stuff to do this. So let’s try it myself en let this be my first blog post created from Rstudio to WordPress.
Setting up WordPress and R
What do we need for wordpress:
- Crayon Syntax Highlighter plugin for highlighting R code in a blog post.
- WP QuickLaTeX for nice math rendering using syntax.
And in R we need:
- knitr, a website is coded in HTML,
knitr
can convert your R code from a R Markdown file to HTML code, this package is already installed with RStudio. - RWordPress allows publish blog posts from R to WordPress.
Load the necessary packages in R
Setting options for RWordPess
Syntax highlighting with Crayon Syntax Highlighter
To make syntax highlighting work in WordPress with the Crayon Syntax Highlighter plugin. R code should be enclosed in WordPress-shortcode instead of the knitr html output default
to
We can’t do that with the default knitr2wp function of knitr. knitr2wp
is only based on the syntax which is used forSyntaxHighlighter. I don’t want to update all my other code on my blog.
For the Crayon Syntax Highlighter I’ve found a request of allowing proper code highlight when using Crayon. Below the copied requested function for using it to post a blog to my WordPress site with Crayon Syntax Highlighter as code highlighter.
After adding the function into R we can post our first blog on WordPress and that would be this one :).
Publishing the post to your blog
Note: Below code should run directly from the R shell (first create the above function and load the RWordPress library) after the R Markdown has created and has runs once. It will post a lots same drafts and ends with a error. I cannot figure out why, I think there is a loop and it wants to post itself to your blog. If you want to upload it run it directly from the R shell with the upload option to TRUE
.
I set the publish option to FALSE
, so the post will stay in draft mode and I can fine tune some formats, tags, set a featured image and add on the top the shortcode for using syntax.
This code can also be find on my GitHub.
- Create blog posts from RStudio to WordPress
- Publish blog posts from R + knitr to WordPress
- Write Posts With Rstudio, Rmarkdown Format And Publish Directly To Wordpress With Knitr & Rwordpress
- Mapping WordPress Posts to Elasticsearch
- After 486 blog posts
- How to Create a WordPress WXR File
- How to create HBITMAP from WICBitmapSource
- How to create a server from scratch
- How to create Magento invoice from order
- Unable to create envelope from given source:
- Unable to create project from archetype
- Unable to create project from archetype
- wordpress博客 pages和posts之间不同点
- wordpress中强大的query posts 用法
- Tranfer my blog from smth to here
- Move blog from 51testing to cdsn
- great tips for write blog(/posts).
- Confluence 博客页面(Blog Posts)宏
- 《一个勺子》观后感
- OpenCV实践之路——画出时钟并动态同步系统时间
- vim+python+OpenCV学习四 : 像素通道分割
- Pots(bfs恶心的宽搜)
- HDU 4803 Poor Warehouse Keeper(贪心)
- Create blog posts from RStudio to WordPress
- ifconfig配置网络时,出现“SIOCSIFADDR: No such device”和“eth0:ERROR while getting interface flags:No such dev”
- ajax原理和XmlHttpRequest对象
- 准备1千万个随机数字,保存到文件并顺序读取
- 数组溢出与指针问题
- 从两段代码中理解JavaScript的单线程和异步
- Java中数字格式化问题
- Android Studio 报:AndroidManifest.xml (系统找不到指定的路径。) 错误
- hdu1019(快排&&欧几里得)