Web Hosted R Syntax Highlighter

R-bloggers 2013-03-24

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

highlight uses simple jquery command to syntax highlight R code contained in any regular <pre> element.

For example, this chunk of code, from the datasets::cars help file.

require(stats); require(graphics)
plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)",
     las = 1)
lines(lowess(cars$speed, cars$dist, f = 2/3, iter = 3), col = "red")
title(main = "cars data")
plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)",
     las = 1, log = "xy")
title(main = "cars data (logarithmic scales)")

More details is given at highlight’s page on how to use it on your own page.

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

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,ecdf, trading) and more...