Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Image

R In a Nutshell 91

joel.neely writes "R is a statistical computing environment that is fully-compliant with state-of-the-art buzzwords: free, open-source, cross-platform, interactive, graphics, objects, closures, higher-order functions, and more. It is supported by an impressive collection of user-supplied modules through CRAN, the 'Comprehensive R Archive Network.' And now it has its own O'Reilly Nutshell book, R in a Nutshell, written by Joseph Adler. I am pleased to report that Adler has risen to the challenge of the highly-regarded 'Nutshell' franchise. As is traditional for the series, this title mixes introduction, tutorial, and reference material in a style that is well suited to a reader who already has a background in programming, but is a new or occasional user of R." Read on for the rest of Joel's review.
R in a Nutshell
author Joseph Adler
pages 672
publisher O'Reilly
rating 9/10
reviewer Joel Neely
ISBN 978-0-596-80170-0
summary A practical and engaging introduction to the R statistical system and its usage
As a curious newcomer to R who wanted to get going quickly, I was well-served by Part 1, which provided an R kickstart. Chapter 1 covers the process of getting and installing R. It is short, to the point, and just works, addressing Windows, Mac OS X, and Linux/Unix with equal attention. Chapter 2, on the R user interface, introduces the range of options for interacting with R: the GUI (both the standard version and some enhanced alternatives), the interactive console, batch mode, and the RExcel package (which supports R inside a certain well-known spreadsheet). Chapter 3 uses a set of interactive examples to provide a quick tour of the R language and environment, establishing a task-oriented theme that carries through the rest of the book. The last chapter of part 1 covers R packages. It summarizes the standard pre-loaded packages, introduces the tools to explore repositories and install additional package, and concludes by explaining how to create new packages.

As a polyglot programmer who is always interested in seeing how a new language approaches programs and their construction, I enjoyed Part 2, which described the R language. This section begins with an overview in chapter 5, and then devotes a chapter each to R syntax, R objects, symbols and environments (central to understanding the dynamic nature of R), functions (including higher-order functions), and R's own approach to object-oriented programming. This section closes in chapter 11, with a discussion of techniques and tips for improving performance.

As a busy professional with data sitting on my hard drive that I'd like to understand better, I appreciated Part 3, with its practical emphasis on using R to load, transform, and visualize data. Chapter 12 presented alternatives for loading, editing, and saving data, from the built-in data editor, through file I/O in a variety of formats, to a mature set of database access options. Chapter 13 illustrated a range of techniques for manipulating, organizing, cleaning, and sorting data, in preparation for presentation or more detailed analysis. Chapter 14 introduces the reader to the wealth of graphical presentation options built into the R environment. There are so many charting types and details that this chapter could have been overwhelming, but Adler keeps the interest high and the mood light by drawing on an engaging variety of data: toxic chemical levels, baseball statistics, the topography of Yosemite Valley, demographic data, and even turkey prices. Chapter 15 is devoted to lattice graphics, the R implementation of the "trellis graphics" technique for data visualization developed at Bell Labs. This chapter illustrates the power of lattice graphics by exploring the question of why more babies are born on weekdays than weekends.

As a non-statistician who still occasionally needs to do some number-crunching, I'm sure I'll be returning to Part 4, with its detailed explanations and illustrations of analysis tools and techniques–almost two-hundred pages worth. In chapters 16 through 20, Adler surveys topics in data analysis, probability, statistics, power tests, and regression modeling. As someone who has been offered too many medications and lost fortunes, I found much to enjoy in chapter 21, which used a variety of spam-detection techniques to illustrate the concepts of classification. Chapter 22, on machine learning, discusses several of the data mining techniques that R supports. Chapter 23 covers time series analysis, which may be used to identify trends or periodic patterns in data. Finally, chapter 24 offers an overview of Bioconductor, an open-source project focused on genomic data.

The book closes with a detailed reference to the standard R packages.

This is an impressive piece of work. In a volume of this size (about 650 pages), navigation is crucial, and I found both the organization of the chapters and index up to the task. I was able to follow the instructions and examples through the first several chapters of the book essentially without a hitch, and in the latter chapters the variety of illustrations and data sources added interest to what could have been very dull going.

I won't claim perfection for this book. There were a couple of explanations that could have been clearer, and one or two odd turns of phrase or rough edits. Out of all the code examples that I tried, I found exactly one that didn't seem to work without a minor correction. For a work of this size, that's actually pretty amazing!

As a long-time O'Reilly reader, I see Joseph Adler's R in a Nutshell as a welcome addition to the menagerie.

You can purchase R in a Nutshell: A Desktop Quick Reference from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

R In a Nutshell

Comments Filter:
  • by eldavojohn ( 898314 ) * <eldavojohn@noSpAM.gmail.com> on Monday July 19, 2010 @01:11PM (#32952956) Journal
    I also own this book in hard copy and cannot say enough good things about it. First I would like to add that the author is also the author of Baseball Hacks [oreilly.com], which might not sound like a popular title for Slashdot but if you are a nerd and techie/programmer then this book is for you! Never have I seen such statistical rigor and beautifying/aggregation of baseball statistics brought together. I only hope that Mr. Adler continues to produce such great technical volumes.

    In a volume of this size (about 650 pages)

    Not to criticize the reviewer but there's not enough written above to do this book justice. From the author's emphasis on preprocessing the data in another language (like Perl I think he uses in the Chapter 3 tutorial) so that it can be effortlessly ingested by R to the very last pages on machine learning in R, it's a good book. I actively lament that in college I was relegated to Matlab instead of R today and the many packages available on CRAN.

    I too would give this book a 9/10. It sometimes tries to inject tutorials in what should probably stick to being a reference and it might have too large of a scope for a single volume (I've read sets of books on machine learning and classification models) but this book is great for R beginners and R intermediates and as an R reference.

    Seriously if you know a statistician who codes or if you know a developer who values statistics then this is their book. Given the nature of the subject matter and the GPL'd beauty of R, you'll undoubtedly have a hard time finding a negative review of this book anywhere.

    • I don't own the book myself but a buddy of mine does, and he has also recommended it. It's funny that you mention Baseball Hacks - this friend of mine started using R for a new kind of statistical analysis of the World Cup here not long ago, and it actually is quite impressive with what he's come up with.

      Anyways - Of the few pages I've skimmed it was pretty good. I'd definately be a beginner, having only taken one stats course, but I could understand what was on the page and what the tutorials were teaching

    • First I would like to add that the author is also the author of Baseball Hacks [oreilly.com], which might not sound like a popular title for Slashdot but if you are a nerd and techie/programmer then this book is for you!

      I once developed baseball software for collecting data and then reporting the stats. I could never understand why all that data was collected and why those stats were calculated for the players. I guess it's part of the game to watch someone hit another home run or steal a base or strike out and imagine the stats changing - I seems to be a waste of time.

      If folks who follow all those stats put that time and effort to the stock market, they'd all be millionaires.

      • If folks who follow all those stats put that time and effort to the stock market, they'd all be millionaires.

        No, actually, they wouldn't.

        But I can introduce you to a lot of others who also seem to think so.

      • by rnj ( 779212 )

        Sean Forman (the guy who built baseball-reference.com) is by no means rich. But he was able to walk away from a tenured professorship (Math).

        If you're talking the guys who compile the raw data, they're basically people who like to keep score while they watch the game. I know several people who are scorers for Stats (speaking of which, the guy who started that company made millions) or other data sources.

        Then there are the people who are transcribing the historical data at retrosheet. These are all volunteer

    • How introductory is the book to someone with little to no statistics background? I saw the review says that part 4 covers this, but I wonder. If I get my textbooks out, I can figure out how to do things like standard deviation, best fit lines, etc, but that's about it. Would this book/tool be useful to someone with such a rudamentary understanding of statistics?
      • I had a stats course about 3 years ago - and so I mean I understand how to do them but I don't remember the formula's off hand like a stats major probably would. It's difficult to say exactly how much of that course I retained exactly.

        But in the few pages I read - I was able to follow along quite easily. I guess the best way to put it is: You have to have some understanding of Statistics and how they work, some familiarity with it, you won't be lost in it.

        Whether or not it will be USEFUL to you is another t

      • by Miseph ( 979059 )

        My guess is that if you aren't terribly familiar with statistics, you won't be entirely comfortable writing in a language designed to process complex statistical calculations.

        If the book is good enough that it can teach you stats, this guy deserves a Pulitzer, not a 9/10 from Slashdot.

    • by tool462 ( 677306 )

      I'm replying to you, since you seem familiar with R, but hopefully others can chime in as well.

      You imply that it's preferable to preprocess the data in another language, like Perl. What makes R valuable as a completely separate language, rather than being implemented as a library within an existing language? I'm assuming there must be something compelling you can't get out of adding
      use R;
      R::some_func(...);
      to your parsing code.

      • Re: (Score:3, Informative)

        by Yold ( 473518 )

        It handles data nicely. You can do things similar to list comprehensions in python. Implementing it in another language would break its semi-compatibility with S-plus. It also has data-types aimed towards the sorts of processing that it is designed for, like formula objects and data frames. Finally, the interactive mode is invaluable for exploratory analysis.

        You could build a ton of syntactic sugar into another language to get something close to R, in-fact, that's actually what basically all of the operatio

      • I have only limited experience with R, but FWIW, R contains some basic data importation routines for standard things like CSV or tab delineated data. There are also libraries that let you import files from other statistical packages like Stata, SPSS, etc. I imagine you could directly import XLS with a library, though I've never had to.

        I would hazard a guess and say that if you had to massage your data into a more machine-readable format, it'd be easier to do it in Perl, then load the result up into R, since

      • Re: (Score:3, Informative)

        This is really the old domain specific language argument. Why go for a DSL when you have a good general purpose language and you can add functionality with libraries. In the end, it's all about notation. You can add a matrix library to Java and write A = B.times(C).plus(D).invert().transpose(), or you can have a language that allows you to write A = inv(B*C+D)'. In R, the data frames are a really rich way of handling data, and the things you can do form a great working environment. For what it's worth,
  • I mean, how can they resist?
    • by selven ( 1556643 )

      I mean, how can they resist?

      "R" is resistance, so R apps should be able to resist just fine.

  • by mobby_6kl ( 668092 ) on Monday July 19, 2010 @01:25PM (#32953124)

    going to be called R-square?

  • R Tools (Score:4, Interesting)

    by Idgarad ( 530269 ) on Monday July 19, 2010 @01:42PM (#32953302) Homepage
    R is an excellent language to learn for just about every field. It's ability to import and export data to MS based resources such as Access, Excel, MS-SQL and other non-MS sources makes it a versital tool. It's commerical parent is S-PLUS and is nearly syntax identical with minor variations. Buy the book, use the tool, impress your Eve Online players by pinning down the July Tritanium prices and hitting the weekly averages within .5 ISK by doing time series analysis using regression plus ARIMA on the residuals. Find out cool things like Hulkageddon impacts frigate prices more then exhumers and MORE! FUN FOR THE WHOLE FAMILY (Except your big sister because she's icky and into boys....) For those what want to do google searches but find 'R' difficult there is the rseek.org site and a few quick links to get you started while you wait for the nutshell book to arrive in the mail. R Intro : http://www.itc.nl/~rossiter/teach/R/RIntro_ov.pdf [www.itc.nl] Programming in R: http://manuals.bioinformatics.ucr.edu/home/programming-in-r [ucr.edu] R Graph Gallery: http://addictedtor.free.fr/graphiques/ [addictedtor.free.fr] Big Resource I use: http://www.math.yorku.ca/SCS/StatResource.html [yorku.ca] The Little Handbook: http://www.tufts.edu/~gdallal/LHSP.HTM [tufts.edu] The Big N: http://www.itl.nist.gov/div898/handbook/ [nist.gov] There are hundreds of PDF references out there that can help as well, too many to list. Good luck, have fun.
  • Let me just say: wow, thanks for actually providing a review, rather than a blurb copied from the amazon listing.

    Seriously. Thanks.

  • ebook version (Score:4, Informative)

    by proxima ( 165692 ) on Monday July 19, 2010 @01:52PM (#32953406)

    As an (occasional) R user, I am excited to see a well-reviewed O'Reilly book on the language. I went and checked the major ebook stores - Amazon, BN, and Stanza, and none had the title.

    It turns out that in addition to the Safari books service, O'Reilly also sells DRM-free copies in epub, mobi, and PDF formats. This book is available here [oreilly.com]. It's not a huge discount over the printed version on Amazon ($6.50 less), though. I'm surprised, then, that it isn't available via the major stores.

    • by _|()|\| ( 159991 )

      Does O'Reilly sell any of its books through ebook intermediaries? Since they sell DRM-free versions direct, usually in multiple formats, I've never bothered to look. The only exception I've noticed is the occasional iPhone app.

      As for price, discounts aren't too hard to find. I ordered one book for half its listed ebook price. I've since gotten a couple of "deal of the day" ebooks for $10 each. Today's deal, listed prominently at oreilly.com [oreilly.com], is Learning the vi and Vim Editors (PDF only, unfortunately).

      • by proxima ( 165692 )

        Does O'Reilly sell any of its books through ebook intermediaries? Since they sell DRM-free versions direct, usually in multiple formats, I've never bothered to look. The only exception I've noticed is the occasional iPhone app.

        I've noticed a few have Kindle versions, but Stanza and its store has nearly the entire library. I guess this way O'Reilly gets the full purchase price rather than 70%.

        As for price, discounts aren't too hard to find. I ordered one book for half its listed ebook price. I've since gott

      • by JanneM ( 7445 )

        They sell some titles through the Android app store - but of course, that would probably count as a direct sale too. I'd like to get this book there but for some reason they mostly seem to sell Windows-related titles and not much else.

  • by by (1706743) ( 1706744 ) on Monday July 19, 2010 @01:57PM (#32953466)
    R!

    <drops pin...>
  • This book always sits right on my desk.

    R is a language that more people should really learn. The statistics community has definitely gravitated strongly to it. These days, with the thousands of packages on CRAN, it's much superior in functionality compared to other packages like STATA or SAS (I won't even go into people who use matlab for statistics), not to mention open source.

    It still is a bit slower than matlab for some matrix operations, but hopefully that will be improved in the future.

  • by Korbeau ( 913903 ) on Monday July 19, 2010 @02:14PM (#32953656)

    Based on Wikipedia, only G, H, N, O, P, U, V, W one-letter programming language names are left! Time to invent a new language :)

  • More than a decade ago I gave a talk on using R, Octave, MuPAD and other software in the classroom environment. It's a great package. Back then I used it to get through stats courses and plot disk usage in a graph. Now I'm using it to hammer through stock market data each night. To do the same with some commercial packages would cost thousands of dollars.

  • by dr_canak ( 593415 ) on Monday July 19, 2010 @02:44PM (#32954044)

    Not having read the O' Reilly book,

    I can't draw a comparison between the two, but I have been extremely pleased with "R In Action" by Robert Kabacoff

    and it can be found here:

    http://www.manning.com/kabacoff/ [manning.com]

    It's a work in progress, in that some 90% of the book is written. Pre-ordering the electronic version gives you the ability to download chapters as they are written, plus a final e-copy (or hard copy if you pay more) when it's completed.

    I have a high degree of familiarity with SPSS and SAS, and am learning R to get around the crazy licensing issues of the aforementioned programs. I have been very pleased with Kabacoff's book, as I had *no* familiarity with R before grabbing "R in Action." The publisher/author support a forum where purchasers can identify errors and/or make suggestions for improvements before the book goes to final press.

    Not sure if it is competition for "R in a Nutshell" or simply an additional reference, but worth checking out if you want to learn R. It's been very helpful for me.

    jeff

  • Is there a way to integrate R programs with another high level language like Java, for example to bind a R object to a Java interface? I have basic familiarity with R, and I would like to use programs written in R directly with other programs written in a object-oriented language, as opposed to do file i/o for the bridge between them.

    The general idea is to be able to take Java objects and pass them to R and do all the stats numbercrunching with smaller R programs, that are somehow integrated with a Java pro

    • Re: (Score:3, Informative)

      by Stradenko ( 160417 )

      JRI sounds like you want, but rJava is there when you want the reverse.
      http://rosuda.org/JRI/ [rosuda.org]
      http://rosuda.org/rJava/ [rosuda.org]

      Similar things exist for Python, Perl and probably others.

    • by js_sebastian ( 946118 ) on Monday July 19, 2010 @05:03PM (#32956300)
      I don't know about java, but when I have to use a statistics library available in R, I use rpy. It's a python module that lets you automagically call r functions very easily, and directly get back python objects or R objects for further processing with R methods. Python's introspection capabilities make this sleek and transparent, I doubt a Java binding could be as cool (though if you need java, there probably are solutions).

      and honestly, i'm so glad i don't have to use R directly... TFS says it is object oriented, but as far as I can recall all the library methods i tried just returned heterogeneous matrixes, with no real user-defined types. And the function calling semantics are mind-boggling, with mixing of keyword and positional arguments leading to all sorts of weirdness...
      • R does support fully user-defined types, inheritance and polymorphic methods. You just have to want to use them enough to dig through the multiple OO implementations available as part of the core. The commonly used systems, S3 and S4 objects, don't exactly play nicely together. I personally lean towards S4 since it seems much cleaner, but a lot of legacy code still uses S3 so it looks like there won't be a rationalisation of these two systems any time soon. The Bioconductor R modules generally (but not excl

      • Re: (Score:2, Informative)

        by mbakunin ( 258573 )

        Sadly, no. As the other guys said, R does absolutely everyting you claim it doesn't. Every positional function argument is a shortcut you can call explicitly in any order. Don't put any stock into this recommendation.

        If you are working in python, have discovered that SciPy's stats functions are not ready for prime time (they aren't), and need drop-in replacements, use rpy. Otherwise, you will find it does not play very well with R. It feeds and returns objects in what I found unintuitive and unuseful w

      • Bingo. Much as I like R, the language leaves a lot to be desired compared to Python - it doesn't even have a built in dictionary type. For a fully integrated package including Python and R, SAGE [sagemath.org] is worth a look.
  • by khb ( 266593 ) on Monday July 19, 2010 @03:27PM (#32954730)

    Often reason people get involved in statistical analysis is there is a body of data, and no clue where to start ... as inhabitants of the information age, and cheap storage ... there's lots of material and often little clue or thought to what the stored data might mean.

    http://rattle.togaware.com/ [togaware.com] is a website dedicated to "rattle" which is an R package (and togaware has a PDF book that's a great introduction) to a GUI based datamining tool.

    Very handy, and the book is very lucid.

  • I only wanted to say that having learned R and Latex just for doing my PhD thesis (I am a PM now and I have never used them since my dissertation), I would strongly recommend them, especially to those never planning on going back to academia...it's once in a lifetime opportunity to do beautiful AND useful coding, feel proud of it and being able to brag to non geeks/nerds. All at the same time. Just priceless..... PS: my PhD had nothing to do with CS by the way.
  • The <- approach is interesting, but what's the R notation for "less than negative six".

    And so, the quest continues. Pascal's := might be the best; although I hate to admit it because Pascal is my "had to deal with in school and was struggling so I hate it" language.

  • Serious question here.

    I do a lot of statistical analyses, including some I've authored. The book is for the programmer, but R is for statistics and that means someone who actually uses the numbers for something.

    SAS has it's own language as well as GUI with menus and can interchange data structures with many common programs.

    SPSS has all these, plus is can record what's pulled down from the menus and generate code in its own language, which is easy to understand, comes as a text file, and can be edited and cu

    • 1. R is free (as in beer and as in speech).
      2. R is far more extensible than SAS or SPSS. When what you're modelling doesn't fit in with the predefined options, you can deal with that by extending R in whatever way you wish.
      Those are the major advantages of R for statisticians.
      • I have used two programs for Statistical Analysis that have one advantage of R: both are free, nad part of the GNU project. Of course, both have disadvantages.

        1) PSPP [gnu.org] - a free alternative to SPSS. It does not have every option as SPSS, but in my opinion is fairly complete and has a lot of power. It is just like "click click. There is the average, the median, the standard deviaton, my null hypothesis cannot be rejected, let`s go back to work".

        2) Gretl - Gnu Regression, Econometrics and Time-series Libra [sourceforge.net]

    • by kklein ( 900361 )

      I use R from time to time. It's great for banging out a quick-and-dirty graph or something. It's so straightforward that if you really know exactly what it is you want to do, it's really fast to do it in R.

      However...

      I don't think I'll be using it that much now that I was able to get SPSS with the Advanced Stats pack onto my research budget. I'd been using a cracked copy of 11.5 for years, and that's why I had migrated to R. Now that I have SPSS, and didn't have to pay for it... I guess I don't really s

    • Re: (Score:3, Insightful)

      by u38cg ( 607297 )
      You might think of the difference between, say, Python and C. Both are Turing complete languages, but they are ideal for different problem domains. Or as a professor of mine put it, "SPSS and SAS are, mostly, for solved problems. R is for unsolved problems."
    • Thank you all for your comments, I've learned a lot, including the fact that others use the more mundane commercial programs to good advantage too.

      The best comment was u38cq's "SPSS and SAS are, mostly, for solved problems. R is for unsolved problems." Certainly most analyses that use such as T-tests (don't sniff -- it's what we do for fMRI. but on a massive scale) and ANOVA/MANOVA are more easily done with something made to do them rather than write code for such simple things. But it's not the problems th

  • R is a very impressive, mature program that does a hell of a job.
    I best liked connecting R data sets to a PostgreSQL database
    for my PhD thesis, and then doing statistical data on SQL selections
    without bothing about the SQL bits any more.

    Also, I see lots of universities in Germany step up and teach R, which I think is good.

      - Hubert

THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE

Working...