I like to have a “x vs. y”- plot in which the symbol colors represent a additional (or another :-) dimension z.
I’m sure that there are several ways to do that, however here is the way I understand.
Assume that x, y and z have the same length n :
n <- length(y)
At first I generate a vector from z (z will give the color) in the interval [0,1]
zp <- z - min(z) ## zp starts from 0 zpp <- zp/max(zp) ## zpp ends at 1
If I now multiply zpp by n I get a nice index vector which can be used together with the result produced by colorRampPalette():
cf <- colorRampPalette(c("blue","yellow","red"))
cf is a function. It’s argument is the length of the color vector which should be returned. Now put everything together:
Here is a complete example:
This is how it looks like:
Today I searched an old post. I used the tumblr search without success …
So I’ve started a new blog with some couchdb, git, node.js stuff I wrote last months. This kind of posts I will dump there.
Leave a comment on
or do it here. The blog is hosted on
It’s a couchapp. Comments?
I relay hope Wittgenstein will approve.
One of the nice things about tracking the R subversion repository using git instead of subversion is you can dogit shortlog -s -n
which gives you19855 ripley 6302 maechler 5299 hornik 2263 pd 1153 murdoch 813 iacus 716 luke 661 jmc 614 leisch 472 ihaka 403 murrell 286 urbaneks 284 rgentlem 269 apache 253 bates 249 tlumley 164 duncan 92 r 43 root 40 paul 40 falcon 39 lyndon 34 thomas 33 deepayan 26 martyn 18 plummer 15 (no author) 14 guido 3 ligges 1 mike
One of my favorite R packages that I use all the time is the RColorBrewer package. The package has been around for a while now and is written/maintained by Erich Neuwirth. The guts of the package are based on Cynthia Brewer’s very cool work on the use of color in cartography (check out the colorbrewer web site).
As a side note, I think the ability to manipulate colors in plots/graphs/maps is one of R’s many great strengths. My personal experience is that getting the right color scheme can make a difference in how data are perceived in a plot.
generates regExp from nobrainer * expressions
> glob2rx("foo*.bar.*baz")  "^foo.*\\.bar\\..*baz$"
A quick note on updating R.
Updating is always important as few bugs are fixed or the code is more efficient than the previous versions.
Though everything will be working as good as in old versions as in new, but some new features might be good to have.
Updating all R packages :
checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed USE_LOCAL = "" Using local libjson code. Copying files /tmp/Rtmp2n5YCn/R.INSTALL38c6756b/RJSONIO configure: creating ./config.status config.status: creating src/Makevars config.status: creating cleanup ** libs gcc -std=gnu99 -I/usr/lib/R/include -I. .... make: g++: Kommando nicht gefunden make: *** [JSONChildren.o] Fehler 127 ERROR: compilation failed for package ‘RJSONIO’
# ln -s g++-4.4 g++ # l g++ lrwxrwxrwx 1 root root 7 11. Okt 13:09 g++ -> g++-4.4*
My problem was the following: I have a database (from priceofweed.com), with locations written as “city, region, country”. What I wanted was the precise location (latitude, longitude) for each city. …