R syntax highlighting for bloggers on WordPress.com

September 20, 2010
By

(This article was first published on R-statistics blog, and kindly contributed to R-bloggers)

Good news for href="http://r-bloggers.com/"> R bloggers who are using href="http://wordpress.com/">WordPress.com to host their blog.

This week, the good people running WordPress.com (special thanks goes to href="http://blog.yoavfarhi.com/">Yoav Farhi), have added the ability for all the users of the WordPress.com platform to be able to highlight their R code inside posts.

Basically you’ll need to wrap the code in your post like this:

test.function = function(r) {
    return(pi * r^2)
}
test.function(1)

(Which will then look like this: /> src="http://www.r-bloggers.com/wp-content/uploads/2010/09/5008201283_e4e81e9e0c.jpg" alt="r syntax highlighted code example" /> /> )

Further details (and other supported languages) can be read about href="http://en.support.wordpress.com/code/posting-source-code/">on this WordPress.com support page.

This new feature was possible thanks to the work of href="http://yihui.name/en">Yihui Xie (who create href="http://yihui.name/en/2010/07/my-talk-on-animations-at-user-2010/">the datetime="2010-09-20T19:14:44+00:00">famous cool animation package for R), who created a href="http://yihui.name/en/2010/09/syntaxhighlighter-brush-for-the-r-language/">R syntax brush for the syntaxhighlighter WordPress plugin (the plugin used by WordPress.com for sytnax highlighting) hands>. And thanks should also go to href="http://r.andrewredd.us/">Andrew Redd, the creator of href="http://r.andrewredd.us/?p=7">NppToR (which connects between notepad++ to R). He both made some good suggestions, and was game to take on the brush creation in case there would be problems, which thankfully so far there aren’t any)

p.s: If you are a WordPress.org users (e.g: have a self hosted WordPress blog) and want to enable R syntax highlighting for your blog, I would recommend the use of the href="http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/">WP-Syntax plugin (enhanced with GeSHi version 1.0.8.6) which can be href="http://www.r-bloggers.com/wp-content/uploads/2010/09/wp-syntax-0.9.8-GeShi-1.0.8.6.zip">downloaded here.

To leave a comment for the author, please follow the link and comment on his blog: R-statistics blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , , , ,

Comments are closed.