Sampling a dataset

The dplyr package has a function to gather a sample from your dataset, sample(). You pass in the dataset to operate against and how many samples you want drawn, sample_n(), and the fraction percentage, sample_frac(), as in this example:

data <- sample_n(players, 30) glimpse(data)

We see the results as shown in the following screenshot:

Note that there are 30 observations in the results set, as requested.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.60.149