Week 6 - Review

Emorie D Beck

Outline

  1. Questions on Homework
  2. dplyr
  3. tidyr
  4. Functions
  5. purrr
  • Note: my office hour is canceled because I will be traveling. If you need to meet this week, please make an appointment.

tidyverse: chaining (|> or |>)

dplyr: select() and filter()

1. select()

Add or remove using select() helper functions.

  • starts_with()
  • ends_with()
  • contains()
  • matches()
  • num_range()
  • one_of()
  • all_of()
bfi |>
  select(starts_with("C"))
      C1 C2 C3 C4 C5
61617  2  3  3  4  4
61618  5  4  4  3  4
61620  4  5  4  2  5
61621  4  4  3  5  5
61622  4  4  5  3  2
61623  6  6  6  1  3
61624  5  4  4  2  3
61629  3  2  4  2  4
61630  6  6  3  4  5
61633  6  5  6  2  1
61634  4  3  5  3  2
61636  5  4  5  4  5
61637  5  4  3  2  2
61639  4  4  4  2  1
61640  5  5  5  2  2
61643  5  5  5  3  5
61650  4  4  4  4  4
61651  5  5  5  4  3
61653  5  4  5  4  6
61654  1  1  1  5  6
61656  4  6  5  5  4
61659  5  4  4  2  3
61661  4  3  2  4  5
61664  3  5  6  3  6
61667  5  5  4  1  1
61668  5  2  5  1  1
61669  6  5  6  1  1
61670  4  5  4  3  4
61672  5  4  5  2  5
61673  5  5  3  5  4
61678  5  5  5  4  3
61679  5  5  5  2  4
61682  1  5  6  4  6
61683  4  6  4  2  4
61684  4  3  3  3  4
61685  2  2  4  3  4
61686  5  6  3  1  5
61687  6  5  6  3  4
61688  6  6  6  1  1
61691  6  5  5  2  2
61692  4  4  4  3  4
61693  5  2  5  2  4
61696  4  5  4  3  3
61698  5  3  3  4  5
61700  5  4  5  3  4
61701  5  2  1  2  1
61702  4  4  3  4  5
61703  3  2  3  4  6
61713  3  6  3  1  3
61715  5  5  4  1  2
61716  4  3  1  4  2
61723  6  6  6  6  2
61724  5  5  3  2  5
61725  5  6  2  5  2
61728  6  5  5  2  2
61730  5  5  4  4  5
61731  5  5  5  5  1
61732  5  4  5  2  4
61740  6  6  6  1  4
61742  6  4  4  2  2
61748  5  3  2  4  6
61749  5  5  4  3  4
61754 NA  6  6  2  3
61756  6  5  5  2  2
61757  4  6  6  1  4
61759  5  4  5  2  1
61761  1  2  2  2  6
61762  4  2  2  4  5
61763  5  5  4  2  2
61764  6  5  6  1  4
61771  4  6  6  1  2
61772  2  4  4  1  1
61773  5  4  6  2  4
61775  5  5  5  1  2
61776  5  5  5  1  1
61777  5  4  6  3  2
61778  5  4  5  1  2
61780  5  5  6  3  4
61782  2  4  2  5  1
61783  4  2  3  5  4
61784  6  5  4  4  3
61788  6  6  5  1  6
61789  3  3  4  4  5
61793  5  6  5  1  1
61794  4  5  5  2  3
61797  2  5  4  4  3
61798  4  4  5  2  2
61801  4  5  4  4  5
61808  4  4  5  2  4
61812  3  3 NA  3  3
61813  5  2  4  1  2
61816  5  4  5  3  4
61818  2  2  3  4  4
61819  6  6  5  1  1
61821  4  5  6  3  1
61822  5  6  4  1  4
61825  2  1  2  6  6
61826  6  4  4  1  1
61829  4  5  6  2  6
61831  4  2  5  3  5
61834  4  3  4  3  5
61835  4  3  4  4  2
61838  6  6  4  1  5
61839  2  1  2  4  6
61840  6  4  5  2  1
61841  5  3  4  6  5
61847  6 NA  6  1  1
61848  3  6  3  3  4
61851  5  4  4  4  6
61852  3  5  2  3  4
61854  4  4  5  3  4
61856  5  5  5  1  5
61857  5  3  5  1  2
61861  6  6  5  1  6
61862  5  4  5  2  2
61865  4  1  2  6  6
61868  5  6  4  1  4
61873  2  2  2  3  5
61874  5  4  5  2  3
61880  6  5  4  2  6
61886  4  6  5  5  2
61888  4  5  5  5  5
61889  5  5  6  1  1
61890  5  5  5  3  6
61891  5  5  4  6  6
61895  5  5  5  2  6
61896  5  4  5  3  2
61900  5  4  5  3  5
61901  2  3  4  5  6
61907  5  3  4  2  5
61908  4  4  4  4  5
61909  4  4  5  3  5
61911  6  5  5  2  3
61913  4  4  4  3  6
61915  6  6  3  6  5
61918  6  1  3  4  5
61921  1  1  3  1  1
61922  6  6  4  1  1
61923  5  5  4  1  4
61925  2  3  2  5  5
61926  3  3  3  2  6
61928  4  4  6  4  2
61932  6  5  4  2  2
61935  3  2  4  2  3
61936  3  5  3  3  6
61939  6  4  4  2  4
61944  6  6  6  1  5
61945  4  4  5  3  5
61949  4  4  6  4  5
61952  5  5  5  2  2
61953  5  2  2  5  6
61954  6  5  3  1  1
61957  4  4  2  5  4
61958  5  4  4  1  1
61965  5  5  6  2  1
61967  4  5  4  2  4
61968  5  3  4  4  4
61969  3  1  4  4  5
61971  3  5  4  4  5
61972  5  6  5  2  1
61973  5  4  5  1  1
61974  5  3  2  3  4
61975  2  3  2  4  5
61976  2  5  6  5  2
61978  5  5  5  2  2
61979  1  1  3  4  5
61983  4  6  4  1  2
61986  4  2  4  5  5
61987  5  6  4  2  2
61989  6  6  5  1  4
61990  3  3  5  3  6
61992  5  6  6  4  2
61993  4  4  4  4  5
61994  5  4  5  3  4
61999  5  5  5  2  1
62001  6  4  6  5  6
62003  4  5  3  3  4
62004  6  6  6  1  3
62005  4  3  5  4  4
62007  3  2  2  4  1
62009  5  2  4  4  5
62011  5  4  5  2  4
62013  3  3  4  4  4
62014  4  3  3  4  5
62015  5  5  4  3  2
62022  3  5  1  1  6
62023  4  4  4  4  4
62024  6  6  6  1  1
62025  5  5  5  1  2
62026  5  5  5  1  2
62029  3  1  1  3  2
62031  4  4  5  2  5
62032  4  5  4  2  5
62033  4  4  4  4  5
62034  5  5  5  2  4
62038  1  3  2  2  5
62039  5  3  3  3  4
62041  2  4  4  3  2
62042  2  4  3  4  6
62043  3  2  5  2  1
62044  5  6  5  1  2
62047  2  2  6  2  3
62048  4  4  4  3  4
62051  5  6  4  1  2
62052  5  4  4  3  4
62054  4  5  5  1  1
62055  2  4  2  2  4
62056  6  4  4  1  1
62059  3  3  3  4  4
62060  1  2  2  1  5
62063  6  2  5  2  2
62064  4  5  4  5  6
62067  5  4 NA  4  4
62070  3  3  3  4  6
62073  5  5  5  1  3
62075  5  4  4  2  2
62077  6  5  4  1  2
62079  5  1  3  2  1
62082  6  6  6  1  6
62084  6  2  2  4  5
62090  5  5  5  4  3
62092  6  6  1  1  1
62094  5  5  5  3  3
62099  5  3  4  3  5
62101  2  5  5  2  2
62102  1  5  6  3  2
62103  4  3  4  3  3
62105  6  5  6  2  4
62106  5  3  4  1  5
62107  5  5  4  2  1
62111  1  4  6  2  2
62115  5  3  3  2  4
62118  5  6  4  1  1
62119  5  4  6  3  3
62120  6  5  5  1  1
62121  3  3  4  5  4
62124  5  5  2  3  3
62128  4  3  4  5  6
62130  5  5  5  2  4
62132  5  6  5  2  1
62133  5  5  6  1  1
62136  4  5  4  2  4
62137  5  4  5  2  4
62142  5  4  5  1  2
62144  5  5  5  2  2
62147  4  3  3  3  5
62151  2  1  2  5  6
62156  5  2  5  2  3
62160  5  4  4  1  5
62161  4  2  4  4  4
62162  4  4  6  3  3
62163  6  5  5  2  2
62164  5  6  5  1  1
62165  6  6  6  1  1
62166  5  4  5  2  2
62168  4  4  4  2  2
62170  5  4  6  1  2
62171  3  3  5  4  4
62173  6  4  4  1  5
62176  4  5  3  5  4
62179  6  5  2  6  6
62180  6  5  5  1  3
62181  5  5  6  6  1
62182  6  5  5  1  1
62183  6  4  4  2  6
62189  5  6  5  2  1
62192  4  4  4  2  3
62197  5  4  5  1  1
62198  5  6  5  2  5
62199  4  4  5  4  5
62201  5  5  3  4  6
62202  4  5  5  3  3
62203  6  5  6  1  3
62204  5  6  6  5  1
62205  4  5  4  2  4
62206  4  5  6  3  1
62208  6  5  5  1  2
62209  5  4  3  2  4
62212  4  4  5  2  5
62213  3  3  5  3  5
62214  4  4  3  4  5
62215  5  4  5  1  1
62216  3  2  4  4  6
62219  4  5  4  3  4
62220  4  4  5  5  4
62224  5  4  5  2  1
62225  3  5  5  2  1
62226  5  3  5  2  3
62227  6  4  4  3  4
62228  5  4  6  2  2
62231  2  4  5  5  5
62233  5  5  5  2  1
62237  4  4  5  4  4
62239  4  4  5  4  4
62240  5  3  3  4  5
62242  4  5  4  3  5
62244  5  6  6  5  6
62245  3  2  2  4  6
62246  3  5  6  2  1
62252  4  4  4  4  3
62259  5  6  2  1  5
62260  4  4  4  2  2
62261  5  2  6  5  5
62263  4  3  5  3  4
62264  5  5  4  1  1
62265  5  5  4  2  4
62266  5  4  3  2  3
62267  5  6  6  2  1
62272  6  6  5  1  2
62276  4  5  5  2  3
62278  3  5  3  2  2
62279  6  5  5  1  2
62280  4  4  4  1  2
62281  5  4  6  1  2
62282  6  5  5  4  6
62287  5  5  5  2  1
62288  2  1  5  6  6
62289  4  4  4  2  2
62290  5  3  4  4  4
62293  4  5  5  1  2
62295  6  6  6  1  2
62296  4  5  4  2  2
62298  5  5  6  2  5
62299  5  5  5  5  5
62300  4  4  3  4  4
62301  5  5  5  2  4
62303  5  5  6  1  2
62305  4  4  3  3  4
62307  6  6  2  6  6
62312  5  5  4  3  5
62313  5  5  3  4  5
62316  4  6  5  1  2
62317  4  4  5  2  3
62325  5  6  4  1  1
62327  4  6  6  2  5
62328  3  1  5  2  5
62330  3  5  5  2  1
62333  6  6  6  1  1
62335  3  3  4  4  2
62336  6  5  2  1  5
62339  3  2  5  4  5
62342  4  1  2  6  3
62343  5  4  4  6  5
62344  5  6  4  2  4
62345  4  4  4  3  4
62346  5  4  5  3  3
62347  4  3  3  5  5
62348  4  5  6  4  3
62349  6  6  5  1  3
62350  4  4  6  4  2
62351  6  4  6  1  4
62352  5  5  5  1  1
62353  2  4  4  4  4
62354  4  4  5  3  2
62358  3  3  5  3  4
62359  5  5  5  2  4
62360  4  4  3  4  6
62362  5  4  5  4  5
62363  4  5  2  4  4
62366  5  6  5  1  3
62367  6  4  5  1  2
62368  4  1  2  5  6
62369  2  5  5  1  2
62370  4  5  2  3  6
62371  3  2  4  3  6
62375  5  6  6  1  2
62376  4  3  3  3  4
62377  5  5  5  5  4
62380  4  1  5  6  6
62382  3  6  2  5  5
62384  5  5  5  3  4
62387  5  5  4  2  4
62390  6  5  4  1  1
62391  5  5  5  1  4
62394  5  4  3  1  4
62397  6  6  6  1  1
62401  5  5  4  1  1
62408  5  4  4  2  5
62412  3  5  3  1  1
62416  6  5  5  3  2
62419  4  5  6 NA  1
62421  5  5  4  2  3
62423  5  6  5  2  3
62426  5  4  5  4  4
62433  5  6  2  2  4
62434  6  5  5  1  1
62435  5  5  5  2  2
62438  4  4  4 NA  3
62440  3  4  5  5  6
62443  5  5  4  1  2
62444  2  3  3  4  3
62447  5  5  5  1  5
62448  5  5  5  4  2
62450  6  5  3  3  4
62453  4  5  4  2  3
62454  3  4  3  4  4
62457  5  3  4  3  3
62462  6  4  4  1  1
62463  5  2  5  3  2
62464  5  4  4  4  4
62467  3  2  2  3  2
62468  4  2  2  5  4
62469  5  5  6  1  1
62470  5  4  2  2  4
62474  2  6  6  1  1
62476  4  2  4  4  5
62479  5  6  5  1  1
62480  5  5  4  2  4
62481  5  5  6  1  2
62486  5  3  4  1  1
62489  4  4  5  2  5
62491  5  2  5  4  3
62493  2  3  2  3  4
62494  6  5  5  1  1
62496  5  2  4  1  5
62497  5  3  2  3  5
62498  1  5  6  4  1
62499  5  4  5  2  3
62500  5  6  5  1  3
62502  1  5  6  1  1
62505  5  6  4  3  4
62508  5  6  6  1  2
62509  6  5  6  2  2
62512  6  6  5 NA  2
62514  6  6  5  1  2
62518  6  6  5  1  1
62520  4  5  4  1  1
62522  6  5  4  2  3
62526  5  4  1  3  1
62527  2  3  2  3  5
62528  5  6  5  1  3
62529  5  6  5  1  3
62530  5  6  5  1  3
62531  5  6  5  1  3
62532  5  6  4  2  4
62533  5  6  4  2  4
62535  5  6  4  2  4
62537  2  2  2  4  5
62538  6  6  6  1  1
62541  6  5  6  4  4
62542  6  5  6  1  3
62543  4  5  5  1 NA
62545  2  5  2  4  3
62546  4  4  4  2  4
62547  6  5  6  5  4
62548  4  3  5  1  2
62550  4  4  4  2  4
62551  4  4  3  6  6
62552  6  6  6  1  1
62553  6  6  6  1  1
62555  3  4  4  5  5
62556  5  5  4  3  3
62557  5  5  5  1  2
62559  5  5  5  4  3
62561  6  4  5  1  1
62562  3  5  5  1  2
62565  1  6  6  1  1
62567  6  6  4  1  5
62570  3  4  2  5  5
62573  6  6  6  1  6
62574  4  3  3  2  4
62577  2  1  2  5  4
62578  5  5  6  1  3
62582  5  3  3  2  2
62589  5  4  3  2  2
62590  5  4  4  1  4
62594  6  5  6  2  3
62597  6  2  4  2  5
62599  6  1  5  3  1
62604  6  5  6  1  2
62605  5  5  3  4  1
62606  5  5  3  1  1
62610  5  6  5  1  1
62611  4  3  4  3  4
62612  4  2  4  4  2
62613  3  1  2  4  2
62615  3  1  4  5  2
62617  6  6  6  1  1
62618  4  3  4  5  4
62622  6  6  5  1  4
62623  5  4  2  1  2
62625  6  5  5  1  2
62627  5  5  5  2  4
62635  4  4 NA  4  5
62638  6  3  5  1  2
62640  6  5  5  5  1
62642  6  5  5  3  3
62643  3  4  2  2  2
62644  5  6  5  1  2
62645  5  5  5  1  3
62646  3  4  6  5  2
62647  5  5  5  2  2
62648  1  4  6  4 NA
62650  6  6  5  1  1
62652  4  3  3  1  1
62653  4  6  5  2  3
62654  5  6  6  1  2
62657  6  3  5  2  1
62662  5  4  4  5  5
62664  6  5  5  1  2
62665  4  5  3  1  1
62667  5  6  5  1  1
62668  1  6  5  3  4
62669  5  4  6  2  4
62670  5  5  5  2  2
62673  5  5  5 NA  2
62675  6  6  4  1  2
62677  1  4  4  4  1
62679  5  4  4  1  2
62681  5  4  4  1  2
62682  3  6  3  3  1
62683  6  5  6  1  1
62684  5  5  5  1  2
62685  6  2  5  1  2
62686  6  5  3  2  2
62687  2  6  5  3  2
62688  6  6  5  1  2
62690  4  6  5  4  1
62692  6  6  5  1  1
62694  6  6  5  1  1
62698  4  3  4  4  3
62700  4  4  6  3  3
62703  4  3  5  2  3
62706  4  5  6  1  1
62707  3  5  4  2  2
62708  5  6  6  1  1
62710  5  4  4  3  4
62712  6  5  5  1  3
62715  5  5  5  2  4
62716  3  1  1  3  6
62717  5  4  5  4  2
62718  5  4  3  3  4
62719  5  2  6  1  1
62720  1  5  2  1  2
62722  5  4  5  2  5
62726  2  5  4  2  1
62728  5  5  4  2  5
62729  3  2  3  4  4
62731  5  2  2  4  2
62740  5  4  3  2  4
62741  5  4  5  2  1
62744  5  5  5  3  2
62745  2  5  6  4  6
62749  2  5  6  1  2
62750  5  2  5  1  2
62751  4  4  5  4  5
62757  5  5  5  2  2
62758  2  2  4  2  5
62761  6  5  6  1  2
62764  4  5  5  1  2
62765  1  4  6  1  1
62766  5  3  3  3  5
62767  1  1  2  4  5
62768  6  6  5  1  2
62770  2  5  5  2  2
62772  4  5  4  4  4
62776  2  2  4  4  4
62778 NA  5  5  1  1
62779  3  5  4  2  4
62780  6  6  6  1  2
62781  6  5  4  2  1
62783  5  5  5  5  5
62785  5  6  5  1  4
62786  6  6  5  1  4
62787  5  3  1  2  5
62788  6  6  5  2  3
62789  4  4  3  5  2
62790  6  5  6  1  1
62792  4  3  4  4  3
62795  5  4  1  5  5
62796  2  4  4  6  5
62797  3  4  1  1  4
62800  3  5  3  1  1
62801  5  6  5  1  1
62803  4  4  4  4  2
62804  6  3  3  2  4
62805  4  5  5  2  4
62809 NA  3  2  2  3
62810  6  6  6  1  1
62816  6  5  6  1  6
62817  3  5  6  5  3
62819  3  4  2  2  5
62821  6  5  6  1  2
62822  4  4  4  3  2
62825  4  2  4  4  5
62826  4  5  4  3  4
62827  4  6  6  4  4
62828  6  6  5  4  2
62831  6  5  3  5  3
62832  5  5  5  3  3
62834  4  4  6  2  2
62835  4  4  3 NA  4
62837  1  5  6  1  4
62839  5  5  5  2  1
62840  4  4  4  1  2
62844  5  5  5  2  2
62846  4  5  4  2  4
62847  6  6  5  1  1
62849  4  6  5  1  2
62851  6  4  6  4  2
62853  5  6  6  2  4
62856  4  5  5  1  2
62857  4  4  3  4  4
62858  5  5  5  2  2
62861  4  4  2  4  4
62863  3  2  5  2 NA
62864  5  1  4  2  1
62867  4  3  4  4  4
62869  4  4  4  2  5
62870  2 NA  6  1 NA
62872  2  5  6  1 NA
62874  5  6  6  1  1
62876  4  2  3 NA  3
62877  5  4  5  1  4
62878  2  6  4  1  3
62879  6  6  5  2  1
62881  6  5  6  1  1
62883  4  4  4  2  4
62887  6  6  5  1  1
62889  4  2  5  4  3
62890  5  4  5  4  5
62891  6  6  6  1  2
62897  4  5  5  1  1
62898  6  6  6  1  1
62899  5  6  5  1  1
62901  4  3  5  4  3
62903  5  5  2  4  2
62908  4  3  3  5  5
62910  5  5  5  2  2
62911  5  4  4  1  2
62916  2  1  4  4  1
62918  6  4  4  2  2
62920  5  5  5  2  3
62922  5  5  5  2  4
62926  5  5  2  4  5
62931  5  5  6  1  2
62933  1  6  4  1  1
62934  4  4  4  3  4
62936  3  1  2  2  2
62938  6  5  4  2  2
62939  4  4  4  3  3
62941  4  4  4  3  3
62942  5  6  4  2  2
62948  4  3  1  3  2
62949  6  4  4  2  3
62950  6  5  4  1  1
62951  4  2  4  2  4
62953  6  5  5  1  2
62954  5  5  1  1  6
62957  6  5  4  1  2
62962  4  2  4  1  1
62965  5  5  4  4  6
62968  2  4  4  3  4
62969  6  5  5  1  5
62971  5  5  5  2  2
62974  5  5  4  1  1
62976  6  5  5  3  1
62983  5  3  4  2  3
62984  4  2  4  5  3
62989  3  5  5  1  1
62990  6  6  6  1  1
62991  5  5  5  3  1
62994  5  5  3  3  5
62995  2  4  2  4  4
62996  4  5  5  2  1
62997  2  1  5  2  6
63004  4  5  5  2  2
63007  4  6  6  3  5
63013  3  4  3  4  5
63017  6  4  4  2  4
63018  5  5  5  2  4
63021  5  4  5  3  4
63023  6  6  5  2  2
63026  6  6  6  1  1
63027  1  2  3  3  1
63030  6 NA NA NA  2
63034  4  6  5  3  3
63035  5  5  5  1  2
63036  4  3  4  1  1
63037  6  6  4  4  4
63038  5  5  4  2  4
63039  6  5  4  2  5
63040  4  4  3 NA  4
63042  4  4  3  4  3
63047  4  4  2  3  5
63048  5  5  2  4  5
63049  6  6  6  1  1
63050  5  4  3 NA  4
63051 NA  5  2  1  2
63054  4  5  5  2  5
63055  5  6  6  2  1
63059  6  6  6  1  1
63062  5  3  4  3  5
63063  3  4  3  4  4
63069  6  6  5  3  3
63070  6  4  5  2  4
63071  6  5  6  1  1
63073  6  4  4  2  5
63075  6  5  5  4  2
63077  5  5  5  2  1
63081  4  6  4  1  1
63083  3  4  4  3  3
63084  5  4  5  2  1
63089  5  6  3  1  6
63090  5  5  4  2  3
63092  3  5  5  4  2
63094  4  3  3  3  5
63096  4  5  5  1  2
63097  5  6  6  2  1
63099  3  5  5  2  2
63100  5  6  3  2  4
63102  5  5  5  1  4
63103  5  6  6  1  2
63104  3  3  3  3  4
63108  3  2  5  4  6
63109  5  5  5  1  1
63112  3  2  3  4  4
63115  5  5  5  5  4
63116  4  5  5  2  1
63120  5  4  6  1  4
63121  6  6  6  1  5
63122  3  4  3  3  4
63123  5  6  1  2  1
63125  5  5  5  2  2
63127  5  5  5  1  2
63128  5  5  6  2  2
63130  5  4  5  2  6
63131  5  6  5 NA  1
63135  4  4  5  3  4
63136  4  6  5  2  4
63139  5  5  6  2  2
63141  1  6  6  1  1
63142  3  4  5  2  4
63146  4  2  2  2  4
63147  6  5  6  1  1
63152  5  6  4  4  4
63154  5  5  6  2  3
63155  5  5  6  2  4
63158  6  5  2  1  5
63161 NA  3  3  1  1
63163  6  6  6  1  2
63165  3  4  3  2  2
63171  4  4  4  3  5
63172  6  5  5  1  1
63173  4  4  6  2  4
63176  4  5  5  2  2
63181  3  5  4  2  3
63182  4  5  4  2  2
63183  3  3  2  3  4
63187  3  5  5  1  6
63192  4  3  4  3  4
63193  5  1  2  2  4
63194  4  4  4  4  4
63197  5  5  4  3  4
63200  3  4  6  2  1
63201  5  4  4  2  2
63203  4  2  2  4  3
63209  6  6  2  1  1
63215  5  5  2  3  5
63222  4  5  3  3  5
63223  3  2  2  5  6
63225  6  6  6  1  4
63227  4  4  4  2  4
63228  3  4  3  4  4
63233  5  5  3  2  3
63237  5  5  5  3  4
63238  5  3  2  2  4
63239  6  5  6  2  1
63242  4  4  5  2  2
63245  5  6  6  4  3
63246  5  3  5  1  1
63250  5  4  4  2  5
63252  5  5  5  2  2
63253  2  2  4  3  4
63258  4  5  5  2  3
63261  4  6  5  2  2
63264  2  2  4  5  6
63266  5  5  4  2  2
63271  3  3  3  3  4
63277  4  4  3  3  5
63278  3  3  3  2  3
63280  4  4  6  3  5
63281  5  5  5  3  3
63286  4  4  4  4  5
63287  5  5  6  1  1
63289  1  5  5  6  6
63292  5  4  5  3  3
63293  4  4  4  2  2
63294  4  3  2  4  4
63301  3  5  5  2  2
63302  5  5  3  2  4
63307  5  4  5  4  4
63309  3  5  5  4  1
63313  5  4  4  4  5
63317  4  4  4  2  3
63320  5  6  5  1  1
63321  4  4  3  3  3
63322  6  4  4  2  5
63324  1  1  1  6  6
63326  3  3  4  2  3
63328  6  5  6  1  1
63330  4  4  4  5  5
63331  4  2  3  2  2
63332  6  6  4  1  1
63334  4  5  5  6  4
63335  5  4  4  3  3
63337  6  6  6  1  1
63338  4  5  4  4  4
63339  6  5  5  1  2
63340  6  6  5  1  3
63342  5  5  4  3  2
63346  5  5  6  1  4
63351  5  5  4  2  2
63352  4  2  4  3  5
63358  4  5  2  4  5
63361  3  5  4  2  2
63364  3  3  4  3  4
63369  4  5  5  5  6
63370  4  4  5  1  2
63371  3  4  4  3  5
63372  4  1  2  5  5
63375  3  3  4  4  4
63376  4  6  5  2  2
63378  5  5  5  2 NA
63379  6  5  5  2  4
63382  5  5  5  2  2
63383  5  4  4  2  3
63386  4  4  5  1  4
63389  5  6  6  1  2
63395  5 NA  5  1  1
63399  5  2  5  2  4
63400  4  5  6 NA  1
63402  4  4  4  5  6
63404  5  6  5  2  4
63406  6  3  4  3  5
63408  4  4  6  3  3
63412  5  5  6  2  1
63413  6  6  5  1  1
63414  5  5  4  5  6
63420  5  3  5  2  5
63421  5  2  5  2  2
63427  5  4  5  2  2
63428  6  6  6  1  2
63430  6  6  6  1  1
63431  4  3  4  4  4
63432  5  5  5  2  4
63435  2  2  2  4  6
63437  2  1  1  4  6
63438  4  4  5  3  3
63439  4  4  4  4  4
63441  3  3  5  5  5
63442  4  4  5  3 NA
63444  4  4  5  3  5
63445  4  6  4  4  5
63446  2  3  2  4  5
63448  6  4  6  1  2
63450  5  5  4  3  4
63452  6  5  4  1  2
63454  4  4  4  2  4
63455  5  6  6  2  4
63458  2  2  4  3  5
63459  6  6  2  2  4
63463  3  1  2  4  6
63464  6  5  5  1  2
63465  4  1  5  4  6
63466  6  5  5  1  1
63467  6  5  1  1  1
63468  5  5  4  2  5
63470  6  6  6  4  1
63472  5  5  5  2  4
63473  3  2  5  4  5
63476  5  5  6  2  3
63479  3  4  5  1  1
63480  5  6  5  2  4
63481  4  4  2  2  4
63485  2  3  5  4  5
63486  4  6  4  2  3
63488  5  5  2  2  2
63491  6  6  6  1  1
63493  3  3  2  3  6
63494  5  5  4  3  5
63496  3  5  5  2  1
63498  4  3  3  2  3
63499  4  2  4  4  5
63501  2  5  6  1  1
63502  3  4  4  4  1
63504  6  2  5  2  1
63505  6  5  5  1  6
63509  5  5  5  3  5
63510  6  6  6  1  1
63512  5  5  4  4  6
63513  3  2  3  4  5
63516  6  6  6  2  5
63518  5  6  1  6  6
63521  3  6  3  2  2
63525  5  4  4  4  2
63528  1  2  1  2  4
63530  5  6  5  1  2
63531  5  2  4  1  3
63533  5  6  5  1  6
63534  4  4  4  3  5
63536  6  4  6  1  3
63538  5  5  5  1  4
63547  5  5  2  1  1
63549  5  6  4 NA  2
63551  4  3  4  4  6
63554  4  5  5  3  6
63555  5  4  5  3  5
63556  3  5  4  2  5
63557  5  5  6  3  4
63558  4  3  6  4  3
63559  5  5  6  1  1
63560  6  6  6  1  4
63562  3  4  4  5  6
63567  2  3  3  3  5
63575  4  4  3  4  5
63578  5  4  5  2  4
63579  6  6  5  1  3
63580  3  4  3  5  4
63581  5  5  5  1  3
63582  2  5  5  2  6
63583  6  6  3  1  1
63584 NA  4  4  3  5
63586  5  5  5  2  4
63587  5  5  4  4  2
63588  5  4  5  2  2
63589  3  3  4  6  4
63590  5  5  5  2  2
63591  2  2  2  2  6
63595  5  5  6  2  2
63596  6  5  5  2  2
63597  4  4  4  4  4
63602  6  6  6  1  1
63608  1  5  5  1  2
63609  3  2  1  5  6
63613  5  6  5  1  1
63616  4  3  3  3  2
63617  5  5  4  1  4
63618  6  5  6  2  2
63619  5  3  2  6  6
63621  4  5  5  4  5
63623  4  5  6  1  1
63625  6  4  5  1  1
63631  5  5  4  3  4
63636  6  5  6  3  6
63637  5  5  5  2  5
63638  4  4  3  4  6
63642  5  5  4  3  5
63644  3  5  5  5  5
63648  5  4  4  3  1
63649  4  5  4  4  3
63655  5  5  5  2  1
63657  6  5  5  5  6
63658  3  4  2  2  2
63659  4  3  4  3  4
63661  4  4  4  4  4
63668  6  6  5  1  1
63669  4  3  5  5  4
63670  5  5  3  3  4
63672  5  4  4  2  2
63675  5  4  5  2  4
63676  4  5  3  2  6
63677  6  4  2  1  6
63681  5  5  5  1  5
63682  3  2  3  2  4
63683  5  3  4  2  5
63687  3  4  3  5  6
63690  4  3  4  3  5
63692  5  2  4  2  3
63693  4  4  4  5  5
63696  3  2  2  4  4
63697  6  6  4  1  1
63699  5  4  3  3  1
63700  5  5  5  2  4
63701  6  6  6  1  3
63704  5 NA  5  1  2
63705  6  6  6  1  4
63706  5  4  4 NA  1
63707  3  4  2  3  4
63709  4  4  4  3  4
63711  5  3  2  4  4
63712  6  6  5  2  4
63713  6  6  5  1  1
63721  6  6  6  4  1
63723  2  5  5  1  2
63724  2  3  4  4  5
63726  5  5  5  2  5
63727  6  5  6  1  2
63728  3  2  5  4  4
63729  4  3  4  2  4
63732  2  3  4  2  2
63734  3  4  2  4  4
63735  5  2  4  2  3
63738  5  5  5  4  4
63739  6  6  6  1 NA
63742  6  6  1  1  6
63743  5  3  3  2  3
63744  3  5  4  2  5
63745  5  4  3  3  4
63746  5  2  5  3  5
63748  3  1  5  1  4
63750  6  4  4  2  4
63752  6  5  5  1  5
63760  4  3  3  2  3
63761  2  2  2  4  5
63762  1  1  1  6  6
63763  1  6  5  4  2
63766  5  4  5  1  1
63767  6  6  6  1  1
63768  5  4  5  2  3
63770  5  5  3  2  4
63773  6  6  5  1  4
63775  5  4  4  1  2
63776  5  6 NA  2  6
63778  5  3  6  1  5
63788  5  5  1  5  6
63789  4  5  5  1  2
63791  5  5  5  1  1
63792  4  3  2  2  3
63793  4  3  3  2  3
63794  6  6  4  1  1
63796  4  3  4  3  6
63798  6  6  5  1  4
63799  4  5  5  1  1
63801  5  5  4  2  3
63803  6  4  5  2  4
63807  3  3  3  2  6
63810  5  4  4  4  6
63811  6  6  6  1  3
63812  3  5  5  1  2
63815  4  5  6  2  1
63816  6  5  4  1  2
63817  6  6  6  1  1
63818  3  5  4  4  4
63820  5  6  5  2  4
63822  2  5  2  1  5
63823  4  4  2  3  4
63824  1  6  5  2  5
63825  4  2  5  3  5
63826  4  5  5  5 NA
63827  6  4  5  1  5
63828  5  5  3  3  6
63829  3  5  4  2  3
63834  5  5  4  2  5
63835  4  5  5  3  3
63837  5  4  3  1  1
63838  5  5  5  1  1
63839  4  6  6  6  4
63846  6  3  5  1  1
63847  5  5  5  2  3
63849  6  6  6  1  1
63851  5  5  6  2  4
63852  5  5  6  2  4
63853  5  5  5  2  5
63854  6  6  1  2  5
63855  6  5  6  1  2
63856  4  5  1  2  6
63862  2  5  2  3  5
63863  5  6  5  2  2
63866  4  2  4  3  4
63868  4  3  3  2  4
63871  6  6  6  1  1
63873  3  3  4  4  4
63875  6  5  6  1  3
63877  6  3  2  5  5
63879  4  3  5  2  1
63880  5  5  6  1  5
63881  5  4  5  5  5
63882  5  3  4  1  6
63883  6  2  4  1  2
63884  4  3 NA  2  4
63885  5  5  4  2  4
63887  5  5  4  4  4
63888  3  4  3  2  3
63890  4  2  2  2  2
63897  4  2  5  5  6
63898  2  5  2  5  2
63899  5  6  5  4  4
63900  5  4  6  2  2
63902  5  5  5  2  2
63907  6  5  5  2  5
63909  3  3  4  2  4
63911  5  5  5  1  5
63912  4  3  1  4  2
63913  6  5  5  1  1
63918  6  5  5  1  2
63924  4  3  4  4  3
63925  4  4  4  2  3
63930  4  5  5  2  2
63931  5  5  4  2  5
63932  6  5  5  2  2
63934  5  5  6  1  1
63937  2  5  5  4  6
63939  5  4  4  4  4
63942  4  2  2  6  6
63946  2  4  2  4  5
63947  5  5  5  1  1
63948  4  3  1  5  5
63950  4  4  3  4  5
63952  4  1  5  3  6
63955  1  4  2  3  6
63956  6  6  5  3  2
63957  5  6  5  1  6
63958  5  4  4  2  5
63959  5  5  5  5  5
63961  5  6  4  2  6
63962  5  3  6  1  4
63963  5  4  5  5  6
63966  4  5  5  4  5
63967  5  5  6  1  1
63971  5  5  6  2  4
63977  6  5  4  2  4
63978  6  6  6  5  4
63979  6  6  2  5  5
63980  4  5  2  3  6
63982  6  5  5  3  3
63983  5  3  5  5  5
63984  6  5  5  1  4
63985  4  4  4  4  4
63987  5  5  4  4  3
63990  4  4  3  2  6
63991  3 NA NA NA  3
63993  5  2  3  3  4
63997  4  4  4  3  4
63999  4  2  4  4  4
64000  2  2  4  5  6
64001  6  6  5  1  5
64003  4  5  5  1  2
64005  4  2  6  2  5
64006  5  5  5  1  1
64010  4  5  4  4  4
64012  4  4  5  3  5
64014  5  3  5  2  2
64016  6  6  6  1  1
64017  3  6  6  1  1
64018  6  5  6  2  2
64020  6  2  6  1  2
64021  2  5  4  1  6
64024  5  6  5  1  1
64025  6  4  5  1  2
64028  3  2  4 NA  4
64029  5  6  5  5 NA
64030  4  1  3  3  4
64031  6  6  5  3  1
64032  4  3  3  4  5
64033  2  3  3  1  6
64036  4  5  5  2  2
64044  3  3  5  5  4
64046  4  4  4  3  3
64047  3  4  3  3  4
64049  2  1  6  2  6
64050  5  1  4  3  4
64051  5  5  6 NA  2
64053  6  5  5  1  1
64056  2  2  3  5  6
64057  4  4  4  5  3
64065  4  5  6  2  2
64066  4  1  5  3  2
64069  2  3  6  5  5
64072  6  6  6  1  2
64074  5  5  4  1  2
64075  6  5  6  1  4
64076  2  5  5  3  5
64078  4  4  2  2  5
64079  6  6  6  1  2
64086  4  2  2  5  5
64087  5  3  5  3  5
64089  5  1  2  5  5
64091  2  1  1  4  4
64092  5  5  5  3  3
64094  5  5  3  4  5
64097  3  5  4  2  2
64099  5  5  4  5  6
64100  4  6  4  2  4
64101  5  5  4  2  4
64102  4  4  4  2  2
64103  5  4  4  3  2
64108  5  5  4  1  4
64111  5  5  5  3  3
64113  1  4  5  1  4
64116  4  4  3  3  4
64119  2  2  3  5  6
64120  3  1  3  5  6
64122  6  6  6  1  1
64125  2  2  1  2  6
64128  4  3  3  4  4
64129  5  4  4  2  4
64132  3  4  5  4  5
64134  5  5  4  2  4
64136  5  4  5  2  4
64137  5  4  2  4  4
64138  3  4  2  4  4
64141  5  5  5  4  4
64142  4  4  4  3  4
64143  4  5  5  2  1
64144  2  2  4  3  4
64147  4  5  4  4  4
64148  6  6  4  2  4
64150  3  3  3  3  5
64151  5  6  5  1  3
64152  2  1  4  4  6
64154  6  6  6  1  4
64155  4  4  5  2  5
64156  4  4  5  2  2
64158  4  2  2  4  6
64163  6  5  6  1  4
64168  5  2  3  4  4
64169  6  6  6  2  1
64178  4  5  5  2  2
64179  6  4  2  2  4
64180  3  4  5  1  1
64185  5  4  4  3  5
64192  1  1  1  6  6
64193  4  3  3  3  5
64195  5  5  5  1  2
64200  4  4  5  2  3
64202  1  1  2  6  6
64204  2  4  5  5  2
64206  5  5  6  1  4
64212  2  3  5  5  5
64216  4  4  4  4  6
64217  5  3  2  4  4
64222  5  4  5  2  2
64226  4  2  2  4  6
64228  4  4  4  2  5
64231  1  5  5  1  1
64235  3  2  4  5  4
64236  4  2  5  5  5
64240 NA  5  5  1  1
64241  3  4  5  3  3
64242  5  4  5  1  2
64243  2  4  2  5  5
64244  6  5  5  1  3
64248  2  3  2  5  4
64250  6  6  6  1  6
64251  3  2  4  4  5
64254  4  5  4  2  1
64256  3  6  6  1  1
64261  4 NA  2  4  4
64263  5  3  5  4  4
64264  3  5  6  5  1
64266  6  1  6  1  2
64267  5  5  2  2  4
64274  5  5  5  1  4
64275  6  6  5  2  6
64279  5  5  4  2  2
64280  4  6 NA  1  1
64284  5  5  6  2  3
64286  5  4  5  2  2
64289  5  6  5  1  1
64290 NA  6  5  1  1
64295  5  5  4  2  6
64296  4  5  4  3  6
64297  4  2  3  2  3
64298  4  3  4  3  1
64299  5  5  6  2  2
64300  4  6  6  5  4
64303  5  3  4  3  4
64305  4  5  5  5  2
64308  6  5  4  1  5
64310  5  5  5  2  3
64311  3  4  4  3  4
64312  5  6  4  2  3
64315  6  5  3  3  1
64318  5  5  5  3  4
64320  5  4  5  2  3
64321  6  6  6  1  1
64322  6  2  4  1  1
64323  1  6  6  1  1
64324  4  5  4  5  5
64326  4  6  5  2  4
64327  3  4  5  4  4
64329  3  4  5  4  5
64332  5  3  5  2  3
64333  6  5  5  1  1
64334  4  3  4  3  3
64335  6  3  6  1  2
64338  5  4  5  3  4
64339  4  4  3  2  5
64340  6  5  6  1  3
64341  1  1  6  6  6
64342  4  4  5  4  3
64344  4  5  4  5  5
64345  5  5  5  1  2
64347  4  4  4  3  5
64349  5  5  4  1  2
64352  4  4  4  4  4
64356  4  6  5  2  1
64359  6  5  5  2  2
64363  5  4  2  2  4
64365  5  5  4  3  6
64367  4  5  3  2  2
64368  5  5  5  5  4
64370  5  3  3  3  3
64371  5  5  5  2  2
64372  3  3  3  5  5
64374  5  3  4  3  3
64375  3  2  4  4  6
64377  4  2  4  4  6
64378  5  5  5  2  5
64379  1  1  1  6  6
64382  5  3  4  4  6
64385  5  4  4  2  2
64389  3  6  6  1  1
64390  5  2  5  2  1
64392  6  5  5  1  2
64393 NA  5  2  3  6
64396  3  4  2  2  2
64399  2  2  4  3  5
64400  4  3  4  2  4
64401  6  4  4  2  3
64403  6  6  5  1  2
64413  6  6  6  1  1
64414  5  4  4  2  4
64417  5  6  5  1  1
64418  6  4  5  1  3
64421  5  4  4  2  4
64422  5  1  5  2  4
64424  5  4  3  4  3
64425  3  3  2  2  1
64426  5  5  5  2  4
64427  6  5  2  1  4
64429  5  5  5  1  2
64430  5  5  5  2  3
64431  3  1  3  4  5
64432  4  2  4  2  3
64435  5  5  5  1  2
64436  5  5  4  2  4
64437  5  6  5  2  2
64438  4  1  5  5  5
64439  6  6  4  1  3
64440  3  3  2  5  5
64446  2  4  4  5  6
64450  3  4  3  3  2
64453  5  6  4  4  2
64456  4  2  4  4  4
64458  2  6  1  5  6
64459  4  4  5  4  4
64460  2  5  4  3  4
64461  6  5  6  1  1
64462  5 NA NA  4  5
64463  4  5  6  4  1
64464  5  6  4  2  4
64466  4  4  5  2  2
64467  3  4  4  4  4
64468  5  5  4  2  2
64469  5  6  2  5  6
64471  6  5  6  2  5
64479  3  2  3  4  6
64481  6  4  6  1  1
64483  6  5  5  1  1
64484  5  2  4  1  4
64487  4  4  6  1  3
64488  5  2  6  2  1
64490  5  4  5  4  4
64491  5  5  5  2  2
64493  6  4  2  5  5
64495  5  5  6  1  1
64496  6  6  3  3  2
64499  6  6  3  2  2
64501  4  3  4  4  6
64507  4  4  5  3  5
64508  5  5  4  4  5
64510  5  5  6  1  1
64511  6  6  6  1  1
64512  6  6  6  2  4
64513  5  6  4  2  4
64514  4  6  4  2  2
64516  4  2  4  3  4
64518  6  5  5  1  2
64519  1  5  5  1  2
64520  6  6  6  1  1
64522  5  5  4  4  5
64525  6  2  2  5  6
64528  4  5  5  1  3
64530  5  4  4  2  2
64532  4  2  3  3  2
64537  6  5  4  1  1
64540  6  5  6  1  2
64541  2  2  2  4  4
64543  3  4  2  3  5
64544  4  2  4  2  4
64545  6  6  6  1  1
64546  5  5  5  3  4
64547  5  5  2  1  5
64548  4  5  4  3  6
64549  5  5  6  2  1
64552  2  2  3  3  5
64555  6  5  6  2  5
64556  6  5  5  2  4
64557  3  4  3  5  5
64562  2  2  4  4  5
64563  4  4  6  4  2
64564  6  5  3  2  3
64565  5  4  6  1  1
64567  5  6  5  4  5
64568  5  5  4  2  4
64571  5  3  4  2  5
64572  4  4  6  3  4
64573  4  3  5  4  5
64577  6  5  4  3  1
64579  3  4  1  4  5
64581  6  5  5  1  1
64583  2  3  3  1  4
64585  5  5  5  2  2
64586  4  4  5  3  4
64588  6  5  3  5  3
64591  6  6  5  2  5
64593  4  5  5  2  3
64595  3  4  4  3  4
64600  1  5  1  2  5
64603  6  4  4  2  5
64605  6  5  4  1  6
64606  3  4  2  4  5
64607  6  5  4  2  3
64612  4  5  4  3  4
64614  2  3  3  2 NA
64618  3  4  4  3  3
64620  2  5  5  2  5
64621  6  6  5  1  1
64622  2  6  6  4  4
64623  4  4  4  3  6
64626  5  5  4  3  4
64627  5  5  6  1  3
64630  4  6  6  1  1
64634  4  1  2  4  4
64636  5  5  6  1  1
64638  3  2  6  2  5
64639  4  4  6  2  5
64642  1  1  1  1  1
64648  6  6  5  1  2
64652  5  5  5  1  4
64656  6  6  4  3  4
64658  5  3  5  3  5
64660  5  6  6  1  1
64661  5  5  4  1  2
64664  5  5  6  1  4
64665  4  4  6  2  4
64668  3  5  4  3  5
64669  6  5  6  2  5
64670  5  5  4  2  4
64671  3  3  5  3  4
64673  6  6  4  2  6
64675  3  2  2  4  5
64679  5  4  5  2  3
64680  5  5  5  3  6
64682  5  4  4  2  1
64683  5  2  6  1  1
64685  6  6  6  1  1
64686  4  5  1  5  6
64688  5  3  5  2  4
64689  1  1  4  6  5
64693  4  2  5  5  5
64696  5  5  5  2  1
64697  5  5  6  2  1
64698  5  5  4  1  4
64702  6  6  4  1  2
64706  4  4  4  2  2
64707  5  4  2  3  5
64709  5  5  6  3  1
64712  3  5  3  5  6
64714  3  2  2  4  5
64715  4  4  5  5  5
64716  4  3  4  4  5
64718  2  5  2  2  6
64720  5  3  5  1  1
64724  1  6  6  1  1
64725  5  3  4  6  4
64727  4  5  5  5  5
64729  5  4  4  2  6
64730  5  5  5  1  4
64733  3  2  2  4  6
64735  5  3  4  3  4
64737  5  4  4  4  6
64738  5  2  4  5  5
64739  4  4  6  3  5
64742  5  4  5  5  5
64744  5  5  5  2  3
64747  4  3  4  2  2
64753  3  2  1  5  6
64754  3  4  2  2  2
64758  4  5  4  2  4
64759  5  6  5  2  2
64763  5  5  4  2  4
64768  6  6  5  4  1
64769  6  5  5  5  2
64770  5  6  5  1  3
64771  5  3  5  1  4
64772  4  3  3  3  5
64773  4  4  4  3  4
64774  5  3  5  4  5
64780  4  1  6  5  3
64804  4  5  5  1  2
64807  6  6  5  1  1
64810  3  2  1  2  1
64814  2  2  4  2  5
64815  5  3  5  3  4
64817  6  6  3  2  2
64819  4  4  4  2  4
64822  5  5  5  1  3
64824  5  5  2  2  2
64825  5  5  6  1  1
64826  6  5  4  3  4
64830  6  6  5  6  3
64831  6  6  5  6  3
64835  1  1  1  6  6
64838  5  5  5  2  4
64839  2  3  4  3  1
64842  5  6  1  3  6
64843  5  5  4  2  2
64844  6  2  1  4  6
64845  5  5  4  3  4
64846  5  4  3  2  4
64847  6  6  6  2  2
64849  3  3  4  4  4
64850  5  5  4  5  5
64852  5  5  6  2  1
64857  5  4  2  4  5
64861  5  4  2  2  6
64865  5  5  3  3  3
64866  6  4  5  1  2
64874  4  4  6  2  1
64876  6  5  3  1  5
64877  6  6  5  1  2
64880  1  2  1  5  6
64886  6  5  6  1  1
64887  5  5  4  2  5
64888  5  5  1  4  6
64890  4  3  5  3  2
64891  5  2  4  3  6
64894  3  5  2  2  5
64898  4  5  5  2  6
64902  2  1  4  4  3
64907  5  4  5  3  2
64912  4  3  2  4  5
64914  5  2  3  6  5
64915  5  5  3  2  4
64917 NA  5  5  3  4
64918  4  5  2  3  4
64919  6  6  6  1  6
64920  6  6  5  1  2
64921  2  3  3  4  4
64926  5  2  2  3  6
64931  5  6  4  2  4
64936  6  5  5  2  5
64937  5  6  4  3  2
64938  5  5  5  1  4
64939  3  2  2  3  6
64940  4  3  5  2  2
64944  4  6  6  5  4
64946  6  4  5  6  3
64949  6  6  5  2  1
64950  4  3  3  4  5
64952  4  5  4  2  5
64953  5  5  5  5  5
64954  6  5  5  2  5
64958  5  6  5 NA  6
64960  5  5  3  5  5
64961  5  4  5  2  4
64962  5  6  6  4  6
64963  6  5  4  1  1
64967  5  6  2  5  2
64968  5  6  6  5  6
64969  5  6  6  5  1
64970  5  6  3  5  1
64971  5  6  6  1  1
64975  5  4  6  1  1
64978  5  4  6  1  1
64979  5  4  6  1  1
64980  5  4  6  1  1
64981  5  4  6  1  1
64982  5  4  6  1  1
64984  5  4  5  4  3
64987  5  5  5  3  5
64990  5  6  5  4  4
64991  5  6  6  4  2
64992  4  4  5  3  3
64993  4  3  3  2  4
64996  6  6  4  1  1
64997  6  5  5  1  2
65017  5  5  4  2  3
65018  3  2  5  4  2
65020  5  5  5  2  5
65022  4  4  4  3  2
65025  5  5  5  1  1
65026  4  2  2  3  2
65027  4  4  4  2  5
65028  6  5  2  2  3
65033  4  3  2  2  5
65041  4  4  4  2  2
65042  5  5  5  5  1
65044  5  6  1  4  6
65047  5  5  5  3  2
65049  5  2  5  3  5
65050  6  6  5  2  1
65052  5  4  2  2 NA
65054  5  3  4  3  3
65056  5  5  5  5  4
65058  4  3  4  3  4
65059  4  4  5  2  3
65060  5  5  5  5  1
65061  5  5  5  2  5
65070  4  4  6  2  4
65071  1  6  6  4  5
65075  6  6  6  1  1
65078  6  5  6  1  6
65079  6  6  6  1  1
65080  6  6  5  1  1
65081  4  4  4  3  6
65082  5  5  4  2  3
65083  6  5  6  2  4
65084  5  4  4  4  4
65086  3  3  5  5  5
65087  6  6  3  1  1
65088  5  5  5  1  2
65091  5  4  3  3  4
65092  5  4  4  2  5
65096  4  4  4  2  2
65097  5  4  4  3  4
65099  4  4  2  5  5
65100  4  3  4  2  5
65101  4  3  3  3  3
65105  6  4  4  5  6
65108  5  5  6  4  2
65109  4  4  2  4  2
65111  6  5  5  2  4
65114  5  4  1  4  6
65117  5  4  4  4  4
65121 NA  6  5  5  4
65122  6  3  4  5  5
65124  6  6  6  2  1
65126  6  6  5  2  1
65129  5  5  6  6  5
65130  4  3 NA  6  6
65140  5  5  5  1  2
65142  3  2  2  5  6
65144  6  5  5  2  6
65147  6  5  5  1  3
65150  6  6  6  1  1
65151  3  2  2  4  6
65152  5  3  5  2  2
65156  5  3  5  2  2
65157  2  2  3  5  4
65162  5  5  5  2  3
65163  5  5  5  2  5
65164  4  2  4  5  2
65166  5  4  3  3  4
65168  1 NA NA NA  1
65169  4  5  4  2  2
65170  1  6  6  2  1
65172  4  3  4  3  3
65173  4  3  2  5  5
65174  5  4  6  2  4
65175  3  4  2  2  2
65179  3  2  3  3  3
65180  6  6  3  1  1
65185  5  5  5  1  1
65186  4  4  3  4  1
65188  5  4  5  4  5
65190  6  4  5  5  5
65191  5  6  6  1  1
65193  4  4  4  5  4
65195  4  5  4  3  4
65196  5  3  2  4  4
65197  4  5  4  4  5
65199  5  5  4  2  2
65201  4  5  5  4  2
65202  5  5  2  3  2
65204  5  5  5  3  4
65206  5  5  2  3  3
65207  5  3  5  4  4
65212  6  5  5  1  4
65213  4  4  5  2  6
65215  5  5  4  5  4
65220  4  2  5  4  5
65223  5  5  3  4  5
65224  6  6  6  2  2
65229  4  5  5  1  2
65230  5  5  5  2  1
65232  4  3  3  5  5
65235  4  3  4  3  4
65236  4  3  3  2  2
65237  4  4  5  2  3
65238  6  6  6  1  1
65240  5  5  2  2  6
65241  5  5  5  1  2
65245  1  6  1  1  5
65247  5  2  3  4  5
65249  5  5  3  2  5
65252  5  4  4  2  4
65254  5  5  4  1  4
65255  6  5  4  1  1
65256  5  5  4  2  5
65257  4  4  6  1  5
65258  6  6  6  1  1
65260  5  4  4  2  2
65262  5  5  3  3  4
65266  5  6  6  2  1
65267  5  5  6  2  2
65268  5  6  6  3  6
65271  3  2  4  2  5
65273  5  2  4  5  2
65274  5  6  3  1  3
65275  6  5  4  4  6
65278  5  4  5  3  4
65279  5  2  2  3  2
65281  2  3  5  1  2
65282  6  6  5  1  4
65285  5  4  4  2  5
65286  6  5  5  1  2
65288  5  2  3  5  4
65289  2  4  4  1  2
65291  6  2  3  3  4
65295  4  3  4  4  3
65296  5  5  5  4  4
65297  4  2  2  1  5
65299  4  2  4  3  5
65300  6  6  6  1  1
65301  4  2  2  4  4
65307  5  5  6  4  4
65309  2  4  3  4  5
65311  6  1  6  1  1
65313  6  6  5  1  5
65314  5  6  5  1  4
65316  5  4  5  3  5
65319  2  2  4  4  5
65320  2  5  2  4  5
65322  6  6  5  2  3
65326  3  2  4  3  4
65327  6  5  4  3  4
65332  3  4  5  5  5
65335  6  5  5  1  3
65342  3  2  5  3  4
65343  3  3  5  3  4
65344  3  3  4  2  4
65346  3  3  4  2  4
65347  5  4  2  2  5
65348  5  3  4  3  2
65349  5  6  3  2  5
65352  6  6  5  1  1
65353  5  2  2  2  3
65356  5  2  5  1  4
65359  5  5  3  3  5
65361  5  2  4  3  5
65362  4  4  5 NA  1
65363  5  4  4  5  6
65370  6  5  4  5  5
65372  6  6  5  1  5
65374  5  4  5  1  1
65377  6  6  6  2  1
65378  5  6  6  1  2
65381  4  6  6  1  5
65382  6  6  6  1  3
65385  2  3  3  4  6
65386  2  1  2  4  5
65387  3  6  6  1  1
65388  6  6  6  1  1
65391  5  5  5  1  1
65392  3  5  2  5  5
65395  4  5  5  4  4
65401  3  2  5  3  5
65402  4  4  1  5  5
65403  6  6  4  1  3
65404  4  3  1  4  6
65405  2  5  5  6  5
65407  1  6  5  1  1
65408  5  5  4  3  2
65411  4  3  4  4  5
65412  5  4  5  5  6
65413  5  6  5  1  3
65415  3  6  5  2  3
65417  5  4  4  2  5
65419  4  5  5  1  3
65420  1  6  5  1  1
65421  4  5  5  2  5
65424  4 NA  5  4  5
65426  5  5  6  2  2
65428  4  5  5  2  2
65430  4  2  5  4  6
65432  6  4  3  6  4
65433  3  5  6  3  2
65434  5  5  5  2  2
65435  4  5  6  3  3
65437  6  5  6  1  2
65439  6  4  2  6  5
65440  5  4  4  4  6
65442  5  5  5  1  1
65445  1  5  6  1  1
65446  4  4  4  4  6
65448  5  3  1  6  2
65450  5  5  4  3  4
65452  6  4  4  4  5
65453  6  6  3  2  2
65455  5  6  3  1  2
65457  4  5  2  3  5
65458  5  5  3  2  3
65459  6  5  5  2  1
65460  4  4  5  2  4
65462  5  6  4  2  2
65466  4  6  5  4  5
65467  5  5  4  3  2
65470  5  4  4  1  2
65472  5  5  4  2  2
65473  4  4  4  2  2
65474  5  3  3  2  3
65475  5  6  2  2  4
65476  5  2  5  3  5
65477  6  6  4  1  4
65479  6  5  5  2  3
65484  5  5  3  2  6
65487  6  5  5  1  4
65488  4  4  6  5  1
65490  5  5  4  4  2
65491  3  2  4  3  6
65494  4  5  5  1  2
65496  3  4  4  3  4
65499  5  4  5  1  1
65501  5  5  4  2  3
65502  6  5  4  1  4
65503  5  5  5  1  1
65504  3  3  4  5  3
65506  5  6  5  2  2
65510  6  4  4  5  6
65511  1  4  1  4  6
65512  5  5  3  2  4
65515  5  6  4  1  5
65519  2  2  4  6  4
65522  5  5  5  1  4
65523  4  5  5  4  6
65524  6  5  6  1  1
65526  4  4  4  2  3
65527  6  6  6  1  2
65528  3  4  3  2  3
65529  3  4  5  2  2
65532  5  4  5  2  1
65536  5  5  3  2  4
65538  6  3  4  1  3
65545  4  4  2  2  5
65547  6  5  5  2  4
65548  6  6 NA  1  1
65549  2  4  4  6  6
65551  5  4  4  1  3
65552  5  6  6  1  1
65556  4  4  4  2  2
65557  5  5  5  2  3
65563  6  2  5  1  1
65564  6  5  1  4  1
65565  6  6  6  1  1
65566  6  6  6  1  1
65568  6  5  5  5  5
65569  4  5  6  3  2
65571  5  5  4  3  5
65575  5  2  2  6  5
65577  1  5  2  4  6
65578  5  5  6  1  1
65580  5  2  1  5  5
65583  6  6  6  2  1
65584  4  3  5  3  2
65586  5  6  5  1  1
65589  6  6  3  1  1
65591  4  3  4  5  1
65592  4  6  3  3  2
65593  6  5  6  1  2
65595  4  5  6  2  3
65598  5  5  2  3  5
65599  5  6  6  5  6
65600  4  3  4  5  5
65602  5  4  4  4  6
65605  4  4  4  1  1
65606  3  5  3  4  4
65612  5  3  3  4  5
65613  3  3  1  5  6
65618 NA  3  4  3  1
65620  5  5  5  1  2
65628  4  4  3  2  2
65629  3  2 NA  2  3
65630  2  2  5  5  6
65631  4  2  5  2  2
65632  4  5  5  5  2
65633  6  6  3  1  1
65634  6  6  4  1  2
65635  4  4  2  2  2
65636  6  6  5  2  3
65641  5  5  4  3  3
65643  4  2  3  4  5
65646  5  4  5  2  2
65648  6  5  5  2  2
65649  4  4  5  2  1
65651  5  4  6  2  2
65652  5  5  4  1  2
65653  4  4  3  3  4
65654  6  5  6  1  5
65656  4  5  5  4  3
65659  6  3  4  2  2
65664  4  5  5  4  2
65668  5  6  6  3  1
65671  2  2  1  3  5
65673  5  5  4  2  2
65674  4  3  5  2  3
65675  5  6  6  1  2
65678  6  6  4  2  5
65679  4  5  3  4  4
65680  5  4  5  2  2
65682  4  6  6  1  2
65684  5  6  6  1  1
65687  3  6  6  1  3
65694  6  2  3  4  6
65695  5  5  2  1  5
65696  5  5  2  1  5
65698  5  5  6 NA  3
65699  5  5  6  3  3
65700  4  3  3  1  2
65702  4  3  5  1  2
65703  6 NA  6  1  4
65704  6  5  5  1  2
65705  5  5  4  3  5
65706  6  6  6  1  1
65708  2  1  4  4  1
65709  3  5  6  3  6
65710  2  3  2  6  6
65711  6  5  5  3  3
65712  5  4  6  2  4
65713  6  5  5  1  2
65714  4  5  4  4  4
65715  6  6  5  1  3
65720  6  6  6  1  1
65724  4  5  3  2  5
65726  2  6  5  1  2
65727  6  5  6  6  6
65728  4  5  5  4  5
65730  4  3  3  2  3
65732  1  5  1  4  1
65733  6  5  4  2  5
65734  6  6  6  1  2
65738  5  5  5  2  1
65740  5  4  5  4  4
65742  2  3  2  4  4
65743  6  5  5  1  2
65744  5  6  2  2  2
65745  5  4  5  2  2
65746  5  5  4  1  3
65747  4  2  4  3  4
65748  6  6  5  3  4
65752  4  4  3  3  2
65758  5  1  5  1  1
65762  4  6  5  4  2
65763  6  6  6  1  1
65764  4  5  4  2  2
65765  3  4  4  2  2
65767  6  5  4  4  6
65777  4  5  3  2  2
65778  6  6  6  1  2
65779  5  4  4  5  6
65793  5  5  6  3  2
65794  3  6  4  1  1
65798  4  2  2  4  2
65801  6  6  6  1  1
65802  3  5  3  2  2
65803  6  5  5  5  2
65804  5  6  6  4  5
65809  4  4  5  2  2
65811  2  2  5  2  4
65813  4  4  4  3  4
65816  4  6  3  6  5
65818  4  6  6  1  1
65820  5  4  3  1  1
65822  4  5  5  1  2
65825  5  5  5  1  1
65826  5  6  4  1  2
65828  4  3  5  3  3
65831  5  5  6  1  3
65834  5  4  4  2  3
65836  3  6  1  1  3
65838  6  5  4  6  4
65839  5  5  3  5  4
65840  4  5  4  1  1
65841  6  6  5  1  1
65842  4  4  4  4  5
65844  5  4  4  3  2
65847  6  6  6  2  1
65848  4  5  4  3  2
65849  5 NA  4  2  4
65851  4  4  4  2  5
65852  6  5  5  1  3
65856  4  5  5  2  4
65857 NA  5  2  5  6
65862  4  3  4  3  4
65863  5  5  5  4  2
65864  6  5  6  1  1
65865  4  4  4  4  5
65870  5  4  5  2  4
65874  4  4  5  3  5
65876  2  5  6  1  1
65879  6  2  4  1  2
65880  5  4  5  1  2
65883  4  5  5  4  5
65886  5  5  5  1  1
65888  5  1  5  1  4
65890  5  4  5  2  1
65891  4  4  3  4  2
65892  4  6  4  3  6
65893  6  5  6  1  1
65894  5  4  5  1  1
65895  3  5  3  1  4
65896  5  6  4  1  4
65897  4  4  6  1  3
65899  6  4  3  5  1
65900  3  4  3  4  4
65901  5  5  5  5  2
65902  4  5  1  3  4
65903  6  6  6  2  4
65905  6  6  5  1  1
65909  3  5  4  3  4
65913  5  4  5  3  4
65917  4  5  5  1  3
65918  2  6  1  6  1
65921  5  5  5  4  6
65924 NA  6  5  2  2
65925  6  6  6  2  3
65926  6  5  3  1  1
65929  4  5  3  4 NA
65930  4  5  3  4  3
65932  6  3  4  2  5
65933 NA  4 NA  3  3
65936  4  4  4  3  3
65937  6  5  6  1  1
65938  5  5  4  3  4
65940  4  6  3  1  2
65941  5  4  5  3  1
65942  5  2  4  4  4
65946  3  4  1  4  5
65948  5  6  5  1  1
65950  3  2  2  3  6
65951  6  6  5  1  1
65959  6  6  2  1  1
65961  4  4  3  1  1
65962 NA  4  2  1  1
65965  4  3  4  5  5
65969  5  5  5  4  1
65971  3  4  4  3  3
65972  5  4  4  2 NA
65973  5  5  4  1  2
65974  1  1  1  1  1
65976  4  4  4  1  2
65977  6  5  5  1  1
65981  5  5  5  1  4
65986  5  5  5  4  2
65987  5  6  6  1  2
65988  4  4  4  2  5
65989  4  5  4  3  4
65990  4  2  4  4  2
65992  5  4  5  1  2
65995  5  2  3  4  5
65998  6  6  6  1  1
65999  5  4  4  4  5
66000  5  5  4  1  2
66001  6  6  5  5  3
66002  6  5  5  1  1
66003  6  5  6  1  3
66004  6  6  5  1  1
66006  6  6  5  1  2
66007  6  6  6  1  4
66013  6  4  5  3  1
66014  5  6  5  3  1
66015  5  5  6  2  2
66016  5  4  6  3  4
66017  4  1  1  4  4
66022  5  6  4  1  4
66024  4  3  5  4  5
66032  5  5  5  3  1
66034  5  6  6  1  4
66037  4  4  4  2  1
66039  5  6  5  3  4
66042  4  5  6  1  1
66045  4  2  2  4  3
66047  5  5  4  2  1
66049  4  5  2  4  3
66050  6  6  5  1  1
66053  5  6  5  2  4
66057  4  3  4  4  5
66058  6  5  4  2  1
66060  6  5  4  5  4
66061  6  6  6  4  2
66062  3  5  5  3  2
66063  5  6  6  1  6
66064  6  5  5  3  6
66065  6  4  4  6  1
66067  3  6  6  1  2
66068  5 NA  6  5  3
66070  6  6  5  1  1
66071  5  6  1  4  6
66072  5  6  1  5  5
66077  5  5  4  4  4
66080  6  5  6  2  3
66081  5  6  5  2  1
66082  6  5  6  1  1
66083  6  2  5  2  1
66086  1  1  3  4  5
66088  5 NA  6  4  4
66092  6  6  6  1  1
66093  6  5  4  1  1
66094  5  4  4  2  5
66095  5  2  5  5  6
66096  5  2  4  2  5
66097  4  4  3  4  6
66098  5  4  5  1  2
66102  1  3  2  4  6
66106  6  6  6  1  1
66107  5  5  5  1  1
66108  4  1  5  2  5
66109  4  5  4  2  3
66114  2  4  2  3  6
66115  6  5  5  1  1
66116  4  4  4  1  2
66117  4  5  5  3  4
66119  6  6  6  4  1
66120  4  2  5  5  6
66121  4  5  6  2  4
66122  5  5  6  2  2
66125  6  5  5  2  2
66127  5  5  6  2  1
66135  6  2  5  4  1
66136  6  2  5  4  1
66138  4  4  6  3  5
66139  3  5  6  5  4
66141  6  6  6  1  1
66144  4  4  4  2  3
66150  5  4  5  2  2
66151  4  2  5  4  5
66153  5  4  2  3  2
66156  4  4  5  2  2
66157  6  5  5  1  4
66158  5  5  4  1  1
66161  5  3  6  2  4
66163  6  6  5  2  2
66164  4 NA  5  1  1
66169  6  5  5  2  4
66170  4  4  4  1  1
66171  3  1  2  5  5
66172  5  4  4  2  2
66173  1  6  6  1  5
66176  5  4  4  4  6
66181  6  5  5  1  1
66187  2  3  3  3  5
66188  5  5  4  1  2
66190  4  5  4  1  3
66191  4  4  5  1  2
66195  5  5  2  2  4
66198  5  2  5  1  2
66199  5  5  4  2  2
66201  6  6  6  1  1
66204  4  3  6  1  2
66205  4  5  4  1  1
66210  2  5  6  1  2
66212  5  3  4  4  4
66215  4  4  4  2  4
66216  4  5  3  1  2
66218  5  2  4  2  6
66219  5  5  3  2  5
66224  5  4  4  3  4
66225  5  5  5  2  3
66227  6  6  4  1  6
66231  5  5  6  1  4
66233  5  4  4  2  3
66234  3  4  3  2  4
66237  5  4  5  2  2
66244  4  4  5  2  3
66245  5  5  4  4  4
66246  3  2  4  3  2
66247  2  3  3  4  5
66251  4  4  4  4  5
66253  4  6  5  3  2
66255  4  5  6  2  3
66256  6  4  4  3  5
66257  6  6  5  1  2
66259  5  6  5  1 NA
66264  4  5  5  1  2
66265  6  6  6  2  4
66266  6  4  5  1  2
66271  5  6  5  1  2
66272  4  6  5  2  3
66273  6  5  6  2  4
66274  3  3  2  3  3
66277  5  5  5  2  2
66278  3  2  2  4  6
66279  4  4  3  3  3
66281  4  4  4  3  1
66283  6  1  6  3  2
66286  6  6  6  1  2
66288  4  6  5  2  3
66289  5  5  4  5  5
66291  5  5  5  1  3
66294  2  6  3  1  5
66295  3  3  3  3  3
66297  4  4  3  4  5
66299  4  3  4  3  5
66304  4  3  5  2  4
66306  4  4  4  2  4
66307  5  5  4  3  3
66309  6  6  1  4  6
66311  5  6  6  2  2
66312  5  4  3  3  4
66314  6  5  6  2  1
66317  5  5  5  3  3
66318  5  5  5  2  4
66323  4  5  5  4  3
66324  3  2  4  2  4
66325  5  5  4  2  5
66326  5  5  5  3  2
66329  4  4  4  2  3
66331  5  4  6  1  1
66337  2  1  2  5  5
66341  4  4  4  2  2
66344  4  2  2  4  4
66346  5  5  5  2  2
66348  3  6  4  1  3
66349  5  6  6  1  1
66357  5  3  4  4  4
66360  3  6  3  3  4
66364  1  1  5  2  6
66368  4 NA  2  3  4
66370  5  4  2  3  4
66371  5  4  2  3  3
66372  5  5  2  2  3
66373  5  6  2  3  3
66376  2  5  4  3  2
66381  4  2  2  4  3
66382  6  5  4  2  2
66389  4  5  2  3  2
66391  6  6  5  1  4
66392  4  5  4  1  1
66396  4  4  4  3  4
66399  4  3  5  2  3
66402  5  4  4  1  3
66403  4  3  4  4  6
66404  5  5  5  2  4
66405  3  2  3  4  4
66406  6  6  6  3  1
66408  6  6  5  1  1
66409  6  5  4  1  1
66410  3  5  4  4  6
66413  4  2  3  4  5
66415  5  6  4  2  3
66419  3  3  3  4  4
66421  4  4  5  2  1
66425  6  3  6 NA  3
66429  5  5  5  2  2
66431  5  5  5  1  1
66434  5  5  5  2  2
66437  5  6  6  2  3
66438  3  4  4  2  2
66439  5  2  5  2  3
66440  1  2  5  5  6
66441  4  4  4  4  4
66444  5  5  2  1  2
66445  3  5  5  2  3
66447  4  6  5  2  2
66450  4  5  5  2  2
66451  2  4  4  1  2
66459  4  3  5  3  3
66463  2  5  4  3  6
66464  4  5  5  5  5
66469  4  4  3  2  4
66472  6  4  4  4  6
66474  5  5  6  4  2
66475  6  6  4  2  6
66476  6  5  6  1  4
66483  5  5  4  1  2
66484  1  5  6  3  4
66485  4  6  5  1  1
66486  5 NA  5  1  2
66487 NA  5  4  1  6
66488  6  4  5  4  5
66491  4  4  5  4  4
66492  2  2  4  3  2
66493  3  5  5  3  4
66495  6  6  4  1  4
66496  6  4  4  2  4
66497  4  5  5  3  3
66498  3  5  2  2  4
66499  5  5  5  2  3
66500  6  6  6  1  1
66501  5  5  5  1  2
66503  6  4  6  4  2
66504  6  6  4  2  5
66506  5  4  5  2  3
66507  6  6  6  1  2
66509  6  1  5  1  1
66511  6  5  5  2  4
66512  6  6  6  1  1
66513  5  3  5  1  1
66514  4  3  3  5  4
66517  6  6  5  2  4
66520  3  1  3  1  2
66522  5  5  4  2  3
66525  5  5  5  3  5
66526  5  5  4  1  3
66528  4  2  5  2  2
66529  6  5  6  1  1
66531  3  4  6  3  3
66532  5  5  5  3  3
66533  5  6  4  5  4
66534  5  5  5  4  6
66538  3  3  5  3  2
66540  6  4  6  1  2
66545  5  5  5  3  5
66546  6 NA NA NA  4
66549  5  5  5  4  4
66550  5  5  4  2  4
66551  5  5  4  3  3
66552  6  6  3  2  1
66553  4  5  6  1  1
66554  6  5  6  1  1
66560  4  4  5  3  4
66562  6  5  5  1  4
66563  5  4  4  2  4
66564  5  4  4  4  6
66566  2  2  1  4  5
66568  4  5  6  2  1
66569  5  5  4  1  2
66570  4  5  4  4  5
66572  3  5  5  3  1
66574  3  3  4  5  5
66575  6  4  1  2  1
66576  3  4  6  4  5
66582  4  4  4  1  4
66583  5  3  6  2  6
66585  4  3  5  3  4
66588  4  6  6  1  3
66589  5  5  5  4  3
66591  5  5  3  3  4
66596  5  5  5  2  1
66598  5  6  6  1  2
66601  3  4  5  3 NA
66604  5  5  4  1  2
66605  5  5  2  4  6
66606  6  5  4  2  2
66607  4  6  5  3  3
66609  5  5  5  4  4
66610  4  5  3  5  6
66612  6  6  5  2  6
66615  5  5  2  3  3
66617  6  6  4  2  4
66619  6  5  5  1  1
66620  5  5  4  3  6
66621  6  6  6  1  1
66622  4  2  2  5  5
66623  4  5  3  3  5
66630  4  3  5  3  2
66635  2  5  2  5  6
66637  3  4  5  3  2
66638  5  4  3  2  2
66642  5  6  5  4  3
66645  6  4  4  3  3
66646  6  5  5  2  5
66647  5  5  5  4  4
66648  5  5  2  2  2
66649  5  4  4  1  4
66651  4  5  2  3  3
66653  5  4  5  2  6
66657  5  6  6  3  1
66660  4  4  5  3  3
66662  6  5  6  2  1
66663  4  5  4  4  4
66664  5  6  2  2  2
66665  4  3  4  2  3
66666  5  6  5  2  1
66668  4  6  4  1  1
66669  4  5  5  2  4
66671  4 NA NA  2  2
66674  6  6  6  1  1
66676  2  3  4  3  2
66679  5  3  4  4  4
66680  5  4  4  2  4
66681  4  6  4  2  2
66682  5  6  4  1  2
66683  4  3  4  3  3
66684  5  5  3  2  3
66685  5  5  4  2  2
66689  4  3  5  4  4
66690  3  2  4  3  4
66692  6  6 NA  5  1
66694  5  4  5  2  3
66700  6  6  5  1  2
66701  5  6  6  3  4
66703  5  4  6  4  4
66704  3  3  3  5  5
66708  6  5  6  2  3
66711  3  3  5  3  5
66712  5  5  5  4  3
66713  5  5  4  1  6
66716  5  6  5  2  6
66717  3  4  2  5  6
66718  2  4  5  3  4
66722  6  6  3  1  2
66723  2  6  4  3  6
66724  5  5  6  3  3
66727  6  6  6  1  1
66728  4  5  5  2  3
66729  6  5  5  1  5
66730  2 NA  3  2  6
66731  6  5  5  3  3
66733  4  4  4  2  4
66734  5  3  4  2  4
66737  4  4  5  1  1
66739  4  4  5  4  5
66741  5  4  6  3  4
66743  5  5  3  2  2
66744  5  5  4  2  5
66745  5  6  5  1  4
66748  6  6  6  1  1
66749  6  6  5  1  1
66751  5  5  5  1  1
66755  4  5  4  3  3
66756 NA  6  5  5  1
66757  4  4  4  4  4
66760  4  4  4  2  2
66764  1  5  5 NA  2
66766  3  2  2  5  5
66768  6  5  6  1  1
66769  5  5  4  4  2
66770  6  5  5  4  4
66771  2  2  2  5  5
66772  6  5  5  4  2
66775  5  5  5  1  2
66778  6  5  5  1  1
66779  5  5  5  1  3
66785  3  3  6  1  1
66788  5  6  6  2  6
66790  5  6  5  1  5
66792  2  6  5  2  1
66793  4  5  5  1  2
66797  5  5  2  2  5
66800  5  5  5  1  2
66801  4  5  5  1  3
66804  6  5  4  1  1
66806  4  5  5  3  3
66807  2  4  4  4  3
66810  5  4  5  2  5
66812  5  5  5  2  6
66813  5  4  2  4  4
66814  5  6  4  2  4
66817  3  2  4  5  4
66819  4  3  5  3  6
66820  6  5  4  2  4
66824  4  6  5  3  4
66826  2  2  4  3  4
66830  3  2  3  4  4
66831  5  4  5  3  2
66832  3  1  3  5  5
66833  1  6  6  1  3
66838  6  6  5  2  2
66839  4  2  2  2  3
66840  6  4  5  2  2
66842  5  4  3  1  1
66843  5  3  5  5  5
66845  5  5  5  1  3
66847  4  3  2  2  4
66848  6  6  6  1  2
66850  4  5  4  2  2
66853  5  4  5  2  2
66855  5  4  4  2  5
66856  4  5  4  2  4
66857  3  5 NA  2  5
66858  5  3  5  2  6
66860  5  4  4  3  4
66863  4  5  4  3  6
66864  5  6  5  3  6
66867  3  5  4 NA  2
66868  2  1  1  4  3
66869  5  5  2  2  2
66872  5  6  4  2  3
66873  5  4  6  1  1
66879 NA  4  5  2  2
66886  6  6  5  1  1
66887  5  5  4  1  2
66890  1  1  3  5  6
66892  6  6  6  1  2
66896  5  4  2  3  2
66897  5  5  6  1  2
66898  4  4  4  3  5
66899  4  2  3  5  6
66902  3  6  6  1  4
66903  3  4  2  4  5
66905  4  4  5  4  2
66911  5  4  5  2  5
66916  5  5  4  3  2
66917  4  2  4  4  4
66918  5  2  1  1  6
66919  5  5  6  2  4
66920  5  5  6  1  5
66921  4  3  3  4  4
66924  4  5  4  1  3
66925  6  5  5  2  1
66926  5  5  5  1  5
66927  5  5  5  2  4
66929  6  5  5  3  4
66930  4  5  5  2  2
66932  6  5  6  2  4
66934  5  2  4  2  3
66935  5  4  3  2  5
66937  6  5  6  2  2
66944  5  5  3  4  3
66945  5  6  5  1  2
66946  2  1  4  5  4
66947  5  5  5  2  4
66949  5  6  3  3  5
66953  2  1  3  6  5
66960  3  4  5  4  4
66962  5  5  5  3  5
66965  5  4  4  3  4
66968  5  4  5  5  6
66970  6  6  1  3  1
66982  5  6  5  1  1
66983  6  5  6  5  1
66985  5  5  5  2  2
66986  3  3  2  3  5
66987  2  5  2  1  4
66988  6  4  5  2  5
66994  6  5  2  4  6
66995  4  6  5  4  5
66997  4  1  6  2  4
67000  1  1  1  1  4
67003  3  1  5  4  6
67007  5  6  2  2  4
67008  5  6  5  4  3
67013  4  2  4  4  4
67014  5  4  5  5  2
67017  6  5  4  2  6
67018  6  6  5  1  3
67019  6  6  4  1  2
67022  3  5  2  4  2
67023  5  5  4  1  3
67024  6  4  6  2  3
67025  6  6  5  1  2
67026  2  3  5  3  5
67027  5  3  5  2  4
67029  5  6  4  2  5
67031  5  5  5  2  3
67033  5  5  6  3  2
67034  4  4  4  3  2
67036  4  5  5  1  2
67039  4  4  4  4  6
67040  3  3  2  3  4
67041  6  5  6  1  1
67042  4  4  4  3  2
67043  5  5  5  2  2
67045  6  6  4  1  2
67046  6  5  6  1  4
67049  5  6  5  1  1
67055  6  5  6  1  2
67056  6  5  6  2  5
67057  6  5  5  1  2
67059  4  6  3  1  3
67064 NA  6  5  4  4
67065  5  2  4  2  2
67066  5  5  2  2  6
67070 NA  6  4  2  2
67072  4  5  5  2  1
67073  3  6  6  1  1
67075  5  3  4  2  3
67078  5  4  5  2  5
67079  5  5  5  1  2
67080  1  1  2  6  6
67082  5  6  5  5  5
67085  6  5  5  2  1
67087  5  4  4  2  2
67091  3  5  3  3  4
67093  3  4  2  4  4
67095  6  6  4  3  6
67096  3  2  4  3  6
67098  6  6  6  1  1
67101  3  4  4  2  2
67104  3  4  4  4  4
67107  6  5  4  2  4
67109  5  5  5  1  2
67115  5  5  4  3  4
67116  4  3  3  2  6
67118  2  4  1  6  6
67119  1  6  2  1  4
67121  3  3  5  2  4
67123  5  4  4  1  1
67124  1  3  1  4  5
67126  6  6  3  1  4
67132  5  4  3  2  6
67134  4  2  1  4  6
67135  4  4  5  2  4
67136  4  4  5  6  2
67140  5  5  5  3  4
67143  4  5  5  1  4
67144  5  6  5  3  2
67145  2  3  4  5  6
67146  2  2  4  3  1
67148  3  3  3  2  4
67149  5  2  5  6  4
67152  5  6  5  1  1
67154  2  5  5  5  2
67155  5  6  1  3  1
67156  5  6  5  4  3
67157  4  5  4  3  3
67158  6  5  5  3  3
67161  5  6  6  2  1
67162  2  4  4  4  2
67168  6  6  4  4  2
67174  5  4  3  2  2
67179  6  6  5  1  1
67180  5  2  5  4  5
67183  4  5  3  1  4
67184  4  2  3  3  4
67185  5  4  5  2  4
67186  6  4  1  3  2
67188  1  1  4  5  5
67189  6 NA  3  1  1
67190  5  4  3  4  5
67191  3  3  3  5  6
67197  5  4  5  4  2
67202  3  2  5  6  6
67203  6  6  5  3  3
67206  6  6 NA  3  4
67213  4  3  4  4  3
67215  4  2  5  4  4
67220  2  3  4  4  4
67222  5  4  6  2  4
67223  6  6  6  1  1
67224  3  5  2  3  5
67225  6  5  3  1  4
67226  1  1  4  5  6
67229  1  1  2  5  6
67230  4  4  6  3  3
67232  5  5  4  1  1
67234  6  5  5  2  6
67237  5  5  5  2  2
67238  6  5  2  5  5
67239  6  6  5  2  4
67240  4  5  2  2  6
67242  4  3  3  3  3
67246  4  4  4  2  2
67247  4  4  3  4  4
67251  5  5  6  1  1
67254  2  6  3  4  5
67255  6  6  6  1  1
67257  4  5  4  4  5
67258  6  5  4  2  5
67259  4 NA  6 NA  1
67260  4  2  1  2  2
67262  4  5  6  1  2
67263  4  3  4  3  4
67269  4  3  6  4  1
67270  5  5  5  2  4
67271  3  4  4  3  4
67272  2  3  4  5  2
67274  3  4  5  6  6
67275  6  5  5  1  1
67277  4  4  5  2  2
67278  4  5  2  4  6
67279  5  3  5  2  2
67283  6  5  5  1  4
67284  3  2  4  2  4
67286  5  5  3  1  1
67287  6  6  4  1  2
67288  6  6  1  1  1
67289  5  4  5  2  4
67294  4  4  4  4  5
67295  6  6  5  1  1
67298  5  5  6  3  1
67299  6  4  4  3  3
67303  3  4  5  3  3
67307  2  1  1  6  6
67309  3  5  5  3  3
67310  4  4  4  3  4
67312  3  4  4  4  5
67313  6  6  2  1  4
67315  5  5  5  1  1
67316  4  4  4  2  3
67322  2  3  4  2  5
67324  5  6  5  4  4
67325  6  6  6  1  1
67328  2  2  4  5  3
67331  5  5  5  4  5
67332  5  4  5  3  2
67334  5  6  6  1  3
67335  4  5  4  2  2
67336  5  5  5  2  5
67338  4  5  5  2  4
67339  6  6  5  1  2
67341  5  4  5  2  1
67342  4  4  6  1  1
67344  3  1  1  6  5
67345  5  5  1  5  5
67346  3  6  3  2  6
67347  2  4 NA  4  4
67352  5  6  6  1  4
67355  6  5  6  1  2
67356  6  5  6  1  2
67357  5  2  4  2  5
67360  6  4  6  2  5
67363  3  2  4  4  1
67364  6  6  2  4  4
67365  6  6  6  1  1
67366  5  6  4  2  2
67367  6  6  6  1  2
67368  2 NA  6 NA  3
67370  5  5  6  5  4
67371  5  5  6  5  4
67374  5  4  3  2  6
67376  6  6  5  3  3
67377  4  4  4  3  4
67378  4  4  4  3  5
67379  5  3  5  3  2
67380  2  1  4  6  4
67382  5  4  4  1  3
67388  5  4  5  2  2
67390  4  5  6  4  5
67392  6  5  4  3  4
67393  3  5  5  2  5
67395  5  5  4  5  5
67396  4  4  4  4  5
67397  4  5  5  3  1
67399  3  3  4  4  4
67401  6  5  5  1  1
67403  2  2  4  5  5
67406  5  4  2  5  6
67408  6  6  6  1  3
67413  1  1  1  1  6
67415  6  6  3  1  1
67417  1  3  2  5  6
67418  5  5  5  2  5
67420  4  4  5  3  5
67421  6  6  6  2  1
67426  5  5  5  2  5
67427  5  1  2  6  4
67429  5  3  5  3  5
67431  4  5  5  2  4
67436  5  4  5  3  4
67438  5  4  4  3  2
67439  5  4  4  3  2
67440  4  6  3  4  5
67441  4  3  4  2  3
67442  6  6  2  3  3
67445  5  4  5  2  2
67446  3  3  5  2  2
67447  5  5  6  3  4
67449  6  4  2  5  6
67451  2  4  4  1  2
67453  6  5  5  1  4
67454  5  5  3  2  4
67455  6  6  6  2  1
67458  3  3  1  3  4
67460  3  3  6  3  6
67462  5  4  4  3  5
67465  6  6  6  6  6
67471  4  4  4  2  5
67473  4  5  5  2  2
67479  4  3  3  4  2
67480  3  6  1  5  6
67483  5  3  4  2  3
67485  6  5  5  1  5
67487  6  5  5  1  1
67488  5  3  5  3  3
67489  4  4  3  3  4
67490  6  5  5  5  3
67495  4  4  2  2  2
67497  5  6  5  1  2
67502  4  4  4  4  3
67503  2  4  4  3  3
67504  5  3  3  5  5
67505  5  4  5  1  2
67506  6  6  6  1  1
67507  4  6  4  1  2
67508  5  4  4  2  2
67509  6  6  5  2  6
67510  2  4  4  5  1
67512  6  5  2  4  1
67516  3  5  4  4  4
67518  5  5  5  3  3
67521  5  6  5  2  2
67522  6  6  5  1  1
67523  5  6  6  1  1
67524  6 NA  5  2  2
67525  6  6  5  1  3
67526  5  5  5  2  5
67528  5  5  4  4  5
67529  5  5  5  2  3
67530  5  4  5  2  3
67531  6  5  5  2  4
67533  5  6  5  1  2
67534  5  2  2  4  3
67535  5  5  5  4  1
67537  4  4  1  4  1
67539  6  6  5  2  1
67540  5  4  3  4  4
67541  3  5  3  6  4
67544  6  6  2  4  5
67547  5  4  5  3  4
67549  5  4  2  3  5
67551  6  6  6  1  1
67552  2  3  4  4  3
67556  5  5  5  1  1
67559  5  5  5  2  6
67560  5  5  3  3  3

2. filter()

  • Often times, when conducting research (experiments or otherwise), there are observations (people, specific trials, etc.) that you don’t want to include.
  • We can use filter() with logical statements to include only rows that match certain conditions
  • We can refer to both bare quoted columns and objects in the global environment
  • == or !=
  • < or <=
  • > or >=
  • %in%
  • all_of()
  • one_of()
  • !
  • | and &

tidyr: pivot_longer() and pivot_wider()

1. pivot_longer()

  • (Formerly gather()) Makes wide data long, based on a key
  • Core arguments:
    • data: the data, blank if piped
    • cols: columns to be made long, selected via select() calls
    • names_to: name(s) of key column(s) in new long data frame (string or string vector)
    • values_to: name of values in new long data frame (string)
    • names_sep: separator in column headers, if multiple keys
    • values_drop_na: drop missing cells (similar to na.rm = T)

1. pivot_longer()

Why would I make my data longer?

  • Main reason: Columns names sometimes contain data.
  • Example: Billboard data has time information in column names
data(billboard)
str(billboard)
spc_tbl_ [317 × 79] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ artist      : chr [1:317] "2 Pac" "2Ge+her" "3 Doors Down" "3 Doors Down" ...
 $ track       : chr [1:317] "Baby Don't Cry (Keep..." "The Hardest Part Of ..." "Kryptonite" "Loser" ...
 $ date.entered: Date[1:317], format: "2000-02-26" "2000-09-02" ...
 $ wk1         : num [1:317] 87 91 81 76 57 51 97 84 59 76 ...
 $ wk2         : num [1:317] 82 87 70 76 34 39 97 62 53 76 ...
 $ wk3         : num [1:317] 72 92 68 72 25 34 96 51 38 74 ...
 $ wk4         : num [1:317] 77 NA 67 69 17 26 95 41 28 69 ...
 $ wk5         : num [1:317] 87 NA 66 67 17 26 100 38 21 68 ...
 $ wk6         : num [1:317] 94 NA 57 65 31 19 NA 35 18 67 ...
 $ wk7         : num [1:317] 99 NA 54 55 36 2 NA 35 16 61 ...
 $ wk8         : num [1:317] NA NA 53 59 49 2 NA 38 14 58 ...
 $ wk9         : num [1:317] NA NA 51 62 53 3 NA 38 12 57 ...
 $ wk10        : num [1:317] NA NA 51 61 57 6 NA 36 10 59 ...
 $ wk11        : num [1:317] NA NA 51 61 64 7 NA 37 9 66 ...
 $ wk12        : num [1:317] NA NA 51 59 70 22 NA 37 8 68 ...
 $ wk13        : num [1:317] NA NA 47 61 75 29 NA 38 6 61 ...
 $ wk14        : num [1:317] NA NA 44 66 76 36 NA 49 1 67 ...
 $ wk15        : num [1:317] NA NA 38 72 78 47 NA 61 2 59 ...
 $ wk16        : num [1:317] NA NA 28 76 85 67 NA 63 2 63 ...
 $ wk17        : num [1:317] NA NA 22 75 92 66 NA 62 2 67 ...
 $ wk18        : num [1:317] NA NA 18 67 96 84 NA 67 2 71 ...
 $ wk19        : num [1:317] NA NA 18 73 NA 93 NA 83 3 79 ...
 $ wk20        : num [1:317] NA NA 14 70 NA 94 NA 86 4 89 ...
 $ wk21        : num [1:317] NA NA 12 NA NA NA NA NA 5 NA ...
 $ wk22        : num [1:317] NA NA 7 NA NA NA NA NA 5 NA ...
 $ wk23        : num [1:317] NA NA 6 NA NA NA NA NA 6 NA ...
 $ wk24        : num [1:317] NA NA 6 NA NA NA NA NA 9 NA ...
 $ wk25        : num [1:317] NA NA 6 NA NA NA NA NA 13 NA ...
 $ wk26        : num [1:317] NA NA 5 NA NA NA NA NA 14 NA ...
 $ wk27        : num [1:317] NA NA 5 NA NA NA NA NA 16 NA ...
 $ wk28        : num [1:317] NA NA 4 NA NA NA NA NA 23 NA ...
 $ wk29        : num [1:317] NA NA 4 NA NA NA NA NA 22 NA ...
 $ wk30        : num [1:317] NA NA 4 NA NA NA NA NA 33 NA ...
 $ wk31        : num [1:317] NA NA 4 NA NA NA NA NA 36 NA ...
 $ wk32        : num [1:317] NA NA 3 NA NA NA NA NA 43 NA ...
 $ wk33        : num [1:317] NA NA 3 NA NA NA NA NA NA NA ...
 $ wk34        : num [1:317] NA NA 3 NA NA NA NA NA NA NA ...
 $ wk35        : num [1:317] NA NA 4 NA NA NA NA NA NA NA ...
 $ wk36        : num [1:317] NA NA 5 NA NA NA NA NA NA NA ...
 $ wk37        : num [1:317] NA NA 5 NA NA NA NA NA NA NA ...
 $ wk38        : num [1:317] NA NA 9 NA NA NA NA NA NA NA ...
 $ wk39        : num [1:317] NA NA 9 NA NA NA NA NA NA NA ...
 $ wk40        : num [1:317] NA NA 15 NA NA NA NA NA NA NA ...
 $ wk41        : num [1:317] NA NA 14 NA NA NA NA NA NA NA ...
 $ wk42        : num [1:317] NA NA 13 NA NA NA NA NA NA NA ...
 $ wk43        : num [1:317] NA NA 14 NA NA NA NA NA NA NA ...
 $ wk44        : num [1:317] NA NA 16 NA NA NA NA NA NA NA ...
 $ wk45        : num [1:317] NA NA 17 NA NA NA NA NA NA NA ...
 $ wk46        : num [1:317] NA NA 21 NA NA NA NA NA NA NA ...
 $ wk47        : num [1:317] NA NA 22 NA NA NA NA NA NA NA ...
 $ wk48        : num [1:317] NA NA 24 NA NA NA NA NA NA NA ...
 $ wk49        : num [1:317] NA NA 28 NA NA NA NA NA NA NA ...
 $ wk50        : num [1:317] NA NA 33 NA NA NA NA NA NA NA ...
 $ wk51        : num [1:317] NA NA 42 NA NA NA NA NA NA NA ...
 $ wk52        : num [1:317] NA NA 42 NA NA NA NA NA NA NA ...
 $ wk53        : num [1:317] NA NA 49 NA NA NA NA NA NA NA ...
 $ wk54        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk55        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk56        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk57        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk58        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk59        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk60        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk61        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk62        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk63        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk64        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk65        : num [1:317] NA NA NA NA NA NA NA NA NA NA ...
 $ wk66        : logi [1:317] NA NA NA NA NA NA ...
 $ wk67        : logi [1:317] NA NA NA NA NA NA ...
 $ wk68        : logi [1:317] NA NA NA NA NA NA ...
 $ wk69        : logi [1:317] NA NA NA NA NA NA ...
 $ wk70        : logi [1:317] NA NA NA NA NA NA ...
 $ wk71        : logi [1:317] NA NA NA NA NA NA ...
 $ wk72        : logi [1:317] NA NA NA NA NA NA ...
 $ wk73        : logi [1:317] NA NA NA NA NA NA ...
 $ wk74        : logi [1:317] NA NA NA NA NA NA ...
 $ wk75        : logi [1:317] NA NA NA NA NA NA ...
 $ wk76        : logi [1:317] NA NA NA NA NA NA ...
 - attr(*, "spec")=
  .. cols(
  ..   year = col_skip(),
  ..   artist = col_character(),
  ..   track = col_character(),
  ..   time = col_skip(),
  ..   date.entered = col_date(format = ""),
  ..   wk1 = col_double(),
  ..   wk2 = col_double(),
  ..   wk3 = col_double(),
  ..   wk4 = col_double(),
  ..   wk5 = col_double(),
  ..   wk6 = col_double(),
  ..   wk7 = col_double(),
  ..   wk8 = col_double(),
  ..   wk9 = col_double(),
  ..   wk10 = col_double(),
  ..   wk11 = col_double(),
  ..   wk12 = col_double(),
  ..   wk13 = col_double(),
  ..   wk14 = col_double(),
  ..   wk15 = col_double(),
  ..   wk16 = col_double(),
  ..   wk17 = col_double(),
  ..   wk18 = col_double(),
  ..   wk19 = col_double(),
  ..   wk20 = col_double(),
  ..   wk21 = col_double(),
  ..   wk22 = col_double(),
  ..   wk23 = col_double(),
  ..   wk24 = col_double(),
  ..   wk25 = col_double(),
  ..   wk26 = col_double(),
  ..   wk27 = col_double(),
  ..   wk28 = col_double(),
  ..   wk29 = col_double(),
  ..   wk30 = col_double(),
  ..   wk31 = col_double(),
  ..   wk32 = col_double(),
  ..   wk33 = col_double(),
  ..   wk34 = col_double(),
  ..   wk35 = col_double(),
  ..   wk36 = col_double(),
  ..   wk37 = col_double(),
  ..   wk38 = col_double(),
  ..   wk39 = col_double(),
  ..   wk40 = col_double(),
  ..   wk41 = col_double(),
  ..   wk42 = col_double(),
  ..   wk43 = col_double(),
  ..   wk44 = col_double(),
  ..   wk45 = col_double(),
  ..   wk46 = col_double(),
  ..   wk47 = col_double(),
  ..   wk48 = col_double(),
  ..   wk49 = col_double(),
  ..   wk50 = col_double(),
  ..   wk51 = col_double(),
  ..   wk52 = col_double(),
  ..   wk53 = col_double(),
  ..   wk54 = col_double(),
  ..   wk55 = col_double(),
  ..   wk56 = col_double(),
  ..   wk57 = col_double(),
  ..   wk58 = col_double(),
  ..   wk59 = col_double(),
  ..   wk60 = col_double(),
  ..   wk61 = col_double(),
  ..   wk62 = col_double(),
  ..   wk63 = col_double(),
  ..   wk64 = col_double(),
  ..   wk65 = col_double(),
  ..   wk66 = col_logical(),
  ..   wk67 = col_logical(),
  ..   wk68 = col_logical(),
  ..   wk69 = col_logical(),
  ..   wk70 = col_logical(),
  ..   wk71 = col_logical(),
  ..   wk72 = col_logical(),
  ..   wk73 = col_logical(),
  ..   wk74 = col_logical(),
  ..   wk75 = col_logical(),
  ..   wk76 = col_logical()
  .. )

1. pivot_longer()

Why would I make my data longer?

billboard |>
  pivot_longer(
    cols = starts_with("wk"), 
    names_to = "week", 
    names_prefix = "wk",
    names_transform = as.numeric,
    values_to = "rank"
  )
# A tibble: 24,092 × 5
   artist track                   date.entered  week  rank
   <chr>  <chr>                   <date>       <dbl> <dbl>
 1 2 Pac  Baby Don't Cry (Keep... 2000-02-26       1    87
 2 2 Pac  Baby Don't Cry (Keep... 2000-02-26       2    82
 3 2 Pac  Baby Don't Cry (Keep... 2000-02-26       3    72
 4 2 Pac  Baby Don't Cry (Keep... 2000-02-26       4    77
 5 2 Pac  Baby Don't Cry (Keep... 2000-02-26       5    87
 6 2 Pac  Baby Don't Cry (Keep... 2000-02-26       6    94
 7 2 Pac  Baby Don't Cry (Keep... 2000-02-26       7    99
 8 2 Pac  Baby Don't Cry (Keep... 2000-02-26       8    NA
 9 2 Pac  Baby Don't Cry (Keep... 2000-02-26       9    NA
10 2 Pac  Baby Don't Cry (Keep... 2000-02-26      10    NA
# ℹ 24,082 more rows

1. pivot_longer()

Why would I make my data longer?

  • This doesn’t just apply to longitudinal data. This is also important when thinking about iteration.
  • For example, if you variables can be grouped into different categories (covariates, IVs/predictors, DVs/outcomes, moderators, etc.), then your column names contain implicit data
  • The data below contain both time, variable, and category information
# load the codebook
(codebook <- read_csv("week6-codebook.csv") |>
    mutate(old_name = str_to_lower(old_name)))
# A tibble: 153 × 14
   dataset old_name item_text      scale category label item_name  year new_name
   <chr>   <chr>    <chr>          <chr> <chr>    <chr> <chr>     <dbl> <chr>   
 1 <NA>    persnr   Never Changin…  <NA> Procedu… <NA>  SID           0 Proc_SID
 2 <NA>    hhnr     household ID    <NA> Procedu… <NA>  household     0 Proc_HH…
 3 ppfad   gebjahr  Year of Birth  "num… Demogra… <NA>  DOB           0 Demo_dob
 4 ppfad   sex      Sex            "\n1… Demogra… <NA>  Sex           0 Demo__s…
 5 vp      vp12501  Thorough Work…  <NA> big5     C     thorough   2005 big5_C_…
 6 zp      zp12001  Thorough Work…  <NA> big5     C     thorough   2006 big5_C_…
 7 bdp     bdp15101 Thorough Work…  <NA> big5     C     thorough   2013 big5_C_…
 8 vp      vp12502  Am communicat…  <NA> big5     E     communic   2005 big5_E_…
 9 zp      zp12002  Am communicat…  <NA> big5     E     communic   2009 big5_E_…
10 bdp     bdp15102 Am communicat…  <NA> big5     E     communic   2013 big5_E_…
# ℹ 143 more rows
# ℹ 5 more variables: reverse <dbl>, mini <dbl>, maxi <dbl>, recode <chr>,
#   lavaan_name <chr>
old.names <- codebook$old_name # get old column names
new.names <- codebook$new_name # get new column names
soep <- read_csv("week6-data.csv") |>
    select(all_of(old.names))
soep
# A tibble: 28,290 × 153
   persnr  hhnr gebjahr   sex vp12501 zp12001 bdp15101 vp12502 zp12002 bdp15102
    <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>    <dbl>   <dbl>   <dbl>    <dbl>
 1    901    94    1951     2       6      -1        7       4       4        5
 2   1202   124    1913     2       7      NA       NA       6      NA       NA
 3   2301   230    1946     1       7       6        6       6       4        5
 4   2302   230    1946     2       6       7        7       5       5        5
 5   2304   230    1978     1       5      NA       NA       7      NA       NA
 6   2305   230    1946     2      NA      NA       NA      NA      NA       NA
 7   4601   469    1933     2       6      NA       NA       6      NA       NA
 8   4701   477    1919     2       6       6       NA       6       5       NA
 9   4901   493    1925     2       5       6        6       7       6        5
10   5201   523    1955     1       7       7        7       5       6        4
# ℹ 28,280 more rows
# ℹ 143 more variables: vp12503 <dbl>, zp12003 <dbl>, bdp15103 <dbl>,
#   vp12504 <dbl>, zp12004 <dbl>, bdp15104 <dbl>, vp12505 <dbl>, zp12005 <dbl>,
#   bdp15105 <dbl>, vp12506 <dbl>, zp12006 <dbl>, bdp15106 <dbl>,
#   vp12507 <dbl>, zp12007 <dbl>, bdp15107 <dbl>, vp12508 <dbl>, zp12008 <dbl>,
#   bdp15108 <dbl>, vp12509 <dbl>, zp12009 <dbl>, bdp15109 <dbl>,
#   vp12510 <dbl>, zp12010 <dbl>, bdp15110 <dbl>, vp12511 <dbl>, …

1. pivot_longer()

Why would I make my data longer?

  • By pivoting our data longer, we can more easily extract information from the column names
  • Pivot the data below longer. Some hints:
    • don’t make the procedural or demographic variables long
    • split the column names you make long into four chunks:
      • “category”, “label”, “item_name”, “year”
    • drop na values
soep |>
  setNames(new.names)
# A tibble: 28,290 × 153
   Proc_SID Proc_HHID Demo_dob Demo__sex big5_C_thorough_2005
      <dbl>     <dbl>    <dbl>     <dbl>                <dbl>
 1      901        94     1951         2                    6
 2     1202       124     1913         2                    7
 3     2301       230     1946         1                    7
 4     2302       230     1946         2                    6
 5     2304       230     1978         1                    5
 6     2305       230     1946         2                   NA
 7     4601       469     1933         2                    6
 8     4701       477     1919         2                    6
 9     4901       493     1925         2                    5
10     5201       523     1955         1                    7
# ℹ 28,280 more rows
# ℹ 148 more variables: big5_C_thorough_2006 <dbl>, big5_C_thorough_2013 <dbl>,
#   big5_E_communic_2005 <dbl>, big5_E_communic_2009 <dbl>,
#   big5_E_communic_2013 <dbl>, big5_A_coarse_2005 <dbl>,
#   big5_A_coarse_2009 <dbl>, big5_A_coarse_2013 <dbl>,
#   big5_O_original_2005 <dbl>, big5_O_original_2009 <dbl>,
#   big5_O_original_2013 <dbl>, big5_N_worry_2005 <dbl>, …

1. pivot_longer()

Why would I make my data longer?

By pivoting our data longer, we can more easily extract information from the column names

soep_long <- soep |>
  setNames(new.names) |>
  pivot_longer(
    cols = c(-starts_with("Proc"), -starts_with("Dem"))
    , names_to = c("category",  "label",    "item_name",    "year")
    , names_pattern = "(.*)_(.*)_(.*)_(.*)"
    , values_to = "value"
    , values_drop_na = T
  ) |> mutate(year = as.numeric(year))
soep_long
# A tibble: 1,845,743 × 9
   Proc_SID Proc_HHID Demo_dob Demo__sex category label item_name  year value
      <dbl>     <dbl>    <dbl>     <dbl> <chr>    <chr> <chr>     <dbl> <dbl>
 1      901        94     1951         2 big5     C     thorough   2005     6
 2      901        94     1951         2 big5     C     thorough   2006    -1
 3      901        94     1951         2 big5     C     thorough   2013     7
 4      901        94     1951         2 big5     E     communic   2005     4
 5      901        94     1951         2 big5     E     communic   2009     4
 6      901        94     1951         2 big5     E     communic   2013     5
 7      901        94     1951         2 big5     A     coarse     2005     4
 8      901        94     1951         2 big5     A     coarse     2009     3
 9      901        94     1951         2 big5     A     coarse     2013     4
10      901        94     1951         2 big5     O     original   2005     5
# ℹ 1,845,733 more rows

1. pivot_longer()

Why would I make my data longer?

  • Long format data are easier to clean (we’ll come back to this but we’ll create the cleaned data frame to use for merging practice)
soep_big5 <- soep_long |>
  filter(category == "big5") |>
  mutate(value = mapvalues(value, seq(-8,0), rep(NA, 9))) |>
  drop_na(value) |>
  group_by(Proc_SID, label, year) |>
  summarize(value = mean(value)) |>
  ungroup()

soep_le <- soep_long |>
  filter(category == "le") |>
  mutate(value = mapvalues(value, seq(-8,1), c(rep(NA, 6), 0, NA, NA, 1))) |>
  drop_na(value) |>
  group_by(Proc_SID, label) |>
  summarize(value = sum(value)) |>
  ungroup()

soep_clean <- soep_big5 |>
  rename(trait = label, p_value = value) |>
  inner_join(
    soep_le |>
      rename(le = label, le_value = value)
  )

2. pivot_wider()

  • (Formerly spread()) Makes wide data long, based on a key
  • Core arguments:
    • data: the data, blank if piped
    • names_from: name(s) of key column(s) in new long data frame (string or string vector)
    • names_sep: separator in column headers, if multiple keys
    • names_glue: specify multiple or custom separators of multiple keys
    • values_from: name of values in new long data frame (string)
    • values_fn: function applied to data with duplicate labels

2. pivot_wider()

Why would I pivot wider?

  • Some analyses require wide format data
  • For example, SEM in lavaan in R requires that both indicators and time are wide format.
  • The code below uses the codebook to rename items according to a numbered format that isn’t specific to any trait
big5 <- codebook |> filter(category == "big5")
soep_lavaan <- soep_long |>
  filter(category == "big5") |>
  mutate(item_name = mapvalues(item_name, big5$item_name, big5$lavaan_name, warn_missing = F))
soep_lavaan
# A tibble: 544,830 × 9
   Proc_SID Proc_HHID Demo_dob Demo__sex category label item_name  year value
      <dbl>     <dbl>    <dbl>     <dbl> <chr>    <chr> <chr>     <dbl> <dbl>
 1      901        94     1951         2 big5     C     I1         2005     6
 2      901        94     1951         2 big5     C     I1         2006    -1
 3      901        94     1951         2 big5     C     I1         2013     7
 4      901        94     1951         2 big5     E     I1         2005     4
 5      901        94     1951         2 big5     E     I1         2009     4
 6      901        94     1951         2 big5     E     I1         2013     5
 7      901        94     1951         2 big5     A     I1         2005     4
 8      901        94     1951         2 big5     A     I1         2009     3
 9      901        94     1951         2 big5     A     I1         2013     4
10      901        94     1951         2 big5     O     I1         2005     5
# ℹ 544,820 more rows

2. pivot_wider()

Why would I pivot wider?

  • Change the soep_lavaan data frame to be in wide format using pivot_wider():
    • pull the names from two sources: item_name() and year
soep_lavaan |>
  pivot_wider(
    names_from = c("item_name", "year")
    , values_from = "value"
  )
# A tibble: 113,635 × 16
   Proc_SID Proc_HHID Demo_dob Demo__sex category label I1_2005 I1_2006 I1_2013
      <dbl>     <dbl>    <dbl>     <dbl> <chr>    <chr>   <dbl>   <dbl>   <dbl>
 1      901        94     1951         2 big5     C           6      -1       7
 2      901        94     1951         2 big5     E           4      NA       5
 3      901        94     1951         2 big5     A           4      NA       4
 4      901        94     1951         2 big5     O           5      NA       3
 5      901        94     1951         2 big5     N           6      NA       6
 6     1202       124     1913         2 big5     C           7      NA      NA
 7     1202       124     1913         2 big5     E           6      NA      NA
 8     1202       124     1913         2 big5     A           1      NA      NA
 9     1202       124     1913         2 big5     O           6      NA      NA
10     1202       124     1913         2 big5     N           6      NA      NA
# ℹ 113,625 more rows
# ℹ 7 more variables: I1_2009 <dbl>, I2_2005 <dbl>, I2_2009 <dbl>,
#   I2_2013 <dbl>, I3_2005 <dbl>, I3_2009 <dbl>, I3_2013 <dbl>

dplyr: `_join()’

The _join() Functions

  • Often we may need to pull different data from different sources
  • There are lots of reasons to need to do this
  • We don’t have time to get into all the use cases here, so we’ll talk about them in high level terms
  • We’ll focus on:
    • full_join()
    • inner_join()
    • left_join()
    • right_join()

3. full_join()

  • Most simply, we can put those back together keeping all observations.
  • Pro: sometimes we want to maintain missing data (i.e. some people are randomly missing variables and we don’t want to drop them completely)
  • Con: can leave you with lots of NAs
  • Join the codebook to the data below using full_join()
  • Look at the data. What’s going on here
soep_long |>
  filter(!category == "big5") |> 
  full_join(
    # your code here
  ) |> 
    View()

3. full_join()

soep_long |>
  filter(!category == "big5") |>
  full_join(codebook |> select(category, label, item_name, year, item_text)) 
# A tibble: 1,300,962 × 10
   Proc_SID Proc_HHID Demo_dob Demo__sex category label    item_name  year value
      <dbl>     <dbl>    <dbl>     <dbl> <chr>    <chr>    <chr>     <dbl> <dbl>
 1      901        94     1951         2 le       ChldBrth ChldBrth   2005    -2
 2      901        94     1951         2 le       ChldBrth ChldBrth   2006    -2
 3      901        94     1951         2 le       ChldBrth ChldBrth   2007    -2
 4      901        94     1951         2 le       ChldBrth ChldBrth   2008    -2
 5      901        94     1951         2 le       ChldBrth ChldBrth   2009    -2
 6      901        94     1951         2 le       ChldBrth ChldBrth   2010    -2
 7      901        94     1951         2 le       ChldBrth ChldBrth   2011    -2
 8      901        94     1951         2 le       ChldBrth ChldBrth   2012    -2
 9      901        94     1951         2 le       ChldBrth ChldBrth   2013    -2
10      901        94     1951         2 le       ChldBrth ChldBrth   2014    -2
# ℹ 1,300,952 more rows
# ℹ 1 more variable: item_text <chr>
  • note we have lots of missing data because the Big Five portions of the codebook were joined even though we removed that data

4. inner_join()

  • We can also keep all rows present in both data frames
  • Pro: Won’t add rows with missing values in key variables
  • Con: will drop observations that you want want for counts, correlations, etc.
  • Join the codebook to the data below using inner_join()
  • Look at the data. What’s going on here
soep_long |>
  filter(!category == "big5")
  full_join(
    # your code here
  ) |> 
    View()

4. inner_join()

  • Note that filtering, renaming/selecting, and joining is a common workflow
soep_long |>
  filter(category == "big5") |>
  select(Proc_SID, trait = label, item_name, year, p_value = value) |>
  inner_join(
    soep_long |>
    filter(category == "le") |>
    select(Proc_SID, le = label, year, le_value = value)
  )
# A tibble: 5,118,954 × 7
   Proc_SID trait item_name  year p_value le        le_value
      <dbl> <chr> <chr>     <dbl>   <dbl> <chr>        <dbl>
 1      901 C     thorough   2005       6 ChldBrth        -2
 2      901 C     thorough   2005       6 ChldMvOut       -2
 3      901 C     thorough   2005       6 Divorce         -2
 4      901 C     thorough   2005       6 DadDied         -2
 5      901 C     thorough   2005       6 Married         -2
 6      901 C     thorough   2005       6 MomDied         -2
 7      901 C     thorough   2005       6 MoveIn          -2
 8      901 C     thorough   2005       6 PartDied        -2
 9      901 C     thorough   2005       6 SepPart         -2
10      901 C     thorough   2006      -1 ChldBrth        -2
# ℹ 5,118,944 more rows

5. left_join()

  • Or all rows present in the left (first) data frame, perhaps if it’s a subset of people with complete data
soep_long |>
  filter(category == "big5") |>
  select(Proc_SID, trait = label, item_name, year, p_value = value) |>
  left_join(
    soep_long |>
    filter(category == "le") |>
    select(Proc_SID, le = label, year, le_value = value)
  )
# A tibble: 5,120,918 × 7
   Proc_SID trait item_name  year p_value le        le_value
      <dbl> <chr> <chr>     <dbl>   <dbl> <chr>        <dbl>
 1      901 C     thorough   2005       6 ChldBrth        -2
 2      901 C     thorough   2005       6 ChldMvOut       -2
 3      901 C     thorough   2005       6 Divorce         -2
 4      901 C     thorough   2005       6 DadDied         -2
 5      901 C     thorough   2005       6 Married         -2
 6      901 C     thorough   2005       6 MomDied         -2
 7      901 C     thorough   2005       6 MoveIn          -2
 8      901 C     thorough   2005       6 PartDied        -2
 9      901 C     thorough   2005       6 SepPart         -2
10      901 C     thorough   2006      -1 ChldBrth        -2
# ℹ 5,120,908 more rows

6. right_join()

  • Or all rows present in the right (second) data frame, such as I do when I join a codebook with raw data
soep_long |>
  filter(category == "big5") |>
  select(Proc_SID, trait = label, item_name, year, p_value = value) |>
  right_join(
    soep_long |>
    filter(category == "le") |>
    select(Proc_SID, le = label, year, le_value = value)
  )
# A tibble: 6,002,158 × 7
   Proc_SID trait item_name  year p_value le        le_value
      <dbl> <chr> <chr>     <dbl>   <dbl> <chr>        <dbl>
 1      901 C     thorough   2005       6 ChldBrth        -2
 2      901 C     thorough   2005       6 ChldMvOut       -2
 3      901 C     thorough   2005       6 Divorce         -2
 4      901 C     thorough   2005       6 DadDied         -2
 5      901 C     thorough   2005       6 Married         -2
 6      901 C     thorough   2005       6 MomDied         -2
 7      901 C     thorough   2005       6 MoveIn          -2
 8      901 C     thorough   2005       6 PartDied        -2
 9      901 C     thorough   2005       6 SepPart         -2
10      901 C     thorough   2006      -1 ChldBrth        -2
# ℹ 6,002,148 more rows

Your Turn

In small groups, discuss what’s happening when you use full_join(), left_join(), right_join(), inner_join(), and anti_join() with the code below. Which is correct in this use case?

soep_long |>
  filter(category == "big5") |>
  select(Proc_SID, trait = label, item_name, year, p_value = value) |>
  [x]_join(
    soep_long |>
    filter(category == "le") |>
    select(Proc_SID, le = label, year, le_value = value)
  )

dplyr: split-apply-combine

Bringing it all together: Split-Apply-Combine

  • Much of the power of dplyr functions lay in the split-apply-combine method

  • A given set of of data are:

    • split into smaller chunks
    • then a function or series of functions are applied to each chunk
    • and then the chunks are combined back together

3. group_by()

  • The group_by() function is the “split” of the method
  • It basically implicitly breaks the data set into chunks by whatever bare quoted column(s)/variable(s) are supplied as arguments.

4. mutate()

  • mutate() is one of your “apply” functions
  • When you use mutate(), the resulting data frame will have the same number of rows you started with
  • You are directly mutating the existing data frame, either modifying existing columns or creating new ones

5. summarize() / summarise()

  • summarize() is one of your “apply” functions
  • The resulting data frame will have the same number of rows as your grouping variable
  • You number of groups is 1 for ungrouped data frames

Exercise 1

  • Remember when I said that long format data are easier to clean. Let’s do that now.

Question 1:

  • Let’s start with the Big Five data:
  1. filter() out only Big Five rows
  2. mutate() each observation so that values less than one are changed to NA
  3. Remove any missing values using filter() or drop_na()
  4. Group (split) the data so that you have a “group” for each person x trait x year combination
  5. summarize() the values to get a composite score for each Big Five trait for each person in each year:

Question 1: Solution

Remember when I said that long format data are easier to clean. Let’s do that now.

soep_big5 <- soep_long |>
  filter(category == "big5") |>
  mutate(value = mapvalues(value, seq(-8,0), rep(NA, 9))) |>
  drop_na(value) |>
  group_by(Proc_SID, label, year) |>
  summarize(value = mean(value)) |>
  ungroup()
soep_big5
# A tibble: 161,432 × 4
   Proc_SID label  year value
      <dbl> <chr> <dbl> <dbl>
 1      901 A      2005  4.67
 2      901 A      2009  4.33
 3      901 A      2013  4.67
 4      901 C      2005  5   
 5      901 C      2009  5   
 6      901 C      2013  5   
 7      901 E      2005  5   
 8      901 E      2009  5   
 9      901 E      2013  5   
10      901 N      2005  4   
# ℹ 161,422 more rows

Question 2:

Now let’s take care of the life event data:
1. filter() out only life event rows
2. mutate() each observation so that

  • -2 = 0
  • 1 = 1
  • everything else is NA
  1. Remove any missing values using filter() or drop_na()
  2. Group (split) the data so that you have a “group” for each person x event combination
  3. summarize() the values to get a sum score for each event for each person across all years:

Question 2: Solution

soep_le <- soep_long |>
  filter(category == "le") |>
  mutate(value = mapvalues(value, seq(-8,1), c(rep(NA, 6), 0, NA, NA, 1))) |>
  drop_na(value) |>
  group_by(Proc_SID, label) |>
  summarize(value = sum(value)) |>
  ungroup()
soep_le
# A tibble: 253,363 × 3
   Proc_SID label     value
      <dbl> <chr>     <dbl>
 1      901 ChldBrth      0
 2      901 ChldMvOut     0
 3      901 DadDied       0
 4      901 Divorce       0
 5      901 Married       0
 6      901 MomDied       2
 7      901 MoveIn        0
 8      901 NewPart       0
 9      901 PartDied      0
10      901 SepPart       0
# ℹ 253,353 more rows

Question 3:

Just for practice, now make your Big Five data frame wide, leaving the time variable (year) long

Question 3: Solution

soep_big5 |>
  pivot_wider(
    names_from = "label"
    , values_from = "value"
  )
# A tibble: 40,504 × 7
   Proc_SID  year     A     C     E     N     O
      <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1      901  2005  4.67  5     5     4     4   
 2      901  2009  4.33  5     5     4.67  4   
 3      901  2013  4.67  5     5     4.33  3.33
 4     1202  2005  4     4     6.67  5     5.67
 5     2301  2005  5.67  5.67  5     4.33  4.33
 6     2301  2009  5.67  4.5   4     5.33  5   
 7     2301  2013  4.67  5.33  5.33  3.67  5   
 8     2301  2006 NA     6    NA    NA    NA   
 9     2302  2005  4.67  4.67  4.67  3.67  5   
10     2302  2009  4     5.5   5.33  3     4.33
# ℹ 40,494 more rows

Question 4:

  • Now, let’s join the data frames back together.
  • Which join function do you think is most appropriate?
  • Hint: You will need to rename the label and value columns to reflect the category of the data

Question 4: Solution

soep_clean <- soep_big5 |>
  rename(trait = label, p_value = value) |>
  inner_join(
    soep_le |>
      rename(le = label, le_value = value)
  )
soep_clean
# A tibble: 1,577,725 × 6
   Proc_SID trait  year p_value le        le_value
      <dbl> <chr> <dbl>   <dbl> <chr>        <dbl>
 1      901 A      2005    4.67 ChldBrth         0
 2      901 A      2005    4.67 ChldMvOut        0
 3      901 A      2005    4.67 DadDied          0
 4      901 A      2005    4.67 Divorce          0
 5      901 A      2005    4.67 Married          0
 6      901 A      2005    4.67 MomDied          2
 7      901 A      2005    4.67 MoveIn           0
 8      901 A      2005    4.67 NewPart          0
 9      901 A      2005    4.67 PartDied         0
10      901 A      2005    4.67 SepPart          0
# ℹ 1,577,715 more rows

Functions

Functions

How to approach writing functions? (broad recipe)

  1. Experiment with performing the task outside of a function
    • Experiment with performing task with different sets of inputs
    • Often, you must revise this code, when an approach that worked outside a function does not work within a function
  2. Write the function
  3. Test the function
    • Try to “break” it
  4. Continual improvement. As you use the function, make continual improvements going back-and-forth between steps 1-3

Basics of writing functions

Three components of a function:

  1. Function name
    • Define a function using function() and give it a name using the assignment operator <-
  2. Function arguments (sometimes called “inputs”)
    • Inputs that the function takes; they go inside the parentheses of function()
      • Can be vectors, data frames, logical statements, strings, etc.
    • In the above hypothetical code, the function took three inputs arg1, arg2, arg3, but we could have written:
      • function(x, y, z) or function(Larry, Curly, Moe)
    • In the “function call,” you specify values to assign to these function arguments
  3. Function body
    • What the function does to the inputs
    • Function body goes inside the pair of curly brackets ({}) that follows function()
    • Above hypothetical function doesn’t do anything, but your function can return a value (covered in later section)

Exercise 2

Some common tasks when working with survey data:

  • Identify number of observations with NA values for a specific variable
  • Identify number of observations with negative values for a specific variable
  • Replace negative values with NA for a specific variable

Exercise 2: num_negative() function

Task: Write function called num_negative()

  • Write a function that counts the number of observations with negative values for a specific variable
  • Apply this function to variables from dataframe df (created below)
  • Adapted from Ben Skinner’s Programming 1 R Workshop HERE
# Sample dataframe `df` that contains some negative values
df
# A tibble: 100 × 4
      id   age sibage parage
   <int> <dbl>  <dbl>  <dbl>
 1     1    17      8     49
 2     2    15    -97     46
 3     3   -97    -97     53
 4     4    13     12     -4
 5     5   -97     10     47
 6     6    12     10     52
 7     7   -99      5     51
 8     8   -97     10     55
 9     9    16      6     51
10    10    16    -99     -8
# ℹ 90 more rows

Steps:

Recommended steps:

  • Perform task outside of function
    • HINT: sum(data_frame_name$var_name<0)
  • Write function
  • Apply/test function on variables

Step 1: Perform task outside of function

names(df) # identify variable names
[1] "id"     "age"    "sibage" "parage"
df$age # print observations for a variable
  [1]  17  15 -97  13 -97  12 -99 -97  16  16 -98  20 -99  20  11  20  12  17
 [19]  19  17 -97 -99  12  13  11  15  20  14 -99  11  20 -98  11 -98  12  16
 [37]  12  18  12  19  12 -97  20  17  11  19  19  12 -98  11  15  18  15 -98
 [55]  15  19 -97  13 -98  16  13  12  16  19 -99  19 -98  13 -97  20  15  19
 [73]  15  12  18 -99  18 -98 -98 -98 -97  12  14  19 -97  11  20  18  14 -99
 [91]  15  20 -97  14  14  19  18  17  20  15
#BaseR
sum(df$age<0) # count number of obs w/ negative values for variable "age"
[1] 27

Step 2: Write function

num_missing <- function(x){
  sum(x<0)
}

##Step 3: Apply function

num_missing(df$age)
[1] 27
num_missing(df$sibage)
[1] 22

Exercise 3: num_missing() function

In survey data, negative values often refer to reason for missing values:

  • E.g., -8 refers to “didn’t take survey”
  • E.g., -7 refers to “took survey, but didn’t answer this question”

Exercise 3: num_missing() function

Task: Write function called num_negative()

  • Write a function that counts number of missing observations for a variable and allows you to specify which values are associated with missing for that variable. This function will take two arguments:
    • x: The variable (e.g., df$sibage)
    • miss_vals: Vector of values you want to associate with “missing” variable
      • Values to associate with missing for df$age: -97,-98,-99
      • Values to associate with missing for df$sibage: -97,-98,-99
      • Values to associate with missing for df$parage: -4,-7,-8

Steps

Recommended steps:

  • Perform task outside of function
    • HINT: sum(data_frame_name$var_name %in% c(-4,-5))
  • Write function
  • Apply/test function on variables

Step 1: Perform task outside of function

sum(df$age %in% c(-97,-98,-99))
[1] 27

##Step 2: Write function

num_missing <- function(x, miss_vals){

  sum(x %in% miss_vals)
}

Step 3: Apply function

num_missing(df$age,c(-97,-98,-99))
[1] 27
num_missing(df$sibage,c(-97,-98,-99))
[1] 22
num_missing(df$parage,c(-4,-7,-8))
[1] 17

purrr

purrr::map()

  • map() functions are the tidyverse alternative to for loops and chaotic lists with deep nesting structures
  • map() functions, unlike _apply() functions can take any number of inputs, which mimics nested for loops
  • map() functions can return any output type, including heterogeneous outputs (at least if you return it as a list)

purrr::map() inputs

  • You control how many inputs using the following:
    • map(): one input, arguments are map(.x, .f)
    • map2(): two inputs, arguments are map2(.x, y., .f)
    • pmap(): any number of inputs, arguments are pmap(.l, .f)
      • Note the .l becuase this means we have to wrap inputs in a list()

purrr::map() ouputs

  • You can also control the output of purrr::map():
    • map(): outputs a list
    • map_chr(): outputs a character vector
    • map_dbl(): outputs a numeric vector
    • map_lgl(): outputs a logical vector
    • map_int(): outputs a integer vector
    • map_vec(): outputs essentially any type of vector
  • Note that if one input combination fails, all will fail and nothing will be outputted

purrr error handling

  • Having everything fail because one thing went wrong is really frustrating
  • There are a number of functions in purrr to help with that:
    • possibly(.f, otherwise): returns whatever you ask it return with otherwise when a .f call fails
    • safely(.f): returns a list with the output, if successful, and errors, if unsuccessful
    • Others: see documentation.

purrr list columns

  • One of the easiest ways to work with purrr is using list columns in nested data frames
  • You can create a nested data frame using tidyr::nest() or tibble() (where one column is a list itself)
soep_clean |>
  group_by(trait, year, le) |>
  nest() |>
  ungroup()
# A tibble: 160 × 4
   trait  year le        data                 
   <chr> <dbl> <chr>     <list>               
 1 A      2005 ChldBrth  <tibble [10,419 × 3]>
 2 A      2005 ChldMvOut <tibble [10,419 × 3]>
 3 A      2005 DadDied   <tibble [10,419 × 3]>
 4 A      2005 Divorce   <tibble [10,419 × 3]>
 5 A      2005 Married   <tibble [10,419 × 3]>
 6 A      2005 MomDied   <tibble [10,419 × 3]>
 7 A      2005 MoveIn    <tibble [10,419 × 3]>
 8 A      2005 NewPart   <tibble [6,364 × 3]> 
 9 A      2005 PartDied  <tibble [10,419 × 3]>
10 A      2005 SepPart   <tibble [10,419 × 3]>
# ℹ 150 more rows
  • You can then call map() within a mutate call to modify the list column or create new columns in your data frame
tibble(
  x = c(1,2,3)
  , y = list(letters[1:5], letters[6:10], letters[11:15])
)
# A tibble: 3 × 2
      x y        
  <dbl> <list>   
1     1 <chr [5]>
2     2 <chr [5]>
3     3 <chr [5]>

Exercise 4

Question 1:

  • Create a data frame called soep_nested that creates a list column of the data split by trait and life event.
soep_nested <- soep_clean |>
  group_by(trait, le) |>
  nest() |>
  ungroup()

Question 2:

  • Using mutate(), create a new list column called model that runs the following function
lmer_fun <- function(d){
  d <- d |> 
    mutate(wave = year - 2005) |>
    group_by(Proc_SID) |>
    filter(n() > 1)
  m <- lmer(p_value ~ wave + le_value + le_value:wave + (1 + wave | Proc_SID), data = d)
  return(m)
}

Question 2: Solution

  • Using mutate(), create a new list column called model that runs the following function
lmer_fun <- function(d){
  d <- d |> 
    mutate(wave = year - 2005) |>
    group_by(Proc_SID) |>
    filter(n() > 1)
  m <- lmer(p_value ~ wave + le_value + le_value:wave + (1 + wave | Proc_SID), data = d)
  return(m)
}

soep_nested <- soep_nested |>
  mutate(model = map(data, lmer_fun))
soep_nested
# A tibble: 50 × 4
   trait le        data                  model    
   <chr> <chr>     <list>                <list>   
 1 A     ChldBrth  <tibble [30,248 × 4]> <lmerMod>
 2 A     ChldMvOut <tibble [30,248 × 4]> <lmerMod>
 3 A     DadDied   <tibble [30,248 × 4]> <lmerMod>
 4 A     Divorce   <tibble [30,248 × 4]> <lmerMod>
 5 A     Married   <tibble [30,248 × 4]> <lmerMod>
 6 A     MomDied   <tibble [30,248 × 4]> <lmerMod>
 7 A     MoveIn    <tibble [30,248 × 4]> <lmerMod>
 8 A     NewPart   <tibble [23,467 × 4]> <lmerMod>
 9 A     PartDied  <tibble [30,248 × 4]> <lmerMod>
10 A     SepPart   <tibble [30,248 × 4]> <lmerMod>
# ℹ 40 more rows

Question 3:

  • Use the following function to extract the number of people we estimated slopes for in this model. Output the result as an integer to a new column called npeople
nslopes_fun <- function(m) summary(m)$ngrps
soep_nested <- soep_nested |>
  mutate(npeople = map_int(model, nslopes_fun))
soep_nested
# A tibble: 50 × 5
   trait le        data                  model     npeople
   <chr> <chr>     <list>                <list>      <int>
 1 A     ChldBrth  <tibble [30,248 × 4]> <lmerMod>    8563
 2 A     ChldMvOut <tibble [30,248 × 4]> <lmerMod>    8563
 3 A     DadDied   <tibble [30,248 × 4]> <lmerMod>    8563
 4 A     Divorce   <tibble [30,248 × 4]> <lmerMod>    8563
 5 A     Married   <tibble [30,248 × 4]> <lmerMod>    8563
 6 A     MomDied   <tibble [30,248 × 4]> <lmerMod>    8563
 7 A     MoveIn    <tibble [30,248 × 4]> <lmerMod>    8563
 8 A     NewPart   <tibble [23,467 × 4]> <lmerMod>    7359
 9 A     PartDied  <tibble [30,248 × 4]> <lmerMod>    8563
10 A     SepPart   <tibble [30,248 × 4]> <lmerMod>    8563
# ℹ 40 more rows

Question 4:

  • Use the tidy() function from the broom.mixed package to extract the coefficients from the model and their confidence intervals. Save it to the column “tidy”
  • Hints:
    • Use the argument conf.int = T to get the confidence intervals
    • Additional arguments to the .f function called in map() can be just included as addition arguments (e.g., map(.x, .f, conf.int = T))

Question 4: Solution

soep_nested <- soep_nested |>
  mutate(tidy = map(model, broom.mixed::tidy, conf.int = T))

Question 5:

  • Let’s practice making a super simple table. Do the following:
  1. remove the data and model columns from the data frame
  2. unnest() the tidy column
  3. Keep only fixed effects (effect == "fixed")
  4. We only care about the interaction, so only keep the interaction term
  5. round the estimate, conf.low, and conf.high columns to 2 decimal places
  6. Keep the trait, le, estimate, conf.low, and conf.high columns only
  7. pivot_wider() by trait for estimate, conf.low, and conf.high

Question 5: Solution

soep_tab <- soep_nested |>
  select(-data, -model) |>
  unnest(tidy) |>
  filter(effect == "fixed" & grepl(":", term)) |>
  mutate(across(c(estimate, conf.low, conf.high), \(x) round(x, 2))) |>
  select(trait, le, estimate, conf.low, conf.high) |>
  pivot_wider(
    names_from = "trait"
    , names_glue = "{trait}_{.value}"
    , values_from = c(estimate, conf.low, conf.high)
  )
soep_tab
# A tibble: 10 × 16
   le        A_estimate C_estimate E_estimate N_estimate O_estimate A_conf.low
   <chr>          <dbl>      <dbl>      <dbl>      <dbl>      <dbl>      <dbl>
 1 ChldBrth        0          0.01       0             0       0          0   
 2 ChldMvOut       0          0.01       0             0       0         -0.01
 3 DadDied         0          0.02       0             0      -0.01      -0.01
 4 Divorce         0.01       0.01       0.01          0       0.01       0   
 5 Married         0          0.02       0             0       0          0   
 6 MomDied         0          0.01       0             0       0.01      -0.01
 7 MoveIn          0          0.01       0             0       0          0   
 8 NewPart         0.01       0.03       0             0      -0.01       0   
 9 PartDied        0          0.01       0.01          0       0.01      -0.01
10 SepPart         0          0.02       0.01          0       0          0   
# ℹ 9 more variables: C_conf.low <dbl>, E_conf.low <dbl>, N_conf.low <dbl>,
#   O_conf.low <dbl>, A_conf.high <dbl>, C_conf.high <dbl>, E_conf.high <dbl>,
#   N_conf.high <dbl>, O_conf.high <dbl>

Question 6:

Use the function below to get model predictions

pred_fun <- function(m){
  d <- m@frame |>
      select(-p_value) |>
      distinct()
  bind_cols(d, pred = predict(m, newdata = d))
}
soep_nested <- soep_nested |>
  mutate(pred = map(model, pred_fun))
soep_nested
# A tibble: 50 × 7
   trait le        data                  model     npeople tidy     pred  
   <chr> <chr>     <list>                <list>      <int> <list>   <list>
 1 A     ChldBrth  <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 2 A     ChldMvOut <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 3 A     DadDied   <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 4 A     Divorce   <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 5 A     Married   <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 6 A     MomDied   <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 7 A     MoveIn    <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
 8 A     NewPart   <tibble [23,467 × 4]> <lmerMod>    7359 <tibble> <df>  
 9 A     PartDied  <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
10 A     SepPart   <tibble [30,248 × 4]> <lmerMod>    8563 <tibble> <df>  
# ℹ 40 more rows

Question 7:

  • Let’s practice making a super simple table. Do the following:
  1. remove the data, model, and tidy columns from the data frame
  2. unnest() the tidy column
  3. group_by() life event and nest() + ungroup()
  4. save this as soep_pred

Question 7: Solutions

soep_pred <- soep_nested |>
  select(-data, -model, -tidy) |>
  unnest(pred) |>
  group_by(trait) |>
  nest() |>
  ungroup()
soep_pred
# A tibble: 5 × 2
  trait data                  
  <chr> <list>                
1 A     <tibble [218,522 × 6]>
2 C     <tibble [334,426 × 6]>
3 E     <tibble [218,454 × 6]>
4 N     <tibble [218,464 × 6]>
5 O     <tibble [218,354 × 6]>

Question 8:

  • Use the following function to create a new column p that contains spaghetti plots
  • Note that the function takes two inputs!
spag_plot_fun <- function(d, trait){
  set.seed(6)
  d |>
    group_by(le) |>
    nest() |>
    mutate(data = map(data, ~filter(., Proc_SID %in% sample(unique(.$Proc_SID), 100)))) |>
    unnest(data) |>
    ungroup() |>
    mutate(le_value = ifelse(le_value > 1, 1, le_value)) |>
    ggplot(aes(x = wave, y = pred)) + 
      geom_line(aes(group = Proc_SID, color = factor(le_value)), alpha = .3) + 
      geom_smooth(method = "lm", se = F, color = "darkblue") + 
      scale_color_manual(values = c("grey", "blue"), labels = c("No Event", "Event")) + 
      labs(x = "Wave", y = "Predicted Trait Levels", color = "Life Event", title = trait) + 
      facet_wrap(~le) + 
      theme_classic() + 
      theme(legend.position = c(.7, .1))
}

Question 8: Solution

soep_pred <- soep_pred |>
  mutate(p = map2(data, trait, spag_plot_fun))

soep_pred$p[[1]]

Wrap-Up

Wrap-Up

  • Today’s goal was to review the coding concepts we’ve used so far and ask you to apply them using a series of guided examples
  • The biggest takeaway I wanted you to have is chaining, or how you can use tidyverse functions in chains to accomplish a bunch of goals simultaneously
  • We cleaned, composited, and ran 50 models across thousands of people, including predictions and tables in less than 100 lines of code. Just doing the models, tidy(), and predict() parts of that alone would have been 150 lines of code and introduced huge opportunities for errors!