Publish blog posts from R + knitr to WordPress
2017-03-14 11:16
183 查看
The RWordPress package allows one to publish blog posts from R to WordPress (see the
create such a fragment from R Markdown with the markdown package. Below is how to do this with the function
Basically you set your login name and password as well as the url of the WordPress server (path to
are a WordPress.com user, you may want to use the
details.
How to upload images? There are a few possibilities. One is to upload
images to Imgur, and another is to save images to your Dropbox folder, e.g.
I created a folder named
to the image URL’s, and generate images in the Dropbox folder. To get the URL of a file in the Public folder, just right-click on it and copy the link from the menu.
Note you can write and preview the draft in RStudio until you are comfortable to publish it. Once it is published, it is not straightforward to modify it (although you can), and that is why you, as a cool hacker, should blog with Jekyll instead of WordPress.
It is always easy to deal with plain text files. Once you have got PHP, MySQL, password, plugins, … things get complicated quickly.
If you have your own server, I recommend you not to use the
e.g. you can add this to your WordPress template:
I thank William K. Morris for his early experiment with knitr and WordPress. The
blog post. I also tested it here.
newPost()function in the package). A blog post is essentially an HTML fragment, and knitr can
create such a fragment from R Markdown with the markdown package. Below is how to do this with the function
knit2wp()in knitr:
if (!require('RWordPress')) { devtools::install_github(c("duncantl/XMLRPC", "duncantl/RWordPress")) } library(RWordPress) options(WordpressLogin = c(user = 'password'), WordpressURL = 'https://user.wordpress.com/xmlrpc.php') library(knitr) knit2wp('yourfile.Rmd', title = 'Your post title')
Basically you set your login name and password as well as the url of the WordPress server (path to
xmlrpc.php), so that RWordPress can send the post to the server. If you
are a WordPress.com user, you may want to use the
shortcodeoption, i.e.
knit2wp(..., shortcode = TRUE). See
?knit2wpfor
details.
How to upload images? There are a few possibilities. One is to upload
images to Imgur, and another is to save images to your Dropbox folder, e.g.
opts_knit$set(base.url = 'https://dl.dropbox.com/u/15335397/wp/', base.dir = 'path/to/Dropbox/Public/wp/')
I created a folder named
wpunder the
Publicfolder, and the above code tells knitr to add a prefix
to the image URL’s, and generate images in the Dropbox folder. To get the URL of a file in the Public folder, just right-click on it and copy the link from the menu.
Note you can write and preview the draft in RStudio until you are comfortable to publish it. Once it is published, it is not straightforward to modify it (although you can), and that is why you, as a cool hacker, should blog with Jekyll instead of WordPress.
It is always easy to deal with plain text files. Once you have got PHP, MySQL, password, plugins, … things get complicated quickly.
If you have your own server, I recommend you not to use the
shortcodeoption, and you should consider much nicer alternative options for syntax highlighting such as highlight.js,
e.g. you can add this to your WordPress template:
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/default.min.css"> <script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script> <script src="http://yandex.st/highlightjs/7.3/languages/r.min.js"></script> <script>hljs.initHighlightingOnLoad();</script>
I thank William K. Morris for his early experiment with knitr and WordPress. The
knit2wp()function was based on his
blog post. I also tested it here.
相关文章推荐
- Create blog posts from RStudio to WordPress
- How to publish blog to csdn from onenote
- Comma separated list of emails to send new blog posts to
- The BlogSpot subdomain under which to publish your blog
- Publish Web Site To IIS From VS
- Mapping WordPress Posts to Elasticsearch
- How to convert from string to datetime in sql server? - Sealyu - BlogJava
- Configuring Visual Studio to Debug .NET Framework Source Code【from Shawn Burke's Blog】
- Tranfer my blog from smth to here
- 黄聪:最新版wordpress出现:require(wp-blog-header.php) [function.require]: failed to open stream……的解决办法
- moving from my private domain name to blog in csdn.net
- 博客搬家 from csdn to cnblog
- A new approach to China. (copy from goolge official blog)
- Implementing a java agent to instrument code (copy from http://chimpler.wordpress.com/2013/11/05/implementing-a-java-agent-to-instrument-code/)
- 使用LINQ to SQL 第一部分--ScottGu's Blog Posts--Using LINQ to SQL (Part 1)
- How to Get Rid of /wordpress/ From your WordPress Site URL
- The type of feed to provide for blog posts
- How to get bean from tag component
- Passing Array From Javascript To PHP in Joomla!1.5