Project Euler: problem 2

September 16, 2011
By
Project Euler: problem 2

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the terms in the Fibonacci sequence whose values do not exc...

Read more »

How Lloyd’s of London uses R for Insurance

September 15, 2011
By
How Lloyd’s of London uses R for Insurance

Lloyd's is the world's leading specialist insurance market, and is often the first to insure new, unusual or complex risks. So it's no surprise that Lloyd's is one of the many companies that use R and its advanced capabilities for data analysis to help manage its insurance risks. At the useR! conference last month, Lloyd's analysts Markus Gesmann, Viren...

Read more »

Using Google Spreadsheets with R: an update

September 15, 2011
By

Prompted by a rush of visitors from Andrew Gelman's blog, I went back and updated the details of my post from 2009 on reading data from Google Spreadsheets into R. Since then, Google had switched to using a secure (https) connection for Google Docs, which required some tweaks to the code. If you haven't seen it before, it's a...

Read more »

Correlations among US Stocks: Is it really time to fire your adviser?

September 15, 2011
By
Correlations among US Stocks: Is it really time to fire your adviser?

Note: This post is NOT financial advice!  This is just a fun way to explore some of the capabilities R has for importing and manipulating data. The Financial Times says it's time to "Fire your Adviser" because correlations among US stocks ar...

Read more »

Reporting Good Enough to Share

September 15, 2011
By
Reporting Good Enough to Share

Sorry to all my faithful readers for my absence recently. I started a new job at a new firm, so my blogging has moved down the priority list but only temporarily. I am still committed to documenting my thoughts, especially finance and R thoughts as dis...

Read more »

littler 0.1.4

September 15, 2011
By

Matthias Klose, the tireless force behind the Debian / Ubuntu gcc, python, and what have you packages, sent me a minimal patch to let littler build when the ld linker uses the --as-needed option (as Ubuntu builds now do): all it took was a little reor...

Read more »

Project Euler: problem 1

September 15, 2011
By
Project Euler: problem 1

To be fairly honest (assuming there are degrees of honesty), I do know a little about math and programming but I don't know much math or any programming. I've loved math for a long time, but started to learn and understand fairly recently. So during th...

Read more »

Recent Updates in the aqp (Algorithms for Quantitative Pedology) Package for R

September 14, 2011
By

New version of our 'aqp' package for quantitative soils investigations, available on CRAN (version 0.99-5) and R-Forge (0.99-8). Some of the major changes are listed below: -------------------------- aqp 0.99-8 (2011-09-14) -------------------------- ...

Read more »

R Fork Bomb

September 14, 2011
By
R Fork Bomb

So maybe I’m a strange guy, but I think fork bombs are really funny.  What’s a fork bomb?  The basic premise is that you spawn a process that spawns a process that spawns a process…, ad infinitum. The most beautiful example of a fork bomb, and really one of the most beautiful lines of code

Read more »

Shortest paths to/from nodes of a certain type

September 14, 2011
By
Shortest paths to/from nodes of a certain type

Elijah asked the following via SOCNET mailing list: I was wondering if anyone knew of a script or tool which would give me the network distance of nodes to a particular class of nodes.  I think of this as an Erdos number, except instead of getting the distance to one node, I want the distance

Read more »

Revolution Analytics Fall Webinar Series

September 14, 2011
By

We've lined up what we think is an amazing series of R-related webinars over the next couple of months. These free 30-60 minute webinars will cover a wide range of topics: big-data analysis in R with the RevoScaleR package, Hadoop and Netezza; introductions to R for SAS users and for R users new to Revolution R; and applications of...

Read more »

Example 9.5: New stuff in SAS 9.3– proc FMM

September 13, 2011
By
Example 9.5: New stuff in SAS 9.3– proc FMM

Finite mixture models (FMMs) can be used in settings where some unmeasured classification separates the observed data into groups with different exposure/outcome relationships. One familiar example of this is a zero-inflated model, where some observat...

Read more »

How to program MapReduce jobs in Hadoop with R

September 13, 2011
By

MapReduce is a powerful programming framework for efficiently processing very large amounts of data stored in the Hadoop distributed filesystem. But while several programming frameworks for Hadoop exist, few are tuned to the needs of data analysts who typically work in the R environment as opposed to general-purpose languages like Java. That's why the dev team at Revolution Analytics...

Read more »

More sas7bdat progress

September 13, 2011
By

The development version of the read.sas7bdat function (in the sas7bdat package) now reads field labels and formats. In addition, errors of the type "found <x> <type> subheaders where 1 expected" are now a thing of the past. These improvements are largely due to work by Clint Cummins. The function also works on some files generated

Read more »

Backtesting a Simple Stock Trading Strategy

September 13, 2011
By
Backtesting a Simple Stock Trading Strategy

Note: This post is NOT financial advice!  This is just a fun way to explore some of the capabilities R has for importing and manipulating data.   I recently read a post on ETF Prophet that explored an interesting stock trading strategy in Ex...

Read more »

Speed up recursion in R 600-fold with Rcpp

September 12, 2011
By

Rcpp package co-author Dirk Eddelbuettel provides another case study in speeding up R code by rewriting repeatedly-called R code as inline C++ functions, using the classic Fibonacci recursion algorithm as an example. The speed gains here are impressive -- over 600x compared to native recursive R code -- but you could also improve performance by using a more efficient,...

Read more »

Why you should care about reproducible research

September 12, 2011
By

This week's Economist has an in-depth article on the consequences of failures reproducible research, adding more detail to the report in the New York Times in July. Errors in data analysis by researchers at Duke University led to patients in clinical trials being assigned the wrong drug: Dr Potti and his colleagues had mislabelled the cell lines they used...

Read more »

Testing and significance

September 12, 2011
By
Testing and significance

Julien Cornebise pointed me to this Guardian article that itself summarises the findings of a Nature Neuroscience article I cannot access. The core of the paper is that a large portion of comparative studies conclude to a significant difference between protocols when one protocol result is significantly different from zero and the other one(s) is(are)

Read more »

Forbush events

September 12, 2011
By
Forbush events

As noted here there is a new paper linking Forbush events with changes in DTR. Simply, during a Forbush event  cosmic rays are modulated ( the flux reaching the earth decreases. The theory goes something like this. If GCRs play a role in cloud formation, then when they decrease you should be able to detect an

Read more »

RQuantLib 0.3.8

September 12, 2011
By

A bug-fix release RQuantLib 0.3.8 is now on CRAN and in Debian. RQuantLib combines (some of) the quantitative analytics of QuantLib with the R statistical computing environment and language. Thanks to Helmut Heiming who noticed a side-effec t f...

Read more »

R to Word, revisited

September 12, 2011
By

In a previous post (a long time ago) I discussed a way to get a R data frame into a Word table. The code in that entry was essentially a brute force way of wrapping R data in RTF code, but that RTF code was the bare minimum. There was no optimization of widths, or borders, or...

Read more »

Converting values to color levels

September 12, 2011
By
Converting values to color levels

     Adding color to a plot is helpful in many situations for visualizing an additional dimension of the data. Again, I wrote the below function "val2col" in R after having coded this manually over and over in the past. It uses similar arguments as the image function in that one defines the...

Read more »

Solve your R problems

September 12, 2011
By
Solve your R problems

  download ‘The R Inferno’ Epilogue I’m not a lawyer, but here is my understanding of the rules should you want to extract images from this page: Most of the images are from istockphoto.com. You would need to pay for each image that you want to use. It is unlikely that Sandro Botticelli is going … Continue reading...

Read more »

Call by reference in R

September 11, 2011
By
Call by reference in R

Sometimes it is convenient to use “call by reference evaluation” inside an R function. For example, if you want to have multiple return value for your function, then either you return a list of return value and split them afterward or you can return the value via the argument. For some reasons(I would like to

Read more »

LondonR, 7 September 2011

September 11, 2011
By
LondonR, 7 September 2011

On 7 September 2011 I attended the London R user group meeting. It was a very good turn out with about 50 attendees at the Shooting Star, a pub close to Liverpool Street Station. The session started at 18:00 with four presentations, followed by drinks ...

Read more »

Including googleVis output into a blogger post

September 11, 2011
By
Including googleVis output into a blogger post

It seems that you cannot include Google Visualisation Charts into a blog post directly.So, I tried to include the output of a googleVis function as a gadget, but also unsuccessful.Although you can include gadgets into your site template, it doesn't see...

Read more »

R subplot() with multiple lines

September 11, 2011
By

I have recently used the subplot() function of the TeachingDemos library for R: I wanted to create a simple embedded chart with multiple lines on it. The trick was to create a simple function that prepares the whole plot and pass it to the subplot() function to execute as shown below: > x > x() > plot(1:10)...

Read more »

Alternately coloured line environment with fancyvrb

September 11, 2011
By

Recently, while typing up an R tutorial, I used the LaTeX fancyvrb package to create two environments—one coloured blue for R commands, and one coloured red to display R output. This worked well for large blocks of each type. Then I decided I wan...

Read more »

A shortcut function for install.packages() and library()

September 10, 2011
By
A shortcut function for install.packages() and library()

I enjoy trying difference kind of R packages. Since I have more than 1 computers (1 at home, 1 at office and a laptop) it is troublesome to check whether I have installed some new packages for each computer. Therefore i wrote a function to load and install packages at once. If the package does

Read more »