doobwa/JuliaData — pull request #1 by tshort (2012-07-26 14:35:16+00:00)
Title: Tom reorg expand

Chris, see enclosed for an attempted reorganization of `expand()`. I've recently written a similar recursive function that operates on expressions. I think I rewrote it about 4 times until it worked right, and I was happy with it.

My goal on the reorg was to try to make expansion "more expandable". The idea is that operators or functions can be defined a couple of ways. One is by defining a method for the operator or function with a signature like the following:
```julia
function &(::FormulaExpander, args::Vector{Any}, df::DataFrame)
interaction_design_matrix(expand(args[1], df), expand(args[2], df))
end
```
That way, someone can define similar functions for `C`, `I`, `poly` or other operations. Similarly, expansion can be provided for specific types like they are for PooledDataVecs:

```julia
function expand(poolcol::PooledDataVec, colname::ByteString, df::DataFrame)
```

This reorg currently helps with the `a+b+c` problem (more than two arguments) as well the `a+a*b` issue (`a` is repeated). `a*b*c` is still broken.

Also, I realized I got some more recent commits in there, too. Hopefully, that's not a problem.