Learning R

As we write in the book, for most historical and humanistic research, you won’t need methods of analysis more complicated than contingency tables (which you can create easily with a spreadsheet editor), and perhaps a test such as the chi-squared test, which will help you interpret the tables (you can easily perform this test online). We strongly believe that the most important, interesting, and difficult task is to create good data: our book therefore focuses on the imputting and categorizing stages of this process. A straightforward descriptive analysis is then sufficient in many cases.

Should I learn R?

Graphical user interfaces

Tutorials

Should I learn R?

Sometimes, however, you will want to use another method, one of the ones that we present in chapters 4-7 (you should do this because it produces additional, fresh results on your data – not because one or the other method is fashionable or makes you look smart…). The good thing is that almost all these methods are now available in R (the few remaining ones are likely to be in the near future) and that R is free, opensource and (mostly – there are sometimes bugs) multi-platform. This means that it will not cost you money to install it and that it should run on your PC, Mac, or computer using Linux.

The not-so-good thing is that R looks impressive and difficult. It was originally developed for biostatistics. More importantly, by default, works with “command lines”, i.e. you have to write instructions (some would say that you have to “code”, but it is not nearly as impressive as it sounds) rather than click on buttons and menus. But as R has now been very generally adopted all other the world by researchers in all disciplines, more and more tutorials are available. Moreover, if you are a beginner, you do not think that you will have to use R regularly (you just want to give it a try and have a specific analysis in mind), and you are impressed by this idea of the “command line” or “coding”, you can add an interface inside R that offers you buttons and menus to click on, as long as you want to do something standard in terms of quantitative analysis. This is called an alternative GUI, for “graphical user interface”.

We also point here to tutorials that we have found accessible and useful to learn and teach R generally. Look at posts devoted to specific methods for specific tutorials.

Note that you should only use R on a categorized version of your data. Categorizing “raw” data (i.e. data inputted in the language of the source) in R is generally cumbersome and might produce errors. The categorization stage is more easily performed in your spreadsheet editor.

Finally, note that we do not address SAS, SPSS, or STATA. Those are variants of sotfware for statistical analysis that were generally used in the social sciences when R did not exist (or did not offer good packages for the social sciences). They are still taught in many places and work fine, but R has the advantage of being free and, now, much more comprehensive in terms of diverse methods.

 

Graphical user interfaces

RCommander

We have some experience – a rather satisfying one – using RCommander, first to learn R ourselves, then to teach regression and factor analysis to beginners in history. It is also useful if you want to quickly create many contingency tables accompanied by chi-squared tests, or to draw more interesting and diverse figures than in a spreadsheet editor. With the addition of the appropriate plugin, RCommander also performs event history analysis.

RCommander is useful for beginners because they do not have to write instructions; but it actually writes the R instructions that correspond to your clicks, and shows them to you. You can then experiment, changing a little thing in the instruction, re-running it and seeing how it responds. You then learn to code without even realizing it; and you will often realize that it is often quicker and easier to save an instruction, change a few things and run it, rather than to go back through all the menus and clicking.

To install RCommander, you can read the explanations here (especially if you have trouble) or follow one of the videos here. The easy way to start using it might be thanks to introductory videos: you can find many here, in several languages. There is a paper book devoted to RCommander, but you do not need it to use this tool. A (dense but useful) overview is given in the pdf here. If you are not afraid of new software, you can even begin by clicking here and there to find your way in the interface, as it is quite intuitive.

Deducer

We have not personally tested Deducer yet, but the principle seems very similar, with the same advantages for beginners (the user community seems smaller, though). You can find introductory videos here. We’ll try it at some point, but meanwhile, do not hesitate to send us feedback.

R tutorials

Videos

Each of us is more than 40 years old: we have been raised before online videos and still do not use them much… But you should know that there are plenty of video tutorials on R, including on how to get started with it, for example here. We have not yet tested them but we’ll try to add more specific advice here in the future.

There is even an iPhone-iPad application dedicated to learning R (we have not tested it and do not endorse Apple products).

Inside R

A specific R package, swirl, has been developed to allow you to learn R directly by practicing (you install R, you install the package, then the first course in the package, and here you go). We also still have to test it.

R events

SatRdays are events organized by R users, who teach other users – the events are free or low-cost and happen in more and more places. Among other things, it’s a good way to learn in your own languages, which is always less impressive (even though R commands are written in English anyway).

Online guides

If you already have an idea of what a command line is and are not afraid, you could start with this succinct overview of R or that one and then look for specific advice among the numerous R-users (inside a website dedicated to “r-bloggers”, on the web generally, on Twitter, etc.).

If you are more of a beginner and prefer a more structured progression, we have two recommendations at this moment:

Maelle Amand’s tutorial CleaR_Ling

Maelle is an excellent doctoral student in linguistics whom we met in one of our workshops; she devised a very accessible introductory course on R for students in linguistics and phonetics (but we think that it will work with other humanists and social scientists too).

You should first install R and RStudio, following, for example, explanations here. Than you can right-click (Ctrl+click on Mac) on “RTorino_Lab1.R” on this page, save this file somewhere on your computer, then open RStudio, go to File/Open, find Maelle’s file, and start experimenting.

R for Data Science

For a more complete course, we recommend Garrett Grolemund and Hadley Wickham’s R for Data Science. We thank the authors for having provided a free-to-use online version (and thanks to Laurent Lesnard, who presented it to us). The authors work at/for RStudio, one of the tools that they present, so they know the topic from the inside, but they are also good teachers (even though we can’t endorse their use of the phrase “data cleaning”). Their strategy is to begin with data visualization, before addressing data analysis, data import, etc. So if you like graphs, you want an overview of R, and you are not reluctant to work with data that is not your own, you can follow the guide from A to Z.

We suggest here an alternative way to use the guide, for beginners in the humanities (note that if you are a complete beginner, RCommander, addressed above, might be an interesting first step). If you mostly want to install R (and RStudio, which makes R much more user-friendly) and learn the basics of how it generally works:

Note that the book does not address network data, spatialized data, or textual data, but “only” datasets with one row per case and one column per variable. As the authors put it, “This book focuses exclusively on rectangular data: collections of values that are each associated with a variable and an observation. ” As a complement to our book, it is mostly useful for chapters 4 (on regression) and 7 (on visualizations other than networks and maps).


Author: Claire Lemercier

CNRS research professor of history in Paris / Directrice de recherche au CNRS en histoire, au Centre de sociologie des organisations

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.