Say it in R with "by", "apply" and friends

Iris versicolor 
By Danielle Langlois
License: CC-BY-SA

R is a language, as Luis Apiolaza pointed out in his recent post. This is absolutely true, and learning a programming language is not much different from learning a foreign language. It takes time and a lot of practice to be proficient in it. I started using R when I moved to the UK and I wonder, if I have a better understanding of English or R by now.

Languages are full of surprises, in particular for non-native speakers. The other day I learned that there is courtesy and curtsey. Both words sounded very similar to me, but of course created some laughter when I mixed them up in an email.

With languages you can get into habits of using certain words and phrases, but sometimes you see or hear something, which shakes you up again. So did the following two lines in R with me:

f <- function(x) x^2
sapply(1:10, f)
[1]   1   4   9  16  25  36  49  64  81 100


Post a Comment

Credit rating by country

The financial crisis has put a lot of pressure on countries' long-term foreign currency credit ratings, with France recently being downgraded by S&P. Wikipedia provides a list of countries by credit ratings as report by US rating agencies S&P, Fitch, Moody's and Dagong, a Chinese rating agency.

So, what does the world look like today through the eyes of those rating agencies?

I use the R packages XML and googleVis to read and display the data from Wikipedia with just a few lines.


Post a Comment

Managing change

No comments

Why the old and the new need to share time together

It takes time to appreciate the new. Even if the new is much better than the old. It is easy to forget when you yourself created the exciting new.

At the end of August 2011 Google announced a new Blogger interface. The new interface offered about the same functionality, but had a different look and feel. At first I was reluctant to use it. I just wanted to get my job done. I knew the old interface, so why disturbe me with something else which does just the same?

Old Blogger interface

I was relieved to see that there was a button, which allowed me to switch back to the old interface. So I continued to use the old interface, although occasionally Google would offer me the new interface after login. Eventually I started to play around with the new interface. At times when I was bored and looking for a good excuse to waste my time. After a while I started to like the new interface and used it more often and then I stopped switching back to the old when Google offered me the new on login. It appeared cleaner, more contemporary and organised than the old. Now I have switched completely to the new interface. After a four months transition period!

New Blogger interface

There is something to be learned from this experience

Suppose you write analysis reports for others, e.g. colleagues, clients, friends, students, etc. and you have a new idea, which will make your report so much better. Maybe a better structure, a new R package, a new plot, something really sophisticated. You are excited about this, you implement it and send your report out to your readers.

Then: No feedback.

Appreciating change takes time.

Here is a suggestion: Implement your next great idea to improve your analysis report. Just because it is so much fun and your are really excited about the new. However, continue to produce the old style report and send it out with the new. Hopefully your excitement will sparkle over to the reader. But acknowledge that not all of them will have time to embrace the new immediately. They read the report for a specific purpose, e.g. table X on page Y. Hence give your reader the space to find his own time to review the new report, eventually he will listen and hopefully switch. But do listen to the reader as well and value his feedback. Easier said than done.

There is another aspect to it. Sending out the new with the old allows you to fail. You have a safety net. Some of your ideas might actually be not that great after all. I believe, we can only learn and succeed by making lots of small failures.


  • Producing the old and the new at the same time is of course only possible, if you have a slick automated reporting system. You find plenty of ideas on R-Bloggers.
  • I wonder, what would have happened if the transition period between the old national coins and notes and the Euro would have been longer than two months in 2002?

No comments :

Post a Comment

Feedback from vignette survey

1 comment

Many thanks to all who participated in the survey about writing R package vignettes.

Following my post last Thursday the responses came in quickly in the evening and all day on Friday. Since Saturday the response rate has been decreasing constantly and I think it is time for a summary based on the 56 responses received.

Summary - How to write a good vignette

  • Length: Trust yourself, but aim for about 20 pages.
  • Language: Don't use language which assumes that the reader is an R and/or subject expert.
  • Structure: Include at least the following sections:
    • Examples
    • Introduction
    • Case studies
    • References
    It would be nice to include also sections on:
    • Support
    • Motivation
    • Road map
  • Examples: Use lots of examples and don't repeat just the examples from the help pages.
  • Get inspiration from: Rcpp, reshape, plyr, vegan, and see below for more.
  • Secrets of good vignettes:
    • Provide an introduction with a clear purpose of the package.
    • Work with case studies, walk the reader through a task from start to finish.
    • Demonstrate the non-default arguments of the package functions, highlight why and when you want to change them.
    • Write briefly and concisely, but provide reference/footnotes to relevant literature and further help.
    • Provide dummy data to play with.
    • Discuss limitations.
  • What else: Potentially split the vignette into several documents, see Rcpp for an example.

1 comment :

Post a Comment

Survey: Writing package vignette

No comments
I am currently co-writing the vignette for the ChainLadder package and wonder what I should be focusing on. I have co-written the vignette of the googleVis package in the past and based it purely and what I thought would work. So, this is an experiment to find out, if user feedback will help me to write a better vignette. Let's see how it develops. I will make the data available once I have at least 10 submission.


No comments :

Post a Comment