August 20, 2010
Well, that was easy.
#!/usr/bin/ruby
require "rubygems"
require "mongo"
require "json/pure"
require "open-uri"
db = Mongo::Connection.new.db('citeulike')
col = db.collection('articles')
j = JSON.parse(open("http://www.citeulike.org/json/user/neils").read)
j.each do |article|
article[:_id] = article['article_id']
col.save(article)
end
Posted in programming, ruby |
2 Comments »
August 20, 2010
At any R Q&A site, you’ll frequently see an exchange like this one:
Q: How can I use a loop to [...insert task here...] ?
A: Don’t. Use one of the apply functions.
So, what are these wondrous apply functions and how do they work? I think the best way to figure out anything in R is to learn by experimentation, using embarrassingly trivial data and functions.
Read the rest…
Posted in computing, R, statistics |
9 Comments »