<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>R-statistics blog &#187; emac</title>
	<atom:link href="http://www.r-statistics.com/tag/emac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.r-statistics.com</link>
	<description>Writing about statistics with R, and open source stuff (software, data, community)</description>
	<lastBuildDate>Mon, 30 Jan 2012 07:45:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Highlight the R syntax on your (WordPress) blog using the wp-syntax plugin</title>
		<link>http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/</link>
		<comments>http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 09:48:38 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[emac]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[highlight package]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[R blogger]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R blogging]]></category>
		<category><![CDATA[syntax highlight]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[wp-syntax]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=119</guid>
		<description><![CDATA[Update (11.10.10): I found a better solution for R syntax highlighting then the one presented in this post. The plugin is called WP-CodeBox, and I wrote about it on the post &#8211; WP-CodeBox: A better R syntax highlighter plugin for WordPress Download link for WP-Syntax plugin (with GeSHi version 1.0.8.6) In case you have a [...]]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/&amp;layout=box_count&amp;show_faces=false&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/"></g:plusone></div></div><table border="1">
<tr>
<td>
<strong>Update (11.10.10):</strong> I found a better solution for R syntax highlighting then the one presented in this post.  The plugin is called WP-CodeBox, and I wrote about it on the post &#8211; <a href="http://www.r-statistics.com/2010/10/wp-codebox-a-better-r-syntax-highlighter-plugin-for-wordpress/">WP-CodeBox: A better R syntax highlighter plugin for WordPress</a>
</td>
</tr>
</table>
<table border="1">
<tr>
<td>
<strong><a href="http://www.r-statistics.com/wp-content/uploads/2010/02/wp-syntax-0.9.8-GeShi-1.0.8.6.zip">Download link for WP-Syntax plugin (with GeSHi version 1.0.8.6)</a></strong>
</td>
</tr>
</table>
<p>In case you have a <a href="http://wordpress.org/">self hosted WordPress blog</a>, and you wish to show your R code in it, how would you do it?</p>
<p>The simplest solution would be to just paste the code as plain text, which will look like this:</p>
<blockquote><p>x &lt;- rnorm(100, mean = 2, sd = 3)<br />
plot(x, xlab = &#8220;index&#8221;, main = &#8220;Example code&#8221;)</p></blockquote>
<p>But if you would like to help our readers orient themselves inside your code by giving different colors to different commands in the code (a.k.a: syntax highlighting). So it would like something like this:</p>

<div class="wp_codebox"><table><tr id="p1192"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p119code2"><pre class="rsplus" style="font-family:monospace;">x <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">rnorm</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">mean</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">2</span>, <span style="color: #0000FF; font-weight: bold;">sd</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># Creating a vector</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>x, xlab <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;index&quot;</span>, main <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Example code&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># Plotting it</span></pre></td></tr></table></div>

<p>How then would you do it?</p>
<h3>Plugin Installation</h3>
<p>The easiest way to do this inside a <a href="http://wordpress.org/">self hosted WordPress </a>blog is by<a href="http://codex.wordpress.org/Managing_Plugins#Installing_Plugins"> installing a plugin</a> called <a href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a>:</p>
<blockquote><p>WP-Syntax provides clean syntax highlighting using GeSHi &#8212; supporting a wide range of popular languages (including R). It supports highlighting with or without line numbers and maintains formatting while copying snippets of code from the browser.</p></blockquote>
<p>But there is<strong> a problem</strong>. The current WP-Syntax version is using an old version of GeSHi, and only the newer version (currently GeSHi version 1.0.8.6) includes support for R syntax. In order to <strong>solve this</strong> I patched the plugin and I encourage you to <strong><a href="http://www.r-statistics.com/wp-content/uploads/2010/02/wp-syntax-0.9.8-GeShi-1.0.8.6.zip">download (the fixed version of) WP-Syntax from here</a></strong>, which will allow you to highlight your R code.</p>
<h3>Usage</h3>
<p>After installing (and activating) the plugin, in order to add R code to your post you will need to:<br />
1) Only work in HTML mode (not the Visual mode). Or else, the code you will paste will be messed up.<br />
2) Put your code between the &lt;pre&gt; tag, like this:</p>
<p>(Note: make sure that you rewrite the &#8221; &#8211; so it will work.)</p>
<blockquote><div id="_mcePaste">&lt;pre lang=&#8221;rsplus&#8221; line=&#8221;1&#8243;&gt;</div>
<div id="_mcePaste">&#8230;Your R code here&#8230;</div>
<div id="_mcePaste">&lt;/pre&gt;</div>
</blockquote>
<h3>Final note: R Syntax highlight in other ways</h3>
<p>If you wish to have R syntax higlight inside an HTML file, I encourage you can have a look at the <a href="http://romainfrancois.blog.free.fr/index.php?post/2009/11/22/new-R-package-:-highlight">highlight package</a>, by Romain Francois.</p>
<p>If you want to higlight your R syntax inside <a href="http://wordpress.com">wordpress.com</a>, here is <a href="http://blogisticreflections.wordpress.com/2009/09/20/welcome-to-blogistic-reflections/">a blog post</a> by Erik Iverson showing how to do that using Emacs.</p>
<p><strong>p.s: If you have a blog in which you write about R, please let me know about it in the comments (Or just <a href="http://www.r-bloggers.com/add-your-blog/">join R-bloggers.com</a>) &#8211; I&#8217;d love to follow you <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </strong></p>
<p><strong>Update: </strong> Stephen Turner wrote about <a href="http://gettinggeneticsdone.blogspot.com/2010/09/embed-rstats-code-with-syntax.html">a syntax highlighting solution for R and blogger using github gist</a>.  And also mentioned there another solution for self hosted wordpress blogs, via  <a href="http://www.cerebralmastication.com/">J.D. Long</a>: a <a href="http://www.entropytheblog.com/blog/2008/12/wordpress-github-gist-shortcode-plugin/">Github Gist plugin for WordPress</a>.  Go publish code <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

