class: center, middle, inverse, title-slide # How to Use
sample()
functions to Take Random Subsets of Rows ## Selecting Rows with _slice_sample() ### Peter Higgins ### 2021-01-10 --- ### How to Use the _slice()_ functions to Take Slices of Rows #### If you have a very large dataset, and want to develop code on a smaller (but random) sample, _slice_sample()_ can help. This is also helpful for sampling for training and testing sets when modeling. _slice_sample()_ can take n or proportion (prop) arguments Let's see some **sampling** examples! --- count: false Example 1/3: Take a Random 30% Sample of Rows from covid_dates. .panel1-filter1-auto[ ```r # how many rows when you start *nrow(covid_dates) ``` ] .panel2-filter1-auto[ ``` [1] 15524 ``` ] --- count: false Example 1/3: Take a Random 30% Sample of Rows from covid_dates. .panel1-filter1-auto[ ```r # how many rows when you start nrow(covid_dates) *covid_dates ``` ] .panel2-filter1-auto[ ``` [1] 15524 ``` ``` # A tibble: 15,524 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 1412 jhezane westerling female 4 covid inpatient … 2 533 penny targaryen female 7 covid clinical l… 3 9134 grunt rivers male 7 covid clinical l… 4 8518 melisandre swyft female 8 covid clinical l… 5 8967 rolley karstark male 8 covid emergency … 6 11048 megga karstark female 8 covid oncology d… 7 663 ithoke targaryen male 9 covid clinical l… 8 2158 ravella frey female 9 covid emergency … 9 3794 styr tyrell male 9 covid clinical l… 10 4706 wynafryd seaworth male 9 covid clinical l… # … with 15,514 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 1/3: Take a Random 30% Sample of Rows from covid_dates. .panel1-filter1-auto[ ```r # how many rows when you start nrow(covid_dates) covid_dates %>% * slice_sample(prop = 0.3) ``` ] .panel2-filter1-auto[ ``` [1] 15524 ``` ``` # A tibble: 4,657 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 4887 maerie greyjoy female 23 covid clinical l… 2 625 waif baratheon female 55 covid inpatient … 3 1594 maris baratheon female 70 covid emergency … 4 12013 tanda clegane female 93 covid clinical l… 5 8383 orphan greyjoy male 44 covid clinical l… 6 11920 hot baelish male 30 covid clinical l… 7 8231 lyle tarly male 15 covid inpatient … 8 2170 rhogoro baelish male 106 covid inpatient … 9 401 jonelle greyjoy female 66 covid clinical l… 10 9896 alerie mormont female 84 covid clinical l… # … with 4,647 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 1/3: Take a Random 30% Sample of Rows from covid_dates. .panel1-filter1-auto[ ```r # how many rows when you start nrow(covid_dates) covid_dates %>% slice_sample(prop = 0.3) # see how many rows now # Format: *# slice_sample(prop = 0.nn) <br> # slice_sample(prop = 0.nn) <br> ``` ] .panel2-filter1-auto[ ``` [1] 15524 ``` ``` # A tibble: 4,657 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 4499 nan seaworth female 89 covid clinical l… 2 7949 skahaz bolton male 98 covid clinical l… 3 12002 joyeuse manderly female 106 covid emergency … 4 5183 jommy mormont male 29 covid inpatient … 5 1411 harma tarly female 63 covid picu 6 658 daario stark male 58 covid inpatient … 7 4235 weasel harlaw female 35 covid care ntwk 8 9673 emmon bolton male 37 covid clinical l… 9 1890 ygritte seaworth female 26 covid clinical l… 10 2509 jon martell male 84 covid clinical l… # … with 4,647 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] <style> .panel1-filter1-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-filter1-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-filter1-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start *nrow(covid_dates) ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set *covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 15,524 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 1412 jhezane westerling female 4 covid inpatient … 2 533 penny targaryen female 7 covid clinical l… 3 9134 grunt rivers male 7 covid clinical l… 4 8518 melisandre swyft female 8 covid clinical l… 5 8967 rolley karstark male 8 covid emergency … 6 11048 megga karstark female 8 covid oncology d… 7 663 ithoke targaryen male 9 covid clinical l… 8 2158 ravella frey female 9 covid emergency … 9 3794 styr tyrell male 9 covid clinical l… 10 4706 wynafryd seaworth male 9 covid clinical l… # … with 15,514 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% * slice_sample(prop = 0.7) ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 10,866 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 2763 myles snow male 42 covid clinical l… 2 538 fornio mormont male 39 covid inpatient … 3 8266 alan harlaw male 41 covid clinical l… 4 11462 imry tarly male 50 covid clinical l… 5 2193 wilbert sand male 45 covid inpatient … 6 7695 roger rivers male 104 covid clinical l… 7 3648 mellei sand female 98 covid clinical l… 8 4361 henly swyft male 42 covid clinical l… 9 7654 jojen baelish male 65 covid picu 10 688 terrance harlaw male 78 covid s care nt… # … with 10,856 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> *training_covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set *covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 15,524 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 1412 jhezane westerling female 4 covid inpatient … 2 533 penny targaryen female 7 covid clinical l… 3 9134 grunt rivers male 7 covid clinical l… 4 8518 melisandre swyft female 8 covid clinical l… 5 8967 rolley karstark male 8 covid emergency … 6 11048 megga karstark female 8 covid oncology d… 7 663 ithoke targaryen male 9 covid clinical l… 8 2158 ravella frey female 9 covid emergency … 9 3794 styr tyrell male 9 covid clinical l… 10 4706 wynafryd seaworth male 9 covid clinical l… # … with 15,514 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% * anti_join(training_covid_dates) ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 4,658 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 533 penny targaryen female 7 covid clinical l… 2 9134 grunt rivers male 7 covid clinical l… 3 8518 melisandre swyft female 8 covid clinical l… 4 11048 megga karstark female 8 covid oncology d… 5 4706 wynafryd seaworth male 9 covid clinical l… 6 8115 patrek frey male 9 covid clinical l… 7 2349 yezzan royce male 10 covid line clini… 8 2083 weasel tarly female 10 covid emergency … 9 10468 chella mormont female 10 covid emergency … 10 9217 ragwyle martell female 10 covid clinical l… # … with 4,648 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% anti_join(training_covid_dates)-> *testing_covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% anti_join(training_covid_dates)-> testing_covid_dates # see how many rows in each *training_covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 10,866 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 10802 easy baelish male 69 covid clinical l… 2 3922 palla targaryen female 84 covid clinical l… 3 10336 ghost manderly female 77 covid emergency … 4 12021 mariya tully female 22 covid clinical l… 5 7718 palla umber female 100 covid gol 6 4815 greydon seaworth male 12 covid clinical l… 7 12164 sansa clegane female 32 covid clinical l… 8 10582 martyn rivers male 106 covid clinical l… 9 1557 margaery rivers female 86 covid clinical l… 10 9193 mellei umber female 25 covid clinical l… # … with 10,856 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% anti_join(training_covid_dates)-> testing_covid_dates # see how many rows in each training_covid_dates *testing_covid_dates ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 10,866 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 12117 penny seaworth female 42 covid emergency … 2 1124 aegon karstark male 76 covid emergency … 3 1115 butterbumps seaworth male 100 covid clinical l… 4 7937 mirri rivers female 83 covid clinical l… 5 850 penny tully female 70 covid clinical l… 6 7126 morra sand female 91 covid clinical l… 7 6828 becca ryswell female 49 covid hem onc da… 8 4464 stevron snow male 27 covid emergency … 9 5135 senelle mormont female 84 covid clinical l… 10 7938 becca swyft female 77 covid clinical l… # … with 10,856 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ``` # A tibble: 4,658 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 663 ithoke targaryen male 9 covid clinical l… 2 3794 styr tyrell male 9 covid clinical l… 3 4706 wynafryd seaworth male 9 covid clinical l… 4 12236 waif harlaw female 9 covid clinical l… 5 2349 yezzan royce male 10 covid line clini… 6 8138 frenya swyft female 10 covid clinical l… 7 9502 lorcas mormont male 10 covid clinical l… 8 10468 chella mormont female 10 covid emergency … 9 10919 woth snow male 10 covid clinical l… 10 227 maege sand female 11 covid emergency … # … with 4,648 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% anti_join(training_covid_dates)-> testing_covid_dates # see how many rows in each training_covid_dates testing_covid_dates # Format: *# slice_sample(prop = 0.nn) # slice_sample(prop = 0.nn) ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 10,866 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 3215 sybelle tyrell female 33 covid clinical l… 2 10558 rast royce male 79 covid clinical l… 3 3656 ralf westerling male 92 covid clinical l… 4 1475 frenken ryswell male 71 covid clinical l… 5 3490 mebble seaworth male 106 covid emergency … 6 8738 arianne tyrell female 59 covid clinical l… 7 5016 khorane swyft male 82 covid emergency … 8 3386 watt westerling male 71 covid clinical l… 9 2275 donyse swyft female 17 covid inpatient … 10 7004 alesander manderly male 41 covid emergency … # … with 10,856 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ``` # A tibble: 4,658 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 8518 melisandre swyft female 8 covid clinical l… 2 8943 myria rivers female 9 covid picu 3 12236 waif harlaw female 9 covid clinical l… 4 8138 frenya swyft female 10 covid clinical l… 5 10468 chella mormont female 10 covid emergency … 6 10919 woth snow male 10 covid clinical l… 7 2114 azzak tully male 10 covid inpatient … 8 252 nymeria karstark female 11 covid ob gyn 9 392 moon mormont male 11 covid clinical l… 10 587 morra tully female 11 covid clinical l… # … with 4,648 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 2/3: Take a Random 70% Sample for Training and a Complementary 30% for Testing. .panel1-filter2-auto[ ```r # how many rows when you start nrow(covid_dates) # make training set covid_dates %>% slice_sample(prop = 0.7) -> training_covid_dates # now make testing set covid_dates %>% anti_join(training_covid_dates)-> testing_covid_dates # see how many rows in each training_covid_dates testing_covid_dates # Format: # slice_sample(prop = 0.nn) # slice_sample(prop = 0.nn) *# set1 %>% anti_join(set2) # set1 %>% anti_join(set2) ``` ] .panel2-filter2-auto[ ``` [1] 15524 ``` ``` # A tibble: 10,866 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 4277 donal snow male 34 covid emergency … 2 4360 boros stark male 57 covid clinical l… 3 1445 sarella harlaw female 105 covid clinical l… 4 1322 oznak martell male 33 covid emergency … 5 4455 donnel greyjoy male 74 covid clinical l… 6 2695 endehar seaworth male 43 covid clinical l… 7 2679 jonelle stark female 44 covid emergency … 8 9170 brenett martell male 81 covid gol 9 6576 wayn stark male 36 covid clinical l… 10 2781 aenys stark female 90 covid emergency … # … with 10,856 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ``` # A tibble: 4,658 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 1412 jhezane westerling female 4 covid inpatient … 2 9134 grunt rivers male 7 covid clinical l… 3 11048 megga karstark female 8 covid oncology d… 4 663 ithoke targaryen male 9 covid clinical l… 5 3794 styr tyrell male 9 covid clinical l… 6 9309 maege sand female 9 covid medical ce… 7 2103 ollo snow male 10 covid clinical l… 8 4930 sarra frey female 10 covid emergency … 9 8138 frenya swyft female 10 covid clinical l… 10 4536 torrhen tully male 11 covid inpatient … # … with 4,648 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] <style> .panel1-filter2-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-filter2-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-filter2-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false Example 3/3: Take a Random Sample of 50 Rows from covid_dates. .panel1-filter3-auto[ ```r # how many rows when you start *nrow(covid_dates) ``` ] .panel2-filter3-auto[ ``` [1] 15524 ``` ] --- count: false Example 3/3: Take a Random Sample of 50 Rows from covid_dates. .panel1-filter3-auto[ ```r # how many rows when you start nrow(covid_dates) *covid_dates ``` ] .panel2-filter3-auto[ ``` [1] 15524 ``` ``` # A tibble: 15,524 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 1412 jhezane westerling female 4 covid inpatient … 2 533 penny targaryen female 7 covid clinical l… 3 9134 grunt rivers male 7 covid clinical l… 4 8518 melisandre swyft female 8 covid clinical l… 5 8967 rolley karstark male 8 covid emergency … 6 11048 megga karstark female 8 covid oncology d… 7 663 ithoke targaryen male 9 covid clinical l… 8 2158 ravella frey female 9 covid emergency … 9 3794 styr tyrell male 9 covid clinical l… 10 4706 wynafryd seaworth male 9 covid clinical l… # … with 15,514 more rows, and 11 more variables: result <chr>, # demo_group <chr>, age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, # orderset <dbl>, payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 3/3: Take a Random Sample of 50 Rows from covid_dates. .panel1-filter3-auto[ ```r # how many rows when you start nrow(covid_dates) covid_dates %>% * slice_sample(n = 50) ``` ] .panel2-filter3-auto[ ``` [1] 15524 ``` ``` # A tibble: 50 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 4537 maerie targaryen female 106 covid inpatient … 2 7956 steelskin bolton male 27 covid emergency … 3 1156 willis clegane male 46 covid inpatient … 4 3212 shyra clegane female 60 covid clinical l… 5 11909 zei seaworth female 97 covid emergency … 6 699 osha targaryen female 79 covid radiation … 7 9380 myria tarly female 51 covid clinical l… 8 10177 dalla clegane female 50 covid clinical l… 9 7318 ollo royce male 101 covid clinical l… 10 10088 tristifer frey male 68 covid clinical l… # … with 40 more rows, and 11 more variables: result <chr>, demo_group <chr>, # age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, orderset <dbl>, # payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] --- count: false Example 3/3: Take a Random Sample of 50 Rows from covid_dates. .panel1-filter3-auto[ ```r # how many rows when you start nrow(covid_dates) covid_dates %>% slice_sample(n = 50) # see how many rows now # Format: *# slice_sample(n = NN) <br> # slice_sample(n = NN) <br> ``` ] .panel2-filter3-auto[ ``` [1] 15524 ``` ``` # A tibble: 50 x 18 subject_id fake_first_name fake_last_name gender pan_day test_id clinic_name <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> 1 6473 porridge bolton male 105 covid clinical l… 2 2329 falia kettleblack female 46 covid nicu 3 516 malliard snow male 56 covid line clini… 4 1076 weasel harlaw female 47 covid clinical l… 5 12304 arwyn kettleblack female 42 covid clinical l… 6 987 shae tyrell female 34 covid cc care nt… 7 10681 gillam harlaw male 58 covid clinical l… 8 11830 aegon kettleblack male 63 covid emergency … 9 3362 wylla lannister female 18 covid clinical l… 10 1742 sansa westerling female 51 covid picu # … with 40 more rows, and 11 more variables: result <chr>, demo_group <chr>, # age <dbl>, drive_thru_ind <dbl>, ct_result <dbl>, orderset <dbl>, # payor_group <chr>, patient_class <chr>, col_rec_tat <dbl>, # rec_ver_tat <dbl>, fake_date <date> ``` ] <style> .panel1-filter3-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-filter3-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-filter3-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- class: inverse, center # End of This Flipbook ## On to The Coding Exercises!