Skip to main content

Sampling in R

Master sampling to get more accurate statistics with less data.

Start Course for Free
4 Hours15 Videos51 Exercises4,041 Learners
4000 XP

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

Sampling is a cornerstone of inference statistics and hypothesis testing. It's tremendously important in survey analysis and experimental design. This course explains when and why sampling is important, teaches you how to perform common types of sampling, from simple random sampling to more complex methods like stratified and cluster sampling. Later, the course covers estimating population statistics, and quantifying uncertainty in your estimates by generating sampling distributions and bootstrap distributions. Throughout the course, you'll explore real-world datasets on coffee ratings, Spotify songs, and employee attrition.

  1. 1

    Bias Any Stretch of the Imagination


    Learn what sampling is and why it is useful, understand the problems caused by convenience sampling, and learn about the differences between true randomness and pseudo-randomness.

    Play Chapter Now
    Living the sample life
    50 xp
    Reasons for sampling
    50 xp
    Simple sampling with dplyr
    100 xp
    Simple sampling with base-R
    100 xp
    A little too convenient
    50 xp
    Are findings from the sample generalizable?
    100 xp
    Are the findings generalizable? 2
    100 xp
    How does Sue do sampling?
    50 xp
    Generating random numbers
    100 xp
    Understanding random seeds
    100 xp

In the following tracks

StatisticianStatistics Fundamentals


Dr. Chester Ismay
Richie Cotton Headshot

Richie Cotton

Curriculum Architect at DataCamp

Richie is a Learning Solutions Architect at DataCamp. He has been using R since 2004, in the fields of proteomics, debt collection, and chemical health and safety. He has released almost 30 R packages on CRAN and Bioconductor – most famously the assertive suite of packages – as well as creating and contributing to many others. He also has written two books on R programming, Learning R and Testing R Code.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA