|
|
Thinking inside the box | |||||
|
Bio
Code Linux Quantian About Blog |
Rcpp 0.7.9
So a quick bug-fix release 0.7.9 is now in Debian and should be on CRAN shortly. The full NEWS entry for this release follows:
0.7.9 2010-03-12
o Another small improvement to Windows build flags
o bugfix on 64 bit platforms. The traits classes (wrap_type_traits, etc)
used size_t when they needed to actually use unsigned int
o fixed pre gcc 4.3 compatibility. The trait class that was used to
identify if a type is convertible to another had too many false positives
on pre gcc 4.3 (no tr1 or c++0x features). fixed by implementing the
section 2.7 of "Modern C++ Design" book.
As always, even fuller details are in Rcpp Changelog page and the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. A local directory has source and documentation too. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Update: First version number corrected to 0.7.8. Thu, 11 Mar 2010
RcppArmadillo 0.1.0
Romain and I already had an example of a simple but fast linear model fit using the (very clever) Armadillo C++ library by Conrad Sanderson. In fact, I had used this as a motivational example of why Rcpp rocks in a recent talk to the ACM chapter at U of Chicago which, thanks to David Smith at REvo, got some further exposure. Now this example is more refined as further glue got added. Given that both Armadillo and Rcpp make use of C++ templates, the actual amount of code in RcppArmadillo is not that large: just over 200 lines in a header file, and a little less for some testing accessor and example functions in a source file. And this makes for some really nice example code: the 'fast regression' example becomes this (where I simply removed two blocks with conditional on the Armadillo version):
#include <RcppArmadillo.h> extern "C" SEXP fastLm(SEXP ys, SEXP Xs) { Rcpp::NumericVector yr(ys); // creates Rcpp vector from SEXP Rcpp::NumericMatrix Xr(Xs); // creates Rcpp matrix from SEXP int n = Xr.nrow(), k = Xr.ncol(); arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy arma::colvec y(yr.begin(), yr.size(), false); arma::colvec coef = solve(X, y); // fit model y ~ X arma::colvec resid = y - X*coef; // residuals double sig2 = arma::as_scalar( trans(resid)*resid/(n-k) ); // std.error of estimate arma::colvec stderrest = sqrt( sig2 * diagvec( arma::inv(arma::trans(X)*X)) ); Rcpp::Pairlist res(Rcpp::Named( "coefficients", coef), Rcpp::Named( "stderr", stderrest)); return res; } No extra copies! Armadillo instantiates directly from the underlying R objects for the vector and matrix, solves the regression equations, computes the standard error of the estimates and returns the two vectors. Leaving us to write about eleven lines of code. Moreover, as Armadillo is well designed and uses template meta-programming to avoid extra copies (see these lecture notes for details), it is about as efficient as it can be (and will use Atlas or other BLAS where available). And, this is just one example. Rcpp should be suitable for other C++ libraries, and provides an easy to use seamless interface between C++ and R. However, we should note that (at about the last minute) we found out about some unit test failures in OS X as well as some issues in a Debian chroot -- cran2deb ran into some build issues on i386 and amd64 in the testing chroot even this 'it all works' swimmingly on our Debian, Ubuntu and Fedora build environments. A follow-up with fixes for either Rcpp and/or RcppArmadillo appears likely. Update: The build issues seems to be with 64-bit systems and everything appears cool in 32-bit. Wed, 10 Mar 2010
RcppExamples 0.1.0
As mentioned in the post about release 0.7.8 of Rcpp, Romain and I carved this out of Rcpp itself to provide a cleaner separation of code that implements our R / C++ interfaces (which remain in Rcpp) and code that illustrates how to use it --- which is now in RcppExamples. This also provides an easier template for people wanting to use Rcpp in their packages as it will be easier to wrap one's head around the much smaller RcppExamples package. A simple example (using the newer API) may illustrate this: #include <Rcpp.h> RcppExport SEXP newRcppVectorExample(SEXP vector) { Rcpp::NumericVector orig(vector); // keep a copy (as the classic version does) Rcpp::NumericVector vec(orig.size()); // create a target vector of the same size // we could query size via // int n = vec.size(); // and loop over the vector, but using the STL is so much nicer // so we use a STL transform() algorithm on each element std::transform(orig.begin(), orig.end(), vec.begin(), sqrt); Rcpp::Pairlist res(Rcpp::Named( "result", vec), Rcpp::Named( "original", orig)); return res; } With essentially five lines of code, we provide a function that takes any numeric vector and returns both the original vector and a tranformed version---here by applying a square root operation. Even the looping along the vector is implicit thanks to the generic programming idioms of the Standard Template Library. Nicer still, even on misuse, exceptions get caught cleanly and we get returned to the R prompt without any explicit coding on the part of the user:
R> library(RcppExamples) Loading required package: Rcpp R> print(RcppVectorExample( 1:5, "new" )) # select new API $result [1] 1.000 1.414 1.732 2.000 2.236 $original [1] 1 2 3 4 5 R> RcppVectorExample( c("foo", "bar"), "new" ) Error in RcppVectorExample(c("foo", "bar"), "new") : not compatible with INTSXP R> There is also analogous code for the older API in the package, but it is about three times as long, has to loop over the vector and needs to set up the execption handling explicitly. As of right now, RcppExamples does not document every class but it should already provide a fairly decent start for using Rcpp. And many more actual usage examples are ... in the over two-hundred unit tests in Rcpp. Update: Now actually showing new rather than classic API. Tue, 09 Mar 2010
Rcpp 0.7.8
This is a minor feature release based on a over three weeks of changes that are summarised below in the extract from the NEWS file. Some noteworthy highlights are
The full NEWS entry for this release follows:
0.7.8 2010-03-09
o All vector classes are now generated from the same template class
Rcpp::Vector
As always, even fuller details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. A local directory has source and documentation too. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Update: Two links corrected. Thu, 25 Feb 2010
R and Sudoku solvers: Plus ca change...
But what everybody seems to be forgetting is that R has had a Sudoku solver for years, thanks to the sudoku package by David Brahm and Greg Snow which was first posted four years ago. What comes around, goes around. With that, and about one minute of Emacs editing to get the Le Monde puzzle into the required ascii-art form, all we need to do is this:
That took all of five seconds while my computer was also compiling a particularly resource-hungry C++ package....R> library(sudoku) R> s <- readSudoku("/tmp/sudoku.txt") R> s [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 8 0 0 0 0 1 2 0 0 [2,] 0 7 5 0 0 0 0 0 0 [3,] 0 0 0 0 5 0 0 6 4 [4,] 0 0 7 0 0 0 0 0 6 [5,] 9 0 0 7 0 0 0 0 0 [6,] 5 2 0 0 0 9 0 4 7 [7,] 2 3 1 0 0 0 0 0 0 [8,] 0 0 6 0 2 0 1 0 9 [9,] 0 0 0 0 0 0 0 0 0 R> system.time(solveSudoku(s)) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 8 4 9 6 7 1 2 5 3 [2,] 6 7 5 2 4 3 9 1 8 [3,] 3 1 2 9 5 8 7 6 4 [4,] 1 8 7 4 3 2 5 9 6 [5,] 9 6 4 7 8 5 3 2 1 [6,] 5 2 3 1 6 9 8 4 7 [7,] 2 3 1 8 9 4 6 7 5 [8,] 4 5 6 3 2 7 1 8 9 [9,] 7 9 8 5 1 6 4 3 2 user system elapsed 5.288 0.004 5.951 R> Just in case we needed another illustration that it is hard to navigate the riches and wonders that is CRAN... Thu, 18 Feb 2010
U of C ACM talk
Rcpp 0.7.7
0.7.7 2010-02-14
o new template classes Rcpp::unary_call and Rcpp::binary_call
that facilitates using R language calls together
with STL algorithms.
o fixed a bug in Language constructors taking a string as their
first argument. The created call was wrong.
As always, even fuller details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Sat, 13 Feb 2010
Rcpp 0.7.6
The changes are summarised below in the NEWS file snippet, more details are in the ChangeLog as well.
0.7.6 2010-02-12
o SEXP_Vector (and ExpressionVector and GenericVector, a.k.a List) now
have methods push_front, push_back and insert that are templated
o SEXP_Vector now has int- and range-valued erase() members
o Environment class has a default constructor (for RInside)
o SEXP_Vector_Base factored out of SEXP_Vector (Effect. C++ #44)
o SEXP_Vector_Base::iterator added as well as begin() and end()
so that STL algorithms can be applied to Rcpp objects
o CharacterVector gains a random access iterator, begin() and end() to
support STL algorithmsl; iterator dereferences to a StringProxy
o Restore Windows build; successfully tested on 32 and 64 bit;
o Small fixes to inst/skeleton files for bootstrapping a package
o RObject::asFoo deprecated in favour of Rcpp::as
As always, even fuller details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Tue, 09 Feb 2010
Rcpp 0.7.5
The changes are summarised below in the NEWS file snippet, more details are in the ChangeLog as well.
0.7.5 2010-02-08
o wrap has been much improved. wrappable types now are :
- primitive types : int, double, Rbyte, Rcomplex, float, bool
- std::string
- STL containers which have iterators over wrappable types:
(e.g. std::vector
As always, even fuller details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Fri, 05 Feb 2010
R / Finance 2010 Open for Registration
See you in Chicago in April! Wed, 03 Feb 2010
RProtoBuf 0.1-0
RProtoBuf had a funny start. I had blogged about the 12 hour passage from proof of concept to R-Forge project following the ORD session hackfest in October. What happened next was as good. Romain emailed within hours of the blog post and reminded me of a similar project that is part of Saptarshi Guha's RHIPE R/Hadoop implementation. So the three of us--Romain, Saptarshi and I---started emailing and before long it becomes clear that Romain is both rather intrigued by this (whereas Saptarshi has slightly different needs for the inner workings of his Hadoop bindings) and was able to devote some time to it. So the code kept growing and growing at a fairly rapid clip. Til that stopped as we switched to working feverishly on Rcpp to both support the needs of this project, and to implement ideas we had while working on this. That now lead to the point where Rcpp is maturing in terms of features, so we will probably have time come back to more work on RProtoBuf to take advantage of the nice templated autoconversions we now have in Rcpp. Oddly enough, the initial blog post seemed to anticipate changes in Rcpp.
Anyway --
RProtoBuf
is finally here and it already does a fair amount of magic based of code reflection
using the R> library( RProtoBuf ) ## load the package R> readProtoFiles( "addressbook.proto" ) ## acquire protobuf information R> bob <- new( tutorial.Person, ## create new object + email = "bob@example.com", + name = "Bob", + id = 123 ) R> writeLines( bob$toString() ) ## serialize to stdout name: "Bob" id: 123 email: "bob@example.com" R> bob$email ## access and/or override [1] "bob@example.com" R> bob$id <- 5 R> bob$id [1] 5 R> serialize( bob, "person.pb" ) ## serialize to compact binary format There is more information at the RProtoBuf page, and we already have a draft package vignette, a 'quick' overview vignette and a unit test summary vignette. More changes should be forthcoming as Romain and I find time to code them up. Feedback is as always welcome. /code/rprotobuf | permanent link Sun, 31 Jan 2010
Rcpp 0.7.4
The release once again combines a number of necessary fixes with numerous new features:
Lastly, we had a remaining Windows build issue. Also, Brian Ripley and Uwe Ligges kindly sent us a small patch supporting the new Windows 64-bit builds using the new MinGW 64-bit compiler for Windows -- so release 0.7.5 may follow in due course. The NEWS file entry for release 0.7.4 is as follows:
0.7.4 2010-01-30
o matrix matrix-like indexing using operator() for all vector
types : IntegerVector, NumericVector, RawVector, CharacterVector
LogicalVector, GenericVector and ExpressionVector.
o new class Rcpp::Dimension to support creation of vectors with
dimensions. All vector classes gain a constructor taking a
Dimension reference.
o an intermediate template class "SimpleVector" has been added. All
simple vector classes are now generated from the SimpleVector
template : IntegerVector, NumericVector, RawVector, CharacterVector
LogicalVector.
o an intermediate template class "SEXP_Vector" has been added to
generate GenericVector and ExpressionVector.
o the clone template function was introduced to explicitely
clone an RObject by duplicating the SEXP it encapsulates.
o even smarter wrap programming using traits and template
meta-programming using a private header to be include only
RcppCommon.h
o the as template is now smarter. The template now attempts to
build an object of the requested template parameter T by using the
constructor for the type taking a SEXP. This allows third party code
to create a class Foo with a constructor Foo(SEXP) to have
as
As always, even fuller details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page Thu, 21 Jan 2010
Rcpp 0.7.3
This release combines a number of under-the-hood fixes and enhancements with one bug fix:
As always, full details are in the ChangeLog on the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page /computers/linux/debian/packages | permanent link Thu, 14 Jan 2010
RQuantLib 0.3.2 released
This versions brings a few cleanups due to minor
Rcpp changes (in
essence: we now define the macro It also adds a number of calendaring and holiday utilities that Khanh just added: tests for weekend, holiday, endOfMonth as well dayCount, date advancement and year fraction functions commonly used in fixed income. Full changelog details, examples and more details about this package are at my RQuantLib page. /computers/linux/debian/packages | permanent link Tue, 12 Jan 2010
Rcpp 0.7.2
A lot of the momentum for the new API is continuing, thanks in large part to Romain. A number of new classes have been added, and existing ones have been enhanced. There are more unit tests than ever, and more documentation. We have better build support (with g++ version detection so that we can add some C++0x support where available) and a new examples sub-directory. We did take one toy away, though. The Doxygen-generated docs were getting so big that we decided to keep them out of the source tarball. (And arguably, they are also too volatile.) We still have the browseable html docs as well as the pdf version (now at over 300 pages!). And we added zip archives of the docs in html, latex, and man format for download. As always, full details are in the ChangeLog on the Rcpp page. Questions, comments etc: bring them to the rcpp-devel mailing list off the R-Forge page /computers/linux/debian/packages | permanent link Thu, 07 Jan 2010
Review of 'Computational Statistics: An Introduction to R' in JSS
RInside release 0.2.1
This is a maintenance release building on the recent
0.2.0 release
which added Windows support (provided you use the Rtools toolchain for
Windows). In this release, we changed the startup initialization so that
The new release should hit CRAN mirrors tomorrow, and is (as always) available from my machine too. /computers/linux/debian/packages | permanent link Tue, 05 Jan 2010
littler 0.1.3
littler provides This version adds a few minor behind-the-scenes improvements:
As usual, our code is available via our svn archive or from tarballs off my littler page and the local directory here. A fresh package is in Debian's incoming queue and will hit mirrors shortly. /computers/linux/debian/packages | permanent link Sat, 02 Jan 2010
Rcpp 0.7.1
A lot has changed under the hood since 0.7.0, and this is the first release that really reflects many of Romain's additions. Some of the changes are
/computers/linux/debian/packages | permanent link Mon, 28 Dec 2009
inline 0.3.4 released
A new release of Rcpp will probably follow in due course as we can now depend on this new inline version; Romain has also put nice new code in around exceptions and we may add some more on external pointers. Good times ... /computers/linux/debian/packages | permanent link Wed, 23 Dec 2009
Beancounter minor bug fix release 0.8.9
/computers/linux/debian/packages | permanent link Tue, 22 Dec 2009
RInside release 0.2.0
The biggest news is that we now support builds on Windows -- if and only
if you use the R toolchain -- more on that below. Since I had first released
RInside people
had emailed about support on Windows. However, Richard Holbrey deserves
special mention as he actually sat down and tried to build it. Over a few
email exchanges we made decent progress, but stalled. More recently, I
sat down and had another go and lo and behold, it works. This required a few
Now, to make this plain: you need
That said, if you have the proper tools, things are peachy. Install the
package, change into the Happy embedding! /computers/linux/debian/packages | permanent link Sun, 20 Dec 2009
Rcpp and inline example
The following R code defines a character
variable ## now use Rcpp to pass down a parameter for the seed, and a vector size gslrng <- ' int seed = RcppSexp(s).asInt(); int len = RcppSexp(n).asInt(); gsl_rng *r; gsl_rng_env_setup(); std::vector<double> v(len); r = gsl_rng_alloc (gsl_rng_default); gsl_rng_set (r, (unsigned long) seed); for (int i=0; i<len; i++) { v[i] = gsl_rng_get (r); } gsl_rng_free(r); return RcppSexp(v).asSexp(); ' ## turn into a function that R can call ## compileargs redundant on Debian/Ubuntu as gsl headers are found anyway funx <- cfunction(signature(s="numeric", n="numeric"), gslrng, includes="#include <gsl/gsl_rng.h>", Rcpp=TRUE, cppargs="-I/usr/include", libargs="-lgsl -lgslcblas") print(funx(0, 5))
The As the R level, we now have a function of two arguments returning a vector of RNG draws of the given lenth and using the given seed.
Also note how we tell Finally, we simply call our freshly compiled, linked and loaded C++ function with arguments zero for the seed and five for the length, and print the results vector returned to R from C++. /computers/linux/debian/packages | permanent link Sat, 19 Dec 2009
Rcpp 0.7.0
This release has a couple new features :
/computers/linux/debian/packages | permanent link Sun, 13 Dec 2009
RQuantLib 0.3.1 released
Full changelog details, examples and more details about this package are at my RQuantLib page. /computers/linux/debian/packages | permanent link Sun, 06 Dec 2009
digest 0.4.2
/computers/linux/debian/packages | permanent link Tue, 01 Dec 2009
Updated slides for 'Introduction to HPC with R' (now with correct URLs)
As mentioned yesterday, I spent a few days last week in Japan as I had an opportunity to present the Introduction to High-Performance Computing with R tutorial at the Institute for Statistical Mathematics in Tachikawa near Tokyo thanks to an invitation by Junji Nakano. An updated version of the presentations slides (with a few typos corrected) is now available as is a 2-up handout version. Compared to previous versions, and reflecting the fact that this was the 'all-day variant' of almost five hours of lectures, the following changes were made:
Comments and suggestions are, as always, appreciated. Sun, 29 Nov 2009
Back from Tokyo
Lisa and I turned this into a brief one-week trip to Kyoto and Tokyo, and we had a truly wonderful time on what was our first visit to Japan. I should blog some more about it, but now I will give in to the jet lag and catch up on some sleep... Tue, 10 Nov 2009
Rcpp 0.6.8
So 0.6.8 went onto CRAN and into Debian earlier in the day. Beside the aforementioned fix, I also split off a more class headers and implementations into their own files but changed no actual functionality. As always, more details are at the Rcpp page. /computers/linux/debian/packages | permanent link Mon, 09 Nov 2009
R / Finance 2010 Call for Papers
So without further ado, and given the success of our initial R / Finance 2009 conference about R in Finance, here is the call for papers for next spring:
See you in Chicago in April! Sun, 08 Nov 2009
Rcpp 0.6.7
One change is that a new type Another small change was the addition of a self-contained example of a function callback from C++ into R which wasn't all that well documented before; this was in response to a user request.
Finally, I started /computers/linux/debian/packages | permanent link Sat, 31 Oct 2009
Adventures with Comcast: Part ohnoesnotanotherone in an ongoing series
But I think this week may top everything. I'll just try to jot down some notes before I forget all the gory details:
/computers/broadband | permanent link Thu, 22 Oct 2009
From ORD Sessions to R-Forge in 12 hours with RProtoBuf
Sounded good, and I needed an excuse to try to mix the awesome Protocol Buffers with my favourite data tool, R. What are Protocol Buffers? To quote from the Google overview page referenced above: Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.and later on that page: Protocol buffers are now Google's lingua franca for data – at time of writing, there are 48,162 different message types defined in the Google code tree across 12,183 .proto files. They're used both in RPC systems and for persistent storage of data in a variety of storage systems.
So three hours later, I had an implementation of the 'addressbook
reader' C++ example wrapped in a tiny yet complete R package that
passed So before going to bed, I quickly registered a new project at R-Forge, everybody's favourite R hosting site, and thanks to the tireless Stefan Theussl (and some favourable timezone differences) the project was approved and the stanza available by the time I got up. So I quickly filled the SVN repo and, presto, we had the RProtoBuf project at R-Forge within 12 hours of the ORD Sessions hackfest. I will try to follow up on RProtoBuf in a couple of days, this may lead to some changes in my Rcpp R / C++ interface package as well. /computers/misc | permanent link Mon, 19 Oct 2009
RPostgreSQL 0.1-6
As always, all the details (including the full ChangeLog) are at the local RPostgreSQL page, the RPostgreSQL package page at CRAN and of course the Google Code repository for RPostgreSQL. /computers/linux/debian/packages | permanent link Fri, 16 Oct 2009
Dianne Reeves: Strings Attached at the CSO
Given that Dianne Reeves (who we had seen in just a few month earlier in our neighbourgood) has plenty of stage presence, the format made for a more intimate concert yet with plenty of groove at times too. The three had been touring in Europe for 25 shows, and it was a really nice performance and a great way to end the week. Recommend if you can catch them somewere. /music/jazz/live | permanent link Tue, 13 Oct 2009
RPostgreSQL 0.1-5
This is a maintenance and bug fix release that addresses four of the seven issue at the Google Code page. Two more are really enhancement requests for which we encourage patches as we are unlikely to have to write them, and the last issue I have been unable to replicate. This release has benefitted greatly from the generous help of Neil Tiffin who now looks after all things OS X and keeps a good eye on the Google Code site (where I had, ahem. overlooked the existence of these open issue tickets for a few months), Joe Conway who we can count on for hard-core PostgreSQL issues as well as Jeff Horner for general R, DBI and database smarts. Some more details (including the full ChangeLog) are at the local RPostgreSQL page, the RPostgreSQL package page at CRAN and of course the Google Code repository for RPostgreSQL. /computers/linux/debian/packages | permanent link Mon, 12 Oct 2009
Zut alors!
/sports/running | permanent link Sun, 11 Oct 2009
Chicago Marathon 2009
First, of course, was the Chicago weather. After two successive marathon in excessive heat --- the 2007 race I completed, poorly, with its thousands of runners forced to abandon when the race was cancelled due to excessive heat, and the 2008 version which I skipped as I ran Berlin that year just weeks before Chicago, this year had forecasts of temperatures in the thirties and possibly snow the night before. Well, the weather cleared up -- but with those clear skies we still got a severe weather alert for the area due to frost! So at the (now earlier by 30 minutes) race start, it was very nippy and in the higher 30s, improving steadily under sunny skies. Overall, a little chilly and hence not exactly ideal, but not too bad in the grand scheme of things. A little windy coming up Michigan Avenue. But hey, Wanjiru still finished with a course record though still well off the world record. So maybe not a fail after all. The second fail, though, was my GPS which I had just blogged about yesterday (albeit indirectly). I had had my issues with the previous (much simpler and older) Forerunner 205 which lost satellite tracking when running downtown amidst the skyscrapers. I had high hopes that this newer model would do better. But no, not only did it loose track within the first few miles, it even managed to outdo the older model by turning its GPS tracking off in the later stages. Now that's a fail! The third and final fail, unfortunately, concerns my run. Training had gone well enough to let me hope for another decent race. However, a latent cold during the last two weeks had left me somewhat afraid I might not do well. Things felt better yesterday, and I ended up running a decent first eighteen miles to the waterstop the rest of my household was working. And thereafter: well let's just say that the wheels came off. I ended up with a 3:25:40 (or around 7:51 min/mile and 4:53 min/km) which is not terrible but also not one of my better races. I updated the two race data geekery charts shown here before to illustrate the fail. As I am running out of shades of blue for Chicago, I show the 2009 race in purple. A decent, flat chat indicating a reasonably steady pace throughout most of the race ... followed by one of the very worst finished. And as discussed above, I cannot really blame the weather either.
I also updated my 'performance by race type through time' chart which suggests that I may be getting slower for marathons (if we allow for a non-linear effect). Eek.
/sports/running | permanent link Sat, 10 Oct 2009
R for system administration and scripting
One of such cases just happened a few minutes ago. The aforementioned Garmin Forerunner 405 can cooperate quite nicely with Linux using the gant reader for the ant wireless communication protocol between the usb hardware dongle and the Garmin 405. (Sources for gant are both this file and this git archive.) I had meant to blog about this tool and the resulting files one of these days anyway, but today I just want to mention that the default filenames created by the program were somewhat horrid such as 20.09.2009 101112.TCX to denote the 20th of September of this year at 10:11h and 12 seconds. As we all know, filenames with spaces are bad for the environment as well as plain annoying. So I had made the simple change in the C sources to switch to a saner format such as 20090920-101112.TCX (and I see that the git archive now contains a similar fix). But that still left me with some 80+ files with the dreaded names. There are of course many ways to skin this cat and to rename the files in bulk. However, I found the following four lines to be fairly succinct #!/usr/bin/r files <- dir(".", pattern=".*\\.TCX$") res <- lapply(files, function(f) { pt <- strptime(f, "%d.%m.%Y %H%M%S.TCX") # parsed time ft <- strftime(pt, "%Y%m%d-%H%M%S.TCX") # formatted time file.rename(f, ft) })as they show, among other things,
Lastly, I do not mean to imply that Python or Perl or Ruby or (insert favourite tool here) cannot do it equally well. I simply meant to say that programmatically creating new filenames is definitely easier in R than it would have been in shell. And as an added bonus, we even get fully parsed time objects that I could have tested for. But then tests and documentation never get written on a Saturday. Tue, 29 Sep 2009
RInside release 0.1.1, and a fresh example
However, today I committed a new example to SVN archive at R-Forge. It is based on this thread on r-devel. Abhijit Bera tries to do this in C, but to me his questions provide rather clear motivation for showing how much simpler things can be via C++ and the Rcpp classes along with RInside. Using a small example, the task was to pass a weight vector to a portfolio solver from the Rmetrics package fPortfolio and to then access the computed solution. The original poster struggled with access from C to the S4 classes used by fPortfolio and could not set the weights. But when using RInside, we simply pass a C++ vector of weights down to R, solve the problem and pass a solution vector back using the handy evaluation of R expressions: // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*- // // Another simple example inspired by an r-devel mail by Abhijit Bera // // Copyright (C) 2009 Dirk Eddelbuettel and GPL'ed #include "RInside.h" // for the embedded R via RInside #include "Rcpp.h" // for the R / Cpp interface used for transfer #include <iomanip> int main(int argc, char *argv[]) { try { RInside R(argc, argv); // create an embedded R instance SEXP ans; std::string txt = "suppressMessages(library(fPortfolio))"; if (R.parseEvalQ(txt)) // load library, no return value throw std::runtime_error("R cannot evaluate '" + txt + "'"); txt = "lppData <- 100 * LPP2005.RET[, 1:6]; " "ewSpec <- portfolioSpec(); " "nAssets <- ncol(lppData); "; if (R.parseEval(txt, ans)) // prepare problem throw std::runtime_error("R cannot evaluate '" + txt + "'"); const double dvec[6] = { 0.1, 0.1, 0.1, 0.1, 0.3, 0.3 }; // choose any weights you want const std::vector<double> w(dvec, &dvec[6]); R.assign( w, "weightsvec"); // assign STL vector to R's 'weightsvec' variable txt = "setWeights(ewSpec) <- weightsvec"; if (R.parseEvalQ(txt)) // evaluate assignment throw std::runtime_error("R cannot evaluate '" + txt + "'"); txt = "ewPortfolio <- feasiblePortfolio(data = lppData, spec = ewSpec, constraints = \"LongOnly\"); " "print(ewPortfolio); " "vec <- getCovRiskBudgets(ewPortfolio@portfolio)"; if (R.parseEval(txt, ans)) // assign covRiskBudget weights to ans throw std::runtime_error("R cannot evaluate '" + txt + "'"); RcppVector<double> V(ans); // convert SEXP variable to an RcppMatrix R.parseEval("names(vec)", ans); // assign columns names to ans RcppStringVector names(ans); for (int i=0; i<names.size(); i++) { std::cout << std::setw(16) << names(i) << "\t" << std::setw(11) << V(i) << "\n"; } } catch(std::exception& ex) { std::cerr << "Exception caught: " << ex.what() << std::endl; } catch(...) { std::cerr << "Unknown exception caught" << std::endl; } exit(0); } /computers/linux/debian/packages | permanent link Thu, 24 Sep 2009
digest 0.4.0 and 0.4.1
The new package will appear shortly on its CRAN page; the R-Forge page has access to the Subversion repo etc and otherwise there's always my local my local digest page. Oh, and 0.3.1 was never blogged about as it was just a maintenance release that added a single cast and an edit to the DESCRIPTION file. /computers/linux/debian/packages | permanent link Sun, 20 Sep 2009
RInside release 0.1.0 -- and now on CRAN
This release improves on the build process and should work on any sane Unix-alike operating system. A few more examples were added or extended. Details and the full ChangeLog are on my RInside page, and there is now a RInside page on CRAN as well. /computers/linux/debian/packages | permanent link Sun, 13 Sep 2009
Chicago Half Marathon 2009
As for the race itself, I didn't run it quite as evenly as I had hoped, faded a little around mile ten and eleven and came in at 1:34:54, or just under 7:15 min/mile. Not a bad time---I have done better (e.g. last year) but also worse. All in all still one my very favourite races, and this year with a once-again improved course that featured even more running along the lake. I will probably be back next year. /sports/running | permanent link Sun, 06 Sep 2009
RQuantLib 0.3.0 Windows build snag
/computers/linux/debian/packages | permanent link Sat, 05 Sep 2009
RQuantLib 0.3.0 released
This version, the first in a new '0.3.*' release series, contains all the work that Khanh Nguyen did during his Google Summer of Code participation which I had mentioned a while back and for which I acted as mentor. And Khanh did great. We now have a lot more Fixed Income functionality; I include the full ChangeLog entry below. I also added some simple calendaring support and the odd fix here or there while mentoring. All of this had been available while technically 'in progress' thanks to support provided by the R-Forge project hosting where SVN checkouts as well as nightly binaries are provided. A few more details are on the RQuantLib page and I hope to add a few more examples. As promised, the ChangeLog entry: 2009-09-05 Dirk Eddelbuettel /computers/linux/debian/packages | permanent link Wed, 12 Aug 2009
random 0.2.1
The new package is available here and should appear on CRAN shortly. /computers/linux/debian/packages | permanent link Tue, 04 Aug 2009
State of the Art in Parallel Computing with R: Now published
Rcpp 0.6.6
While the /computers/linux/debian/packages | permanent link Sun, 19 Jul 2009
New RInside release
This releases owes a big Thank you! to Miguel Lechón who not only noticed errant behaviour and occassional segfaults with overly long commands sent to the embedded R, but even traced it to an oversight of mine in a simple memory buffer class and provided the one-line fix to reset a pointer! Much appreciated, especially as I got his mail two days before I talked about Rcpp and RInside at UseR! 2009 . The other changes are mostly cleanups, additions of two more test examples (to replicate the bug report) and some minor additions of a few new assign() functions to pass data between C++ and the embedded R session. /computers/linux/debian/packages | permanent link Mon, 13 Jul 2009
cran2deb: Would you like 1700+ new Debian / R packages ?
This is essentially a '2.0' version of earlier work with Steffen Moeller and David Vernazobres which we had presented in 2007. Then, the approach was top-down and monolithic which started to show its limits. This time, the idea was to borrow the successful bottom-up approach of my CRANberries feed. The bulk of the work was done by Charles Blundell as part of his Google Summer of Code 2008 project which I had suggested and mentored. After that project had concluded, we both felt we should continue with it and bring it to 'production'. The CRAN hosts provided us with a (virtual Xen) machine to build on, and we are now ready to more publically announce the availability of the repositories for i386 and amd64: deb http://debian.cran.r-project.org/cran2deb/debian-i386 testing/and deb http://debian.cran.r-project.org/cran2deb/debian-amd64 testing/ A few more details are provided in our presentation slides. We look forward to hearing from folks using; the r-sig-debian list may be a good venue for this. Sun, 12 Jul 2009
useR 2009 in Rennes: Recap and slides
As last year (and again at the BoC in December), I presented a three-hour tutorial on high-performance computing with R. This covers profiling, vectorisation, interfacing compiled code, debugging, parallel computing, as well as scripting and automation. Slides, and a 2-up version, are now on my presentations page. I also gave two regular conference presentations. The first was on my Rcpp and RInside packages which facilitate interfacing R and C++. The second talk, based on joint work with Charles Blundell, describes our cran2deb system for creating Debian packages of essentially all CRAN packages. I will try to follow up on this with another post. Slides from these talks are also on my presentations page. Sat, 27 Jun 2009
R 2.9.1, CRANberries outage, and missing Java support
Speaking of broken, I had neither noticed that this R version now returns an additional field (for the repository) in the per-package metadata via available.packages(), nor that this change had broken my oh-so-useful and increasingly popular CRANberrries html and rss summaries of CRAN changes. So with the usual beta and rc releases or R 2.9.1 in Debian starting a week prior, CRANberries had been silent for six days from Friday the 21st to last Thursday. I rectified it once I noticed, and changed the code to no longer fall on its nose at that spot. Sorry for the few days without service. Sun, 31 May 2009
Ubuntu Developer Summit in Barcelona
All told, a well-organised conference in a nice setting -- two stone throws from the legendary Camp Nou. Unfortunately, I had to leave by Wednesday so I missed what was undoubtedly quite a scene in Barcelona following Barca's dismantling of Man U in this year's Champions League final. /computers/misc | permanent link Sat, 30 May 2009
JPM Chase Corporate Challenge 2009
We fielded a small but spirited team of nine runners. I finished with a decent (hand-stopped) time of 22 minutes and 27.93 seconds for the 3.5 miles -- or a 6:25 min/mile pace. That is among the fasters times but not quite the fastest compared to the other six times I have run this. Most importantly, everybody seems to have had a blast. And we did set a record for longer post-race party which sets a nice precedent for 2010. /sports/running | permanent link Sat, 23 May 2009
Temporary Debian mail outage
If you happened to have sent me mail to my debian.org address during that time period, you may have gotten a hard reject ('550 Administrative prohibition') as did a test mail of mine. In this case mail may not be respooled, so please do send it again. My alternate address, formed by my first name followed by the family name and the commercial top-level domain, remained functional as a fallback. /computers/misc | permanent link Fri, 01 May 2009
Brad Mehldau at the CSO
The first set was performed as a (strictly acoustic) trio with Larry Grenadier on bass and Jeff Ballard on drums. After several compositions by Mehldau and a brazilian samba piece, the first set closed with a rendition of 'Holland' from Sufjan Stevens' album Michigan which was truly beautiful. The second set had Mehldau performing solo, again with several compositions of his own as well as one from Neil Young's classic 'The Needle and the Damage Done' leading two two pieces from the Sound of Music including an amazing, yet really different 'My favourite things' that just hushed a piece of the central melody along with a strond rhythmic element. Lovely. And then to cap it all off, four encores. Highly recommended. /music/jazz/live | permanent link Thu, 30 Apr 2009
GSoC 2009 Chicago area meeting
/computers/misc | permanent link Wed, 29 Apr 2009
Slides from most recent R and HPC tutorial
This tutorial was a shorter format of just an hour which did not allow for any parallel computing with R. However, parallel computing with R via MPI, snow, nws, ... is covered in the slides from December's workshop at the BoC. Tue, 28 Apr 2009
Google Summer of Code 2009: R / Quantlib
We had twenty-two applications to review for the R project, including three for the RQuantLib topic I had proposed. Khanh's application was clearly among the best, and I look forward to helping him do cool stuff over the summer. He already posted two short emails on the r-sig-finance and the quantlib-user lists soliciting suggestions and comments. So if you have comments regarding R and QuantLib, please get in touch with him or me! /computers/misc | permanent link Mon, 27 Apr 2009
Review of 'Analysis of Integrated and Cointegrated Time Series with R (2nd ed)' in JSS
|
|||||