Web Hosted R Syntax Highlighter

March 24, 2013
By

(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, 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...

Comments are closed.