Abusing Amazon’s Elastic MapReduce Hadoop service… easily, from R

I built my first Hadoop cluster this week and ran my first two test MapReduce jobs. It took about 15 minutes, 2 lines of R, and cost 55 cents. And you can too with JD Long’s (very, very experimental) ‘segue’ package.

But first, you may be wondering why I use the word “abusing” in this post’s title. Well, the Apache Hadoop project, and Google’s MapReduce processing system which inspired it, is all about Big Data. Its raison d’être is the distributed processing of large data sets. Huge data sets, actually. Huge like all the web logs from Yahoo! and Facebook huge. Its HDFS file system is designed for streaming reads of large, unchanging data files; its default block size is 64MB, in case that resonates with your inner geek. HDFS expects its files to be so big that it even makes replication decisions based on its knowledge of your network topology.

I use the term “abuse” because, well, we’re just not going to use any of that Big Data stuff. Instead, we’re going to take advantage of Hadoop’s core machinery to parcel out some embarrassingly parallel, computationally-intensive work, collect the results, and send them back to us. And to keep everything in the cloud and capex-free, we’ll do it all on a cluster of Amazon EC2 instances marshalled and managed by Amazon’s Elastic MapReduce service.

Could the same thing be done with MPI, PVM, SNOW, or any number of other parallel processing frameworks? Certainly. But with only a couple of lines of R? Probably not.

Start the cluster

> library(segue)
Loading required package: rJava
Loading required package: caTools
Loading required package: bitops
Segue did not find your AWS credentials. Please run the setCredentials() function.

> setCredentials('YOUR_ACCESS_KEY_ID', 'YOUR_SECRET_ACCESS_KEY')

> myCluster <- createCluster(numInstances=5)
STARTING - 2011-01-04 15:07:53
STARTING - 2011-01-04 15:08:24
STARTING - 2011-01-04 15:08:54
STARTING - 2011-01-04 15:09:25
STARTING - 2011-01-04 15:09:56
STARTING - 2011-01-04 15:10:27
STARTING - 2011-01-04 15:10:58
BOOTSTRAPPING - 2011-01-04 15:11:28
BOOTSTRAPPING - 2011-01-04 15:11:59
BOOTSTRAPPING - 2011-01-04 15:12:30
BOOTSTRAPPING - 2011-01-04 15:13:01
BOOTSTRAPPING - 2011-01-04 15:13:32
BOOTSTRAPPING - 2011-01-04 15:14:03
BOOTSTRAPPING - 2011-01-04 15:14:34
BOOTSTRAPPING - 2011-01-04 15:15:04
WAITING - 2011-01-04 15:15:35
Your Amazon EMR Hadoop Cluster is ready for action.
Remember to terminate your cluster with stopCluster().
Amazon is billing you!

The createCluster() function provisions the specified number of nodes from EC2, establishes a security zone so they can communicate, boots them, and, in its bootstrap phase, upgrades the version of R on each node and loads some helper functions. You can also distribute your own code and (small) data files to each node during the bootstrap phase. In any case, after a few minutes, the cluster is WAITING and the taxi meter is running… so now what?

Try it out

Let’s make sure everything is working as expected by running the example from JD’s December announcement of his project on the R-sig-hpc mailing list:

> # first, let's generate a 10-element list of 999 random numbers + 1 NA:

myList <- NULL
set.seed(1)
for (i in 1:10){
   a <- c(rnorm(999), NA) 
   myList[[i]] <- a
   }

> # since this is a toy test case, we can run it locally to compare:
> outputLocal  <- lapply(myList, mean, na.rm=T)

> # now run it on the cluster
> outputEmr   <- emrlapply(myCluster, myList, mean,  na.rm=T)
RUNNING - 2011-01-04 15:16:57
RUNNING - 2011-01-04 15:17:27
RUNNING - 2011-01-04 15:17:58
WAITING - 2011-01-04 15:18:29

> all.equal(outputEmr, outputLocal)
[1] TRUE

The key is the emrlapply() function. It works just like lapply(), but automagically spreads its work across the specified cluster. It just doesn’t get any cooler—or simpler—than that.

Estimate pi stochastically

I first stumbled across JD’s R+MapReduce work in this video of his presentation to the Chicago area Hadoop User Group. As a demonstration, he estimates the value of pi stochastically, by throwing dots at random at a unit circle inscribed within a unit square. On average, the proportion of dots falling inside the circle should be related to its area compared to that of the square. And if you remember anything from what passed as math education in your younger years, you may recall that pi is somehow involved. Fortunately for us, JD has posted his code on github so we can put down our #2 pencils and cut-and-paste instead:

> estimatePi <- function(seed){
   set.seed(seed)
   numDraws <- 1e6

   r <- .5 #radius... in case the unit circle is too boring
   x <- runif(numDraws, min=-r, max=r)
   y <- runif(numDraws, min=-r, max=r)
   inCircle <- ifelse( (x^2 + y^2)^.5 < r , 1, 0)

   return(sum(inCircle) / length(inCircle) * 4)
 }

> seedList <- as.list(1:1e3)

> myEstimates <- emrlapply( myCluster, seedList, estimatePi )
RUNNING - 2011-01-04 15:22:28
RUNNING - 2011-01-04 15:22:59
RUNNING - 2011-01-04 15:23:30
RUNNING - 2011-01-04 15:24:01
RUNNING - 2011-01-04 15:24:32
RUNNING - 2011-01-04 15:25:02
RUNNING - 2011-01-04 15:25:34
RUNNING - 2011-01-04 15:26:04
RUNNING - 2011-01-04 15:26:39
RUNNING - 2011-01-04 15:27:10
RUNNING - 2011-01-04 15:27:41
RUNNING - 2011-01-04 15:28:11
RUNNING - 2011-01-04 15:28:42
RUNNING - 2011-01-04 15:29:13
RUNNING - 2011-01-04 15:29:44
RUNNING - 2011-01-04 15:30:14
RUNNING - 2011-01-04 15:30:45
RUNNING - 2011-01-04 15:31:16
RUNNING - 2011-01-04 15:31:47
WAITING - 2011-01-04 15:32:18

> stopCluster(myCluster)
> head(myEstimates)
[[1]]
[1] 3.142512

[[2]]
[1] 3.140052

[[3]]
[1] 3.138796

[[4]]
[1] 3.145028

[[5]]
[1] 3.14204

[[6]]
[1] 3.142136

> # Reduce() is R's Reduce() -- look it up! -- and not related to the cluster:
> myPi <- Reduce(sum, myEstimates) / length(myEstimates)

> format(myPi, digits=10)
[1] "3.141586544"

> format(pi, digits=10)
[1] "3.141592654"

So, a thousand simulations of a million throws each takes about 10 minutes on a 5-node cluster and gets us five decimal places. Not bad.

How does this example relate to MapReduce?

First of all, I am not MapReduce expert, but here’s what I understand based on JD’s talk and my skimming of Hadoop: The Definitive Guide (highly recommended and each purchase goes towards my beer^H^H^H^Helastic computing budget):

  1. Instead of a terabyte or so of log files, we feed Hadoop a list of the numbers 1-1000. It dutifully doles each one to a “mapper” process running our estimatePi() function.
  2. Each invocation of our function uses this input as the seed for its random number generator. (It sure would be embarrassing to have all 1,000 simulations generate exactly the same results!)
  3. The output of the mappers is collected by Hadoop and normally sent on for reducing, but segue’s reduce step just concatenates all of the results so they can be sent back to our local instance as an R list.

All communication between Hadoop and the R code on the cluster is peformed using Hadoop Streaming which allows map and reduce functions to be written in nearly any language which knows the difference between stdin and stdout.

Conclusion and alternatives

If you do your modeling in R and are looking for an easy way to spread around some CPU-intensive work, segue may be right up your alley. But if you’re looking to use Hadoop the right way—The Big Data Way—segue’s not for you. Instead, check out Saptarshi Guha’s RHIPE, the R and Hadoop Integrated Processing Environment.

If you’re just looking to run R on an EC2 node, you can start with this old post by Robert Grossman.

If you’re in Facebook’s data infrastructure engineering team, or are otherwise hooked on Hive, I bet you could use the RJDBC package and the HiveDriver JDBC driver, but I understand that most people just pass CSV files back and forth. The more things change….

But if you think all of this is unnatural and makes you want to take a shower, perhaps I can direct you to CRAN’s High-Performance and Parallel Computing with R task view for more traditional parallel processing options.

spssread.pl: a Perl script to parse SPSS SAV file metadata

I have been spending some time trying to figure out why R’s read.spss() function won’t read Qualtrics-generated SPSS SAV files. (Qualtrics is a very nice online survey system which we have been using with one of our partners.)

I have to admit that I have no interest in the structure of SPSS files (or most others, for that matter), so I was very glad to find Scott Czepiel’s spssread.pl Perl script to parse and display metadata.

So far I can tell that R’s read.spss()/code> is croaking on null characters (as in ASCII 0) at the end of variable names. What was puzzling is that the open source PSPP seems to read these Qualtrics files just fine and the read.spss() code was originally based on PSPP.

To read these files from R, I have been reading them into PSPP first and saving new copies.

Thanks to spssread.pl, I can now see that PSPP doesn't like these variable names either. But instead of croaking, PSPP simply assigns new variable names as spssread.pl -r shows:

$ ./spssread.pl -r qualtrics_short.sav 
Name	Type	Label
A_1	String (20)	ResponseID  
A_2	String (20)	ResponseSet 
A_3	String (255)	Name
A_4	String (255)	ExternalDataReference   
A_5	String (255)	Email   
A_6	String (255)	IPAddress   
A_7	String (255)	StartDate   
A_8	String (255)	EndDate 
A_9	Numeric	Finished
A_10	Numeric	Many airlines are involved in a continui
A_11	Numeric	Please check which applies to this trip.
A_12	Numeric	About how full was your cabin of the air
A_13	Numeric	What was the primary purpose of this fli
A_14	Numeric	Who made the decision regarding the airp
A_15	Numeric	Please divide 100 points among the five -Schedule convenience   
A_16	Numeric	Please divide 100 points among the five -Preference for airline 
A_17	Numeric	Please divide 100 points among the five -Frequent flyer/Mileage program 
A_18	Numeric	Please divide 100 points among the five -Ticket price   
A_19	Numeric	Please divide 100 points among the five -Company policy 
A_20	Numeric	How close to the scheduled departure tim
A_21	Numeric	Please rate the services you received fr-Speed in getting through to Agent  
A_22	Numeric	Please rate the services you received fr-Helpfulness of Agent   
A_23	Numeric	Please rate the services you received fr-Courtesy of Reservation Agent  
A_24	Numeric	Please rate the services you received fr-Accuracy of flight information 
A_25	Numeric	Please rate the services you received fr-Accuracy of fare information   
A_26	Numeric	Please rate the services you received fr-Value for the money
A_27	Numeric	Please rate the services you received fr-Overall rating of the flight   
A_28	String (255)	Including this trip how many air trips fBusiness
A_29	String (255)	Including this trip how many air trips fPleasure
A_30	Numeric	For classification purposes are you...  
A_31	String (255)	Approximate age:
A_32	Numeric	Occupation  
A_33	Numeric	Approximately how many people are employ
A_34	String (255)	City and state of residence:
A_35	Numeric	THANK YOU FOR YOUR COOPERATION. 

$ ./spssread.pl -r pspp_short.sav 
Name	Type	Label
V1      	String (20)	ResponseID  
V2      	String (20)	ResponseSet 
V3      	String (255)	Name
V4      	String (255)	ExternalDataReference   
V5      	String (255)	Email   
V6      	String (255)	IPAddress   
V7      	String (255)	StartDate   
V8      	String (255)	EndDate 
V9      	Numeric	Finished
A22777  	Numeric	Many airlines are involved in a continui
A22778  	Numeric	Please check which applies to this trip.
A22779  	Numeric	About how full was your cabin of the air
A22780  	Numeric	What was the primary purpose of this fli
A22781  	Numeric	Who made the decision regarding the airp
A22782_1	Numeric	Please divide 100 points among the five -Schedule convenience   
A22782_2	Numeric	Please divide 100 points among the five -Preference for airline 
A22782_3	Numeric	Please divide 100 points among the five -Frequent flyer/Mileage program 
A22782_4	Numeric	Please divide 100 points among the five -Ticket price   
A22782_5	Numeric	Please divide 100 points among the five -Company policy 
A22783  	Numeric	How close to the scheduled departure tim
A_21    	Numeric	Please rate the services you received fr-Speed in getting through to Agent  
A_22    	Numeric	Please rate the services you received fr-Helpfulness of Agent   
A_23    	Numeric	Please rate the services you received fr-Courtesy of Reservation Agent  
A_24    	Numeric	Please rate the services you received fr-Accuracy of flight information 
A_25    	Numeric	Please rate the services you received fr-Accuracy of fare information   
A_26    	Numeric	Please rate the services you received fr-Value for the money
A_27    	Numeric	Please rate the services you received fr-Overall rating of the flight   
A22823_0	String (255)	Including this trip how many air trips fBusiness
A22823_1	String (255)	Including this trip how many air trips fPleasure
A22825  	Numeric	For classification purposes are you...  
A22826_0	String (255)	Approximate age:
A22827  	Numeric	Occupation  
A22828  	Numeric	Approximately how many people are employ
A22829_0	String (255)	City and state of residence:
Q16     	Numeric	THANK YOU FOR YOUR COOPERATION. 

File header information can be displayed with spssread.pl -h:

$ ./spssread.pl -h qualtrics_short.sav 

Record type         $FL2
Product name        @(#) SPSS DATA FILE PHP Writer (c) Qualtrics - 0.9.0        
Layout code         2
Case Size           349
Compression         1
Weight index        0
Number of cases     -1
Bias                100.000000
Creation date       21 Jul 10
Creation time       10:28:27
File label                                                                          

$ ./spssread.pl -h pspp_short.sav 

Record type         $FL2
Product name        @(#) SPSS DATA FILE GNU pspp 0.7.6-g55e6e7 - i386-apple-darw
Layout code         2
Case Size           349
Compression         1
Weight index        0
Number of cases     1
Bias                100.000000
Creation date       15 Dec 10
Creation time       12:57:31
File label                                                                          

Thanks, Scott. spssread.pl sure beats the heck out of some quality time with od and the SAV file format docs!

How to fix PSPP’s psppire crashing right after launch (Mac OS 10.5.8)

I installed PSPP from MacPorts on Mac OS X 10.5.8. When I launch the psppire GUI, it displays the splash screen, opens its main window, then crashes a couple of seconds later:

$ /opt/local/bin/psppire
Xlib:  extension "RANDR" missing on display "/tmp/launch-T7iqdy/:0".
(psppire:64632): Gtk-WARNING **: Could not find the icon 'application-x-spss-sav'.
The 'hicolor' theme was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases
**
Gtk:ERROR:gtkrecentmanager.c:1942:get_icon_fallback: assertion failed: (retval != NULL)
Abort trap

Upgrading to the pspp-devel beta version didn’t help.

Solution

Google found a recent ticket and discussion for the same problem with “MyPaint” installed from MacPorts. Maybe it’s a generic problem caused by a change to MacPorts. Dunno, but the same workaround fixed PSPP for me:

  1. Install gnome-icon-theme via MacPorts
  2. Create ~/.gtkrc-2.0 with the line

    gtk-icon-theme-name = "gnome"

Ta-da:

$ /opt/local/bin/psppire
Xlib: extension "RANDR" missing on display "/tmp/launch-T7iqdy/:0".

PSPP screenshot

The “RANDR” warning doesn’t seem to matter.

Posted in Tips. Tags: , , . Leave a Comment »

how to install 64-bit rggobi on Mac OS X 10.5

I was surprised when everything seemed to “just work” when I made the jump to 64-bit R 2.11.1 a while back. “Surprised” because my previous attempt to join the 64-bit world under 2.10.x was a dead-end: the must-have RMySQL package didn’t like the 32-bit MySQL drivers, but Leopard’s 32-bit perl couldn’t deal with 64-bit drivers, etc., etc. Too much hassle for my new non-IT self to deal with.

So today I found the first thing which didn’t “just work” in the jump: the rggobi package.

Long story short, the trick is to install the rggobi package from source. Hadley Wickham (that guy is everywhere, isn’t he?) spells out the prerequisites and steps on the GGobi users Google group:

http://groups.google.com/group/ggobi/msg/5ae98c8b87d14a61

The only change you’ll need to make, if you’re still stuck in the 32/64-bit limbo of 10.5 like me is to make sure you build the package from the 64-bit version of R:

$ R64 CMD INSTALL ~/Downloads/rggobi_2.1.16.tar.gz

Posted in Tips. Tags: , , . Leave a Comment »

vecLib: Why Mac users are better off with Open Source R

The July and August meetings of the New England R Users group focused on two different aspects of R performance: parallel processing techniques and the effects of compiler & library selection when compiling the R executable itself.

It was during Amy Szczepanski’s excellent introduction to multicore, Rmpi, and foreach (slides here) that she mentioned that the nice people who compile R for the Mac use optimized libraries to improve its performance. Amy works at the University of Tennessee’s Center for Remote Data Analysis and Visualization where they build and run machines with tens of thousands of cores, so her endorsement carries a lot of weight. I think Amy mentioned that she had benchmarked the open source vs. Revolutions distributions on her Mac, but I can’t find it in her slides and, well, in one ear and out the other….

It was the comprehensive presentation by IBM’s Vipin Sachdeva (slides here) showing 15-20X speedups through compiler and library selection that made me want to try a couple of benchmarks myself.  And my recent it’s-about-time upgrade to 2.11 seemed like the perfect opportunity.

Open source vs. Revolutions Community R

Performance is one of the advantages claimed by Revolution Analytics for its distributions, with their product page promising “optimized libraries and compiler techniques run most computation-intensive programs significantly faster than Base R” even with their free, Community edition. I have heard good things about its performance on Windows, so I was curious to see if it provides an improvement over the already-optimized Mac binary.

Benchmarking Methodology (or lack thereof)

First, some disclaimers: I am not a serious benchmarker and have made no special effort for statistical rigor.  I am just looking for order-of-magnitudes here, so I kept a normal number of programs running in the background, like Firefox and OpenOffice, though nothing was doing anything substantial and I avoided any user input while each test ran. My machine is the short-lived, late-2008, aluminum unibody 13″ MacBook (MacBook5,1) with 4GB RAM and Mac OS X Leopard 10.5.8 running the 32-bit kernel. It has a 2.4GHz Core 2 Duo — nothing special.

For my tests, I ran the standard R Benchmark 2.5 available from AT&T ‘s benchmarking page which performs various matrix and vector calculations — perfect for discerning the effects of such optimized libraries.  I kept the defaults, such as running each test 3 times, and installed the required “SuppDists” package.  I tested the open source 2.10.1 32-bit version I already had on my machine and then installed Revolution’s 2.10.1-based 64-bit community edition. I should have repeated the test with the open source 64-bit edition, but I didn’t think of it at the time (I told you I wasn’t serious about this), so instead I later re-ran the benchmark with the 32- and 64-bit versions of the open source 2.11.1 to check if there are any significant 32-vs-64 differences.

Results

It didn’t take long to realize that the Revolutions community edition was not going to fare well. During just the fourth benchmark, 2800×2800 cross-product matrix (b = a’ * a), there was a pregnant pause in the output while my laptop’s fans kicked in and soon spun up to full force. It took nearly 25 seconds to complete each turn of that one test where the open source 2.10.1 had finished in less than one tenth the time. (The complete output for each test is at the end of this post.)

results summary bar chart

Figure 1: Summary-level benchmark results. (Smaller bars are better.)

Figure 1 shows the geometric means of the elapsed times for each benchmark section as reported by R Benchmark 2.5. Clearly the Revolutions distribution did significantly worse on the matrix benchmarks. Figure 2 drills into the individual benchmarks to show the roughly 2-8X difference on the five slowest matrix benchmarks. Only on the sixth, Grand common divisors of 400,000 pairs (recursion), was the slowdown matched by the base 64-bit distribution. Only on Revolution’s fastest benchmark,2400×2400 normal distributed random matrix ^1000 all the way at the bottom of Figure 2, did the 64-bit versions hold a distinct (and roughly equal) advantage over their 32-bit brethren.

results detail bar chart

Figure 2: Individual benchmark results. (Smaller bars are better.)

vecLib: BLAS, LAPACK, and built into the Mac

So, no surprise — Amy was right. The off-the-shelf open source distributions of R for the Mac are already optimized. But how? Vipin walked us through all the different choices for BLAS and LAPACK libraries, not to mention the different C and FORTRAN compilers and their optimization flags. How can we know what’s being used by a given distribution? Well, it turns out that R makes it easy to find out with the config options to “R CMD”:

$ R CMD config BLAS_LIBS-L/Library/Frameworks/R.framework/Resources/lib/i386 -lRblas
$ ls -l /Library/Frameworks/R.framework/Resources/lib/i386/libRblas.dylib
lrwxr-xr-x  1 root  admin  17 Oct  7 00:58 /Library/Frameworks/R.framework/Resources/lib/i386/libRblas.dylib -> ../libRblas.dylib
$ ls -l /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib
lrwxr-xr-x  1 root  admin  21 Oct  7 00:58 /Library/Frameworks/R.framework/Resources/lib/libRblas.dylib -> libRblas.vecLib.dylib

Following the symbolic link, “libRblas.vecLib.dylib” is the library being used for BLAS. A quick consultation with Google reveals that “vecLib” is Apple’s vector library from their “Acceleration” framework in Mac OS. Here’s what Apple’s Developer site says about vecLib’s BLAS and LAPACK components::

Basic Linear Algebra Subprograms (BLAS)

VecLib also contains Basic Linear Algebra Subprograms (BLAS) that use AltiVec technology for their implementations. The functions are grouped into three categories (called levels), as follows:

  1. Vector-scalar linear algebra subprograms
  2. Matrix-vector linear algebra subprograms
  3. Matrix operations

A Readme file is included that contains the following sections:

  1. Descriptions of functions
  2. Comparison with BLAS (Basic Linear Algebra Subroutines)
  3. Test methodology
  4. Future releases
  5. Compiler version

LAPACK

LAPACK provides routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems. The associated matrix factorizations (LU, Cholesky, QR, SVD, Schur, generalized Schur) are also provided, as are related computations such as reordering of the Schur factorizations and estimating condition numbers. Dense and banded matrices are handled, but not general sparse matrices. In all areas, similar functionality is provided for real and complex matrices, in both single and double precision.

Also, see <http://netlib.org/lapack/index.html.

As Vipin had demonstrated, using a fast BLAS and LAPACK libraries can make all the difference in the world (well, 20X or so). And since Apple controls the horizontal and vertical on their platform, it shouldn’t be a surprise that vecLib is fast on their hardware and OS.  The real question is why doesn’t Revolutions simply link to vecLib too? It can’t be because their libraries are better (they clearly aren’t). Nor could they be afraid of competing with their Enterprise edition because, according to this edition comparison chart, they don’t offer an enterprise edition for the Mac. Perhaps they’re simply not that familiar with the platform and don’t know about vecLib. I know I didn’t know anything about it until these tests prompted me to consult The Google.

Your mileage may vary

Google also pointed me to this recent discussion on the R-SIG-MAC mailing list in which Simon Urbanek refers to a serious bug in vecLib which prevents it from spawning threads and shows timings from a “tcrossprod” benchmark on a new 2.66GHz Mac Pro:

vecLib           6.43
ATLAS serial     4.80
MKL serial       4.30
MKL parallel     0.90
ATLAS parallel   0.71

So there still seems to be plenty of opportunity to beat vecLib if you’re willing to compile R and mix and match BLAS libraries. For the rest of us, the open source distribution offers the best bang for the buck.

Maybe I need to ask Vipin to take a look at my Mac at the next meeting….

Complete Output

open source 2.10.1 32-bit

R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.31 (5537) i386-apple-darwin8.11.1]

[Workspace restored from /Users/jbreen/.RData]

> source("/Users/jbreen/Desktop/R-benchmark-25.R")
Loading required package: Matrix
Loading required package: lattice
Loading required package: SuppDists

 R Benchmark 2.5
 ===============
Number of times each test is run__________________________:  3

 I. Matrix calculation
 ---------------------
Creation, transp., deformation of a 2500x2500 matrix (sec):  1.16766666666666
2400x2400 normal distributed random matrix ^1000____ (sec):  1.14666666666667
Sorting of 7,000,000 random values__________________ (sec):  1.26266666666667
2800x2800 cross-product matrix (b = a' * a)_________ (sec):  2.461
Linear regr. over a 3000x3000 matrix (c = a \ b')___ (sec):  1.42233333333333
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.27997944504873

 II. Matrix functions
 --------------------
FFT over 2,400,000 random values____________________ (sec):  1.333
Eigenvalues of a 640x640 random matrix______________ (sec):  1.23633333333333
Determinant of a 2500x2500 random matrix____________ (sec):  1.65233333333333
Cholesky decomposition of a 3000x3000 matrix________ (sec):  1.712
Inverse of a 1600x1600 random matrix________________ (sec):  1.65633333333334
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.53942494113224

 III. Programmation
 ------------------
3,500,000 Fibonacci numbers calculation (vector calc)(sec):  1.21066666666667
Creation of a 3000x3000 Hilbert matrix (matrix calc) (sec):  0.919333333333332
Grand common divisors of 400,000 pairs (recursion)__ (sec):  1.252
Creation of a 500x500 Toeplitz matrix (loops)_______ (sec):  1.38000000000001
Escoufier's method on a 45x45 matrix (mixed)________ (sec):  1.105
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.18758233972606

Total time for all 15 tests_________________________ (sec):  20.9173333333333
Overall mean (sum of I, II and III trimmed means/3)_ (sec):  1.32762395973868
 --- End of test ---

Revolution R community 2.10.1 64 bit

R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

REvolution R version 3.2: an enhanced distribution of R
REvolution Computing packages Copyright (C) 2010 REvolution Computing, Inc.

Type 'revo()' to visit www.revolution-computing.com for the latest
REvolution R news, 'forum()' for the community forum, or 'readme()'
for release notes.

[R.app GUI 1.30 (5511) x86_64-apple-darwin9.8.0]

[Workspace restored from /Users/jbreen/.RData]

trying URL 'http://watson.nci.nih.gov/cran_mirror/src/contrib/SuppDists_1.1-8.tar.gz'
Content type 'application/x-gzip' length 139864 bytes (136 Kb)
opened URL
==================================================
downloaded 136 Kb

* installing *source* package ‘SuppDists’ ...
** libs
** arch - x86_64
g++ -arch x86_64  -I/opt/REvolution/Revo-3.2/Revo64/R.framework/Resources/include -I/opt/REvolution/Revo-3.2/Revo64/R.framework/Resources/include/x86_64  -I/usr/local/include    -fPIC  -g -O2 -c dists.cc -o dists.o
g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o SuppDists.so dists.o -F/opt/REvolution/Revo-3.2/Revo64/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
* DONE (SuppDists)

The downloaded packages are in
 ‘/private/var/folders/+s/+snLnQILHz4Kn8jMFYEERE++-4+/-Tmp-/RtmpVqNN4f/downloaded_packages’
> source("/Users/jbreen/Desktop/R-benchmark-25.R")
Loading required package: Matrix
Loading required package: lattice
Loading required package: SuppDists

 R Benchmark 2.5
 ===============
Number of times each test is run__________________________:  3

 I. Matrix calculation
 ---------------------
Creation, transp., deformation of a 2500x2500 matrix (sec):  1.18633333333333
2400x2400 normal distributed random matrix ^1000____ (sec):  0.463333333333334
Sorting of 7,000,000 random values__________________ (sec):  1.10266666666667
2800x2800 cross-product matrix (b = a' * a)_________ (sec):  24.786
Linear regr. over a 3000x3000 matrix (c = a \ b')___ (sec):  10.3813333333333
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  2.38580368558367

 II. Matrix functions
 --------------------
FFT over 2,400,000 random values____________________ (sec):  1.32633333333335
Eigenvalues of a 640x640 random matrix______________ (sec):  1.631
Determinant of a 2500x2500 random matrix____________ (sec):  8.66366666666666
Cholesky decomposition of a 3000x3000 matrix________ (sec):  6.70300000000001
Inverse of a 1600x1600 random matrix________________ (sec):  8.71566666666664
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  4.55835668372464

 III. Programmation
 ------------------
3,500,000 Fibonacci numbers calculation (vector calc)(sec):  1.10766666666666
Creation of a 3000x3000 Hilbert matrix (matrix calc) (sec):  0.818666666666672
Grand common divisors of 400,000 pairs (recursion)__ (sec):  3.529
Creation of a 500x500 Toeplitz matrix (loops)_______ (sec):  1.28933333333335
Escoufier's method on a 45x45 matrix (mixed)________ (sec):  1.072
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.15254093929808

Total time for all 15 tests_________________________ (sec):  72.776
Overall mean (sum of I, II and III trimmed means/3)_ (sec):  2.32291395838888
 --- End of test ---

open source 2.11.1 64-bit

R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.34 (5589) x86_64-apple-darwin9.8.0]

[Workspace restored from /Users/jbreen/.RData]

> source("/Users/jbreen/Desktop/R-benchmark-25.R")
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':

 det

Loading required package: SuppDists
Error in eval.with.vis(expr, envir, enclos) : object 'rMWC1019' not found
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
 there is no package called 'SuppDists'
trying URL 'http://watson.nci.nih.gov/cran_mirror/bin/macosx/leopard/contrib/2.11/SuppDists_1.1-8.tgz'
Content type 'application/x-gzip' length 412485 bytes (402 Kb)
opened URL
==================================================
downloaded 402 Kb

The downloaded packages are in
 /var/folders/+s/+snLnQILHz4Kn8jMFYEERE++-4+/-Tmp-//RtmpoWgMNZ/downloaded_packages
> source("/Users/jbreen/Desktop/R-benchmark-25.R")
Loading required package: SuppDists

 R Benchmark 2.5
 ===============
Number of times each test is run__________________________:  3

 I. Matrix calculation
 ---------------------
Creation, transp., deformation of a 2500x2500 matrix (sec):  1.193
2400x2400 normal distributed random matrix ^1000____ (sec):  0.455333333333336
Sorting of 7,000,000 random values__________________ (sec):  1.06133333333333
2800x2800 cross-product matrix (b = a' * a)_________ (sec):  2.70466666666667
Linear regr. over a 3000x3000 matrix (c = a \ b')___ (sec):  1.78500000000001
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.3123313069964

 II. Matrix functions
 --------------------
FFT over 2,400,000 random values____________________ (sec):  1.23466666666667
Eigenvalues of a 640x640 random matrix______________ (sec):  1.15366666666667
Determinant of a 2500x2500 random matrix____________ (sec):  1.92633333333333
Cholesky decomposition of a 3000x3000 matrix________ (sec):  1.81366666666667
Inverse of a 1600x1600 random matrix________________ (sec):  1.96333333333333
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.6278443559224

 III. Programmation
 ------------------
3,500,000 Fibonacci numbers calculation (vector calc)(sec):  1.07533333333332
Creation of a 3000x3000 Hilbert matrix (matrix calc) (sec):  0.792999999999997
Grand common divisors of 400,000 pairs (recursion)__ (sec):  3.393
Creation of a 500x500 Toeplitz matrix (loops)_______ (sec):  1.20000000000001
Escoufier's method on a 45x45 matrix (mixed)________ (sec):  0.89500000000001
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.04917789012305

Total time for all 15 tests_________________________ (sec):  22.6473333333333
Overall mean (sum of I, II and III trimmed means/3)_ (sec):  1.30868512419174
 --- End of test ---

open source 2.11.1 32 bit

R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

 Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.34 (5589) i386-apple-darwin9.8.0]

[Workspace restored from /Users/jbreen/.RData]

trying URL 'http://watson.nci.nih.gov/cran_mirror/bin/macosx/leopard/contrib/2.11/SuppDists_1.1-8.tgz'
Content type 'application/x-gzip' length 412485 bytes (402 Kb)
opened URL
==================================================
downloaded 402 Kb

The downloaded packages are in
 /var/folders/+s/+snLnQILHz4Kn8jMFYEERE++-4+/-Tmp-//RtmpX3gq6O/downloaded_packages
> source("/Users/jbreen/Desktop/R-benchmark-25.R")
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':

 det

Loading required package: SuppDists

 R Benchmark 2.5
 ===============
Number of times each test is run__________________________:  3

 I. Matrix calculation
 ---------------------
Creation, transp., deformation of a 2500x2500 matrix (sec):  1.19433333333333
2400x2400 normal distributed random matrix ^1000____ (sec):  1.122
Sorting of 7,000,000 random values__________________ (sec):  1.144
2800x2800 cross-product matrix (b = a' * a)_________ (sec):  2.25133333333333
Linear regr. over a 3000x3000 matrix (c = a \ b')___ (sec):  1.475
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.26312946510292

 II. Matrix functions
 --------------------
FFT over 2,400,000 random values____________________ (sec):  1.40366666666667
Eigenvalues of a 640x640 random matrix______________ (sec):  1.28133333333333
Determinant of a 2500x2500 random matrix____________ (sec):  1.745
Cholesky decomposition of a 3000x3000 matrix________ (sec):  1.61
Inverse of a 1600x1600 random matrix________________ (sec):  1.50166666666667
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.50275368328927

 III. Programmation
 ------------------
3,500,000 Fibonacci numbers calculation (vector calc)(sec):  1.22666666666666
Creation of a 3000x3000 Hilbert matrix (matrix calc) (sec):  0.87133333333333
Grand common divisors of 400,000 pairs (recursion)__ (sec):  1.29
Creation of a 500x500 Toeplitz matrix (loops)_______ (sec):  1.33899999999999
Escoufier's method on a 45x45 matrix (mixed)________ (sec):  1.16800000000001
 --------------------------------------------
 Trimmed geom. mean (2 extremes eliminated):  1.22721231763175

Total time for all 15 tests_________________________ (sec):  20.6233333333333
Overall mean (sum of I, II and III trimmed means/3)_ (sec):  1.32561819861344
 --- End of test ---
Posted in Tips. Tags: , , . 5 Comments »

Set Firefox to ignore no autocompletion suggestions and offer to remember instead

Web developers can add autocomplete="off" to the HTML code of online forms to suggest that browsers not remember the input. This is often done for login pages, etc. in the name of security.

But Firefox already asks whether it’s OK to save such info—and even remembers if you press Never For This Site. And since it’s my computer, I’d like it to ask me instead.

Fortunately, a one-line JavaScript change to force the _isAutocompleteDisabled function in components/nsLoginManager.js to returnfalse blindly will do the trick:

http://cybernetnews.com/firefox-remember-passwords/

rgdal and other GIS-related packages for Mac OS X

CRAN contains ready-made binary packages for nearly all of its packages, but rgdal is one which I keep finding myself trying to install from source whenever I upgrade R.

Compiled versions of rgdal, along with prerequisites and complements like the GDAL framework, GRASS, and even the old FFTW3 can be found at KyngChaos’s Wiki:


Update 10/10/10:
I don’t remember needing to do this before, but

$ ln -s /Library/Frameworks/GDAL.framework/Programs/gdal-config /usr/local/bin

makes the rgdal source package installation work on R 2.11.1.


Posted in GIS, Tips. Tags: , , . Leave a Comment »