Welcome to R for Marketing Research and Analytics

Note, April 2019: The 2nd Edition of R for Marketing Research and Analytics was released this month. All code and exercises are posted here as .R files. We will update Exercise Notebooks in coming weeks (basic solutions in R code are available now).

R for Marketing Research and Analytics by Chris Chapman and Elea McDonnell Feit is designed to teach R to marketing practitioners and data scientists. This site contains the latest, updated .R code files; data files; classroom slides; exercises; and errata.

Book cover

Recent Updates

Date Announcement
PINNED: May 12, 2019

Important 'errata': In April 2019, just after publication of the book, R 3.6.0 changed the way it generates random numbers. In many chapters we simulate data and perform other functions that use random numbers. Those results will change slightly from what the book shows. Options include:

  • To match the book, when using downloaded data: no action is needed. You will notice few differences, except for minor details such as results from the some() function, and slightly different results in some Bayesian statistics (which use randomization).

  • To match the book exactly (especially when simulating the data as we recommend): give the command RNGversion("3.5.0") after starting R and before running code from the book.

  • To see how things change: just go ahead and use R's new default random number generator. Compare results to the book. They will be slightly different in the exact data points, yet quite similar for the overall statistical results.

  • If you're interested to read more about the reason for the change, see Bias in R's random integers?
  • October 20, 2019 For readers of the 1st edition (and the 2nd), the Exercises and solutions that were added in the 2nd edition are available to you. See the Exercises page for the Exercises PDF and solution .R files.
    August 19, 2019 Chris has released a development, in-progress R choicetools package to assist with choice-based conjoint and MaxDiff analyses. See choicetools presentation from UseR! 2019 for details and example code. These tools may assist with choice-based conjoint simulations as discussed in Chapter 13.
    April 10, 2019 What's new in the 2nd edition?

    The 2nd edition focuses on making the book more useful for students, self-learners, and instructors. This includes:

  • Exercises at the end of each chapter. Exercises page.
  • A new chapter on behavior sequences (such as web logs), with analysis using Markov chains.
  • Classroom slides here (that work for both 1st and 2nd editions).
  • Discussion of how & where one might acquire typical data sets in each chapter.
  • A new appendix introducing reproducible research and the advantages of R Notebooks.
  • Generally updated the code and text as needed to be clearer, correct errors, update packages, etc.
  • March 20, 2019 The Second Edition is now electronically available (early!). We are updating the content here and will be in sync with the 2nd edition in time for the official release date in May 2019. Please check back for updates!
    November 3, 2016 A Chinese translation is now available: China Pub and Amazon China
    . Chinese cover


    The book is available in:

  • Springer
  • Amazon
  • Powell's Books
  • Google Play Store (ebook)

  • Chinese:
  • China Pub
  • Amazon China

  • Japanese (February 2020):
  • Kyoritsu Publishing
  • Amazon Japan
  • Events

    To be announced

    Selected past events

  • Chris and Elea taught a 2-day workshop at the Foster School of Business, University of Washington, January 2017

  • Chris offered beginning and advanced tutorials at: 2016 SKIM/Sawtooth Software Conference.

  • Chris discussed the book in an invited talk at: 2015 Joint Statistical Meetings.

  • Elea presented "Designing New Products Using Choice Models in R" at: PhillyR Meeting, April 2015 [Slides].