Skip to main content

Posts

Showing posts with the label Ruby

Aspirational & Useful: deck.rb with RStudio/knitr & Go2Shell

There has been some interest in the recent release of RStudio 0.96 and especially the ability to use combine its knitr Markdown functionality with Pandoc to integrate R and a variety of different documents types. I just wanted to add two quick things (one mostly aspirational, the other useful) Aspirational: Markdown/Ruby/deck.js I am currently using this combination to put together a presentation based on a recent working paper . Maybe out of procrastination I decided to see if there was any way to use knitr /Markdown to write a deck.js presentation. I generally prefer deck.js to the three Pandoc HTML presentation types ( slidy , S5 , and dzslides ). Deck.js presentations are a pain to write, so it would be great if there was a program like Pandoc that could quickly convert a Markdown file into a deck.js presentation. I discovered that there kind of is. There is a ruby program called deck.rb . The Markdown syntax is really simple and would be familiar to Pandoc users (...

Scrappy Scapers

In an earlier post I presented some R  code for a basic way of collecting text from websites. This is a good place to start for collecting text for use in text analysis.  However, it clearly has some limitations;  You need to have all of the URLs already stored in a .csv file. The method of extracting the text from the downloaded HTML code using <gsub> is a bit imprecise. It doesn't remove the text from common links such as "Home" or "About". Both of these problems can be solved in R  with a bit of work. But I think for bigger scrapping projects it is probably a good idea to use other languages such as Python or Ruby .  ProPublica has an excellent little series on scraping  that covers how to gather data from online databases and PDFs. This is a really good public service and enables something sadly unusual in journalism: reproducibility. Their  chapter on using Ruby and Nokogiri for scraping the Phizer's doctor payments disclos...