Sampling data

Sampling can be done with sample_n and sample_frac. Both sample_n and sample_frac allows the user to select random samples (by count or fraction respectively) from the given dataset. It is primarily a wrapper to gather random samples using sample.int, as shown:

sample_n(tstate, 10) # To select 10 random rows 

The output of the preceding code is as follows:

 

sample_frac(tstate, 0.10) # To select 10% of the rows at random, i.e.,
# 5 rows out of 50
..................Content has been hidden....................

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