Category Archives: R

“Inside” Functors — Multiple Arguments

Again for HTML reasons this has been taken to http://strugglingthroughproblems.blogspot.com/2011/04/inside-functors-multiple-arguments.html

Posted in R | Leave a comment

“Inside” Functors

So, WordPress doesn’t like RweaveHTML, so this is posted at http://strugglingthroughproblems.blogspot.com/2011/04/inside-functors.html

Posted in R | Leave a comment

Complex-valued linear models

Someone has probably already written code to do this. But I couldn’t find it in CRAN, so here goes. Oh no lm() won’t take complex numbers! (or rather, it’ll take them, but it’ll discard the imaginary part.) Easy enough fix. … Continue reading

Posted in R | 2 Comments

R SQL-ish aggregation

I came to R from SQL. I’ve heard that packages such as reshape and plyr are quite beautiful, but to me they are somewhat non-intuitive. I’m always looking for SELECT mean(sodium) as mean, variance(sodium) as var FROM texas GROUP BY … Continue reading

Posted in R | 5 Comments

Subset views in R

I don’t know how to do this in R. So let me just say why I can’t. I wanted something akin to Boost‘s sub-matrix views, where you can have indexes map back to the original matrix, so you don’t create … Continue reading

Posted in R | 4 Comments

Matlab-style multiple assignment in R

R again! You know how in Matlab you can do? S, I = sort(M) I like that. R generic functions makes this possible. First, let’s genericize assignment. I feel like regular “=” and “<-” oughta stay nongeneric, so let’s make … Continue reading

Posted in R | 5 Comments

Packing everything into a data.frame

OK, I know I talk about R too much, but I like R, so I’m going to talk about it some more. Common situation: repeat a procedure many times; each time generates some large wadge of awful-structured data, and in … Continue reading

Posted in R | Leave a comment

Rearranging definitions in R

I came up with a handy little trick for programming in R. I like to define a lot of variables all at once without worrying about what order they’re in. The goal would be something like this: K  = -R2/R1 … Continue reading

Posted in R | 1 Comment