The wonderful people at Gilt are having me teach an introductory course on R this Friday.
The class starts with the very basics such as variable types, vectors, data.frames and matrices. After that we explore munging data with aggregate, plyr and reshape2. Once the data is prepared we will use ggplot2 to visualize it and then fit models using lm, glm and decision trees.
Most of the material comes from my upcoming book R for Everyone.
Participants are encouraged to bring computers so they can code along with the live examples. They should also have R and RStudio preinstalled.
While playing Words with Friends my randomly chosen opponent played “radiale” as her first word. Since that used up all of her tiles, she received a bonus on top of all the points the word itself got, resulting in a one-move score of 53 points! Rather than being impressed I was upset at the large deficit I would have to overcome.
To combat this I did what comes naturally: Write an R script to find the perfect word!
Needing to combine my seven letters with one of her letters there were two routes I could take. The first would be for each combination of my seven letters and one of hers, find all 40,320 (8!) permutations then hit dictionary.com to see if it is a real word for a total of 282,240 (8!*7) http calls. That seemed a bit excessive and impractical so I moved on to the next idea.
So, first thing I did was pull a list of common eight-letter words. Then for each combination of my letters and one of hers (only 7 iterations) I checked if those letters (in any order) matched the letters in any of the possible words. Once a match was found there was a check for the counts of the letters and if that passed then the word was recorded as a true match.
The algorithm took about 17 seconds to run and found me one possible word for my letters combined with one of hers: “headrace”, for 63 points! Perhaps I should have been able to figure that out on my own, but where would be the fun in that. Find the code after the break.