zwol: stylized sketch of a face in profile (Default)
[personal profile] zwol

R's graphics libraries make it much, much too hard to plot two curves on top of each other. For instance. Suppose I have two vectors of numbers, X and Y, and I want probability density plots for them both. On the same chart. How do you do it? Is it something sane like

densityplot(list(X,Y))

...? Or I would tolerate the slightly less obvious but still relatively motivated

densityplot(stack(X,Y))

even (assuming that was an acceptable way to use stack, which it isn't, but that's a whole nother rant). No! It is neither! This is how you do it:

with(data.frame(aargh=c(X,Y),
                gah=c(rep(1,length(X)), 
                      rep(2,length(Y)))),
     densityplot(~aargh, groups=gah))

Plz to be shooting me now.

Date: 2007-05-17 05:39 am (UTC)
From: [identity profile] aldren.livejournal.com
I'm sorry. Is that a C-derived language you're using, or a LISP-derived one? Because it seems to be downright confused as to which it really is :)

Date: 2007-05-17 05:58 am (UTC)
From: [identity profile] zwol.livejournal.com
It is confused. The syntax is iterative and infix (and C-ish for control structures), but everything is data, including code. Just for added fun, there are no scalar data objects, only vectors of length one. (It's a high-level statistical language, and really very nice, except for the graphics library. My horribly complicated regression model for my experiment can be specified in one line. Producing a sensible graph from that model - two plots with three straight lines on each and error bars at either end of the lines - takes fifty plus.)

On balance I'd say it's closer to the Lisp attractor than the Algol attractor.

The "R" at the beginning of the post is a hyperlink, if you want more detail.

April 2017

S M T W T F S
      1
2345678
9101112131415
16171819 202122
23242526272829
30      

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 11th, 2026 11:17 pm
Powered by Dreamwidth Studios