Code Highlighter for R in WordPress

First of all, welcome to my blog! I will write posts about trading, quantitative and algorithmic trading, programming and everything else what is on my mind. Feel free to comment and give suggestions how to improve this blog. Thank you!

Well, one of the first issues I was facing was: How to nicely highlight R (and other programming language) source code in my posts. After few minutes of googling I found this blog post. The plugin named WP-CodeBox does the job! It's easy to use and works fine even in WordPress 3.1.

The question mark in upper right corner was linking to irrelevant webpage so I decided to remove it. Open main.php file and comment row number 90:

1
$output .= "<sup><a href=\"http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples\" target=\"_blank\" title=\"WP-CodeBox HowTo?\"><span style=\"color: #99cc00\">?</span></a></sup>";

 

This little trick will remove the annoying question mark. OK.. now let's go back to usage of the plugin. All you have to do is to add:

<pre lang="RSPLUS"></pre>

to your post and place your code inside the tags. That's all.. simple, yet powerful.

 

1
2
3
4
5
6
7
8
9
10
rm(list = ls(all = TRUE))
 
library(quantmod)
library(tseries)
library(timeDate)
 
symbols &lt;- read.csv("/home/robo/workspace/R-Test/sp500.csv", header = F, stringsAsFactors = F)
nrStocks = length(symbols[,1])
dateStart = "2008-01-01"
z <- zoo()

Tags: , ,

  1. QuantTrader’s avatar

    Hi Tom,

    thank you for your comment and visit! I am sure you will like the upcoming posts. Your blog looks pretty interesting, too.

    Reply

  2. Tom Ott’s avatar

    Hi Quanttrader,
    Just discovered your blog via an R aggregator. It looks like you got some interesting posts alright, looking forward to reading them and keep 'em coming!

    Reply

  3. Tal Galili’s avatar

    Congrats on the new blog.

    1) Consider removing the auto comment.
    2) Consider adding the subscribe to comments plugin
    3) once you have several more R posts, consider adding your blog to http://www.r-bloggers.com/add-your-blog/ to gain more readers (but I strongly encourage you to do so only after you've got more R content...)

    Good luck :)
    Tal

    Reply

    1. admin’s avatar

      Hi Tal,

      thank you for your comment and suggestions. I will definitely look into it and after few more R blog posts will add this blog to r-bloggers (I'm follower and enjoy the posts already :) ).

      Reply

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.