Publications by ellbur

The R WikiBook

21.06.2011

Tal Galili, god bless him, is rounding up R bloggers for an R WikiBook In support of this book I am announcing all R-related content I post (here and at the old site) to be available under a cc-by-sa license (not that I’d really care if you didn’t give attribution). Related To leave a comment for the author, please follow the ...

691 sym

Items

22.06.2011

Let’s define a new pattern! I do a lot of programming for research, and part of what this involves is turning calculations, usually expressed as verbs, into nouns. That is, I need to keep the calculation and all it’s intermediate steps around so that I can inspect them. Alas, I am programming in Python most of the time and end up writing a lo...

3460 sym R (203 sym/1 pcs)

Inheriting in Items

23.06.2011

What if we want to extend the behavior of one item with another? Or, to put it another way, what if we want one item to be able to grab the functionality of another? It turns out we can (almost) get this behavior without modifying the item constructor at all. Here’s how you do the grabbing: > grab = function(src, obj=parent.frame()) { > fo...

4661 sym R (2363 sym/2 pcs)

Crashed!!

23.06.2011

This crashes R (sometimes): 1 2 f = function( 3 a = {x <- y <- z <- w <- t <- u <- 7} 4 ) environment() 5 6 for (i in 1:1000) { 7 try(as.list(f()), silent=T) 8 } 9 10 The problem is the same as I described in the last post Related To leave a comment for the author, please follow the link and c...

494 sym R (190 sym/1 pcs)

RObjectTables are AWESOME

26.06.2011

Why isn’t everyone using the RObjectTables package? This is the best thing ever! Here’s the basic idea of RObjectTables: An environment is an object where you can lookup names and associate them with values. And in particular its where you look up variables used in an expression. But there’s no reason you can’t take any other object that ...

7806 sym R (651 sym/1 pcs)

Reverse Iteration

03.07.2011

Time to horrify some people. First let’s include the code we wrote last time, > source(“pretend.R”) and the dependency-tracking environment it creates will be used to run all the following examples. Let’s look at, I don’t know, I’m just trying to demonstrate a language feature so uh… band-pass filtering Gaussian noise. Here’s some...

2948 sym 10 img

You can scrap it and write something better but let me keep R ;)

11.07.2011

Ross Ikaha (via Xi’an — thanks 😉 ) gives a nice example to show why R is basically impossible to optimize: > f = function() { > if (runif(1) > 0.5) { > x = 10 > } > x > } x in the last expression could be a local or a global, and this won’t be known until runtime! That’s pretty good. I wonder if this will alw...

4612 sym

Do older SOers use fewer words?

18.08.2011

On StackOverflow, to posters with more experience ask their questions in fewer words? No. There’s no visible difference: Chars of non-code: Chars of code: The data comes from the super-handy StackOverflow API, which was retrieved using wget and then parsed using rjson and XML. First read in and parse the JSON: so.R 1 library(rjson) ...

821 sym R (1465 sym/4 pcs) 4 img