Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I saw this great post on crayola crayon colors at the Learning R blog, reproducing a nice graph of the Crayola crayon colors over time. (Also see this even nicer version.)
The Learning R post shows how to grab the crayon colors from the wikipedia page, “List of Crayola crayon colors,” directly in R. Here’s the code (after some slight modifications due to changes in the page since 2010):
library(XML) theurl <- "http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors" crayontable <- readHTMLTable(html, stringsAsFactors = FALSE)[[1]] crayons <- crayontable[,grep("Hex", colnames(crayontable))] names(crayons) <- crayontable[,"Color"]
Comparing these to what I’d grabbed, I noted one small discrepancy on the Wikipedia page: Yellow Orange was listed as "#FFAE42"
but the background color for the Yellow Orange cell in the table was "#FFB653"
.
So I created a Wikipedia account and edited the Wikipedia page.
(Then I realized that I’d made a mistake in my edit, undid my change, thought the whole thing through again, and edited the page again.)
The Learning R post also showed a different way to sort the colors: convert to HSV, and then sort by the H then S then V. So I edited my plot_crayons()
function again, to create the following picture:
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.