Blog Archives

Do older SOers use fewer words?

August 18, 2011
By
Do older SOers use fewer words?

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.R1...

Read more »

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

July 11, 2011
By

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> }> ...

Read more »

Reverse Iteration

July 3, 2011
By
Reverse Iteration

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 noise:

RObjectTables are AWESOME

June 26, 2011
By

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 associates names...

Read more »

Crashed!!

June 23, 2011
By

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) { ...

Read more »

Inheriting in Items

June 23, 2011
By

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:

Items

June 22, 2011
By

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...

Read more »

The R WikiBook

June 21, 2011
By

Tal Galili, god bless him, is rounding up R bloggers for an R WikiBookIn 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 giv...

Read more »

Corresponding

May 7, 2011
By

(The examples here work with the version of insidefunctor tagged as "v2")Unfortunately I couldn't do this cleanly outside the library. So the changes are made in insidefunctor.Levels are no longer used to "line up" eaches. So, for example,> library(insidefunctor)> `%+.%` = fmap(`+`)> `%/.%` = fmap(`/`)> x = c(1,...

Read more »

"Inside" Functors — Evaluating things more than once

May 1, 2011
By
"Inside" Functors — Evaluating things more than once

(The examples here work with the version of insidefunctor tagged as "v1")I ran into an interesting problem using "inside" functors.Something is wrong in the following code (well, depending on what you thought it should do).> library(insidefunctor)> `%+.%` = fmap(`+`)> x = seq(0, 10, len = 50)> plot(x,...

Read more »