the dplyr package

tidyverse package that has revolutionized working with data in R.

It provides a consistent and simple interface to do common data manipulation tasks

the dplyr package

dplyr is very consistent

it assumes that you are starting with a dataframe, doing something to that dataframe, and finishing with a different dataframe.

Many of the base R functions operate on atomic vectors, which makes it more complicated to apply them to dataframes.)

dplyr introduces a series of simple 'verbs' that describe many common data manipulation tasks.

Challenge

The basic dplyr verbs

There are a few basic functions in dplyr

The first argument to these functions is always the dataframe that you want to manipulate.

Within these function calls, you can refer to the names of columns in the dataframe without quotation marks and without the usual $ syntax.

library(dplyr)

filter()

This function selects a subset of rows meeting some criterion. Note that the result is a dataframe.

filter(loans, School=="GEORGE WASHINGTON UNIVERSITY")
##                         School State      School_Type SubsidizedDL
## 1 GEORGE WASHINGTON UNIVERSITY    DC PrivateNonprofit      7463145
##   UNSubsidizedDL
## 1        5913027

arrange()

This function is like the "sort" function in MS Excel. You simply provide a list of column names to sort by:

arrange(loans, State, SubsidizedDL)
##                                                                   School
## 1                                 NATIONAL CONSERVATORY OF DRAMATIC ARTS
## 2                                             TECHNICAL LEARNING CENTERS
## 3                                               BENNETT CAREER INSTITUTE
## 4                                                        RADIANS COLLEGE
## 5                                     CORCORAN COLLEGE OF ART AND DESIGN
## 6                                             CAREER TECHNICAL INSTITUTE
## 7                                                   GALLAUDET UNIVERSITY
## 8                                                        TRINITY COLLEGE
## 9                                         CATHOLIC UNIVERSITY OF AMERICA
## 10                                                 GEORGETOWN UNIVERSITY
## 11                                UNIVERSITY OF THE DISTRICT OF COLUMBIA
## 12                                                   AMERICAN UNIVERSITY
## 13                                          GEORGE WASHINGTON UNIVERSITY
## 14                                                     HOWARD UNIVERSITY
## 15                                                    STRAYER UNIVERSITY
## 16                                           WESLEY THEOLOGICAL SEMINARY
## 17                                            DOMINICAN HOUSE OF STUDIES
## 18                                                       POTOMAC COLLEGE
## 19                                       INSTITUTE OF WORLD POLITICS THE
## 20  PONTIFICAL JOHN PAUL II INSTITUTE FOR STUDIES ON MARRIAGE AND FAMILY
## 21                                   HOLISTIC MASSAGE TRAINING INSTITUTE
## 22                                                 HARMONS BEAUTY SCHOOL
## 23                                               MARYLAND BEAUTY ACADEMY
## 24                                            FAITH THEOLOGICAL SEMINARY
## 25                                              AARONS ACADEMY OF BEAUTY
## 26                  ROBERT PAUL ACADEMY OF COSMETOLOGY ARTS AND SCIENCES
## 27           OMEGA STUDIOS SCHOOL OF APPLIED RECORDING ARTS AND SCIENCES
## 28                                       FREDERICK SCHOOL OF COSMETOLOGY
## 29                                   AESTHETICS INSTITUTE OF COSMETOLOGY
## 30                                          COLORLAB ACADEMY OF HAIR THE
## 31                                       BALTIMORE STUDIO OF HAIR DESIGN
## 32                                                       HAIR ACADEMY II
## 33                                          ASPEN BEAUTY ACADEMY  LAUREL
## 34                                      MARYLAND BEAUTY ACADEMY OF ESSEX
## 35                                          BLADES SCHOOL OF HAIR DESIGN
## 36                                              MONTGOMERY BEAUTY SCHOOL
## 37                                               DELMARVA BEAUTY ACADEMY
## 38                                          INSTITUTE OF HEALTH SCIENCES
## 39                                                  LACADEMIE DE CUISINE
## 40                                                   AWARD BEAUTY SCHOOL
## 41                                              HAIR EXPRESSIONS ACADEMY
## 42                            TEMPLE THE: A PAUL MITCHELL PARTNER SCHOOL
## 43                                                NATIONAL LABOR COLLEGE
## 44                                             CARROLL COMMUNITY COLLEGE
## 45                                           BALTIMORE SCHOOL OF MASSAGE
## 46                                           TESST COLLEGE OF TECHNOLOGY
## 47                                           TESST COLLEGE OF TECHNOLOGY
## 48                                                          HAIR ACADEMY
## 49                                           TESST COLLEGE OF TECHNOLOGY
## 50                                             SOJOURNERDOUGLASS COLLEGE
## 51                                                       CAPITOL COLLEGE
## 52                                               AMERICAN BEAUTY ACADEMY
## 53                                             HARFORD COMMUNITY COLLEGE
## 54                                          NORTH AMERICAN TRADE SCHOOLS
## 55                                                       GARRETT COLLEGE
## 56                                         LINCOLN COLLEGE OF TECHNOLOGY
## 57                                                      ST JOHNS COLLEGE
## 58                                              WORWIC COMMUNITY COLLEGE
## 59                                                         CECIL COLLEGE
## 60                                           FREDERICK COMMUNITY COLLEGE
## 61                                      UNIVERSITY OF MARYLAND BALTIMORE
## 62                                     NOTRE DAME OF MARYLAND UNIVERSITY
## 63                                          COLLEGE OF SOUTHERN MARYLAND
## 64                                                       ALLSTATE CAREER
## 65                                          ST MARYS COLLEGE OF MARYLAND
## 66                                       WASHINGTON ADVENTIST UNIVERSITY
## 67                                                       GOUCHER COLLEGE
## 68                                                    WASHINGTON COLLEGE
## 69                                              HOWARD COMMUNITY COLLEGE
## 70                                          MOUNT SAINT MARYS UNIVERSITY
## 71                                                          HOOD COLLEGE
## 72                                          ALLEGANY COLLEGE OF MARYLAND
## 73                                                      MCDANIEL COLLEGE
## 74                                     MARYLAND INSTITUTE COLLEGE OF ART
## 75                                          HAGERSTOWN COMMUNITY COLLEGE
## 76                                                      FORTIS INSTITUTE
## 77                                        ANNE ARUNDEL COMMUNITY COLLEGE
## 78                                               UNIVERSITY OF BALTIMORE
## 79                                              JOHNS HOPKINS UNIVERSITY
## 80                                               COPPIN STATE UNIVERSITY
## 81                                            LOYOLA UNIVERSITY MARYLAND
## 82                                            FROSTBURG STATE UNIVERSITY
## 83                                      PRINCE GEORGES COMMUNITY COLLEGE
## 84                                                  STEVENSON UNIVERSITY
## 85                                 UNIVERSITY OF MARYLAND  EASTERN SHORE
## 86                                                BOWIE STATE UNIVERSITY
## 87                                                    MONTGOMERY COLLEGE
## 88                                 COMMUNITY COLLEGE OF BALTIMORE COUNTY
## 89                                                  SALISBURY UNIVERSITY
## 90                              UNIVERSITY OF MARYLAND  BALTIMORE COUNTY
## 91                                               MORGAN STATE UNIVERSITY
## 92                                                     TOWSON UNIVERSITY
## 93                                   UNIVERSITY OF MARYLAND COLLEGE PARK
## 94                             UNIVERSITY OF MARYLAND UNIVERSITY COLLEGE
## 95                                           INTERNATIONAL BEAUTY SCHOOL
## 96                             MARYLAND UNIVERSITY OF INTEGRATIVE HEALTH
## 97                                                        BETHEL COLLEGE
## 98                                   CAYCE/REILLY SCHOOL OF MASSOTHERAPY
## 99                                            VIRGINIA INTERMONT COLLEGE
## 100                                       STAUNTON SCHOOL OF COSMETOLOGY
## 101        DANVILLE REGIONAL MEDICAL CENTER SCHOOL OF HEALTH PROFESSIONS
## 102                                                  AVI CAREER TRAINING
## 103                                       DOMINION SCHOOL OF HAIR DESIGN
## 104                                    CHRYSM INSTITUTE OF ESTHETICS THE
## 105                                                     COLUMBIA COLLEGE
## 106                      NORTHERN VIRGINIA SCHOOL OF THERAPEUTIC MASSAGE
## 107                                  COSMOPOLITAN BEAUTY AND TECH SCHOOL
## 108                           TOMORROWS IMAGE BARBER ACADEMY OF VIRGINIA
## 109       HENRICO COUNTYSAINT MARYS HOSPITAL SCHOOL OF PRACTICAL NURSING
## 110                                     BAR PALMA BEAUTY CAREERS ACADEMY
## 111                                 CULPEPER COSMETOLOGY TRAINING CENTER
## 112                          UNIVERSITY OF MANAGEMENT AND TECHNOLOGY THE
## 113              BON SECOURS ST MARYS HOSPITAL SCHOOL OF MEDICAL IMAGING
## 114                                           SPRINGFIELD BEAUTY ACADEMY
## 115                                           VIRGINIA SCHOOL OF MASSAGE
## 116                                               SUFFOLK BEAUTY ACADEMY
## 117                                                 SANFORDBROWN COLLEGE
## 118                            GRAHAM WEBB INTERNATIONAL ACADEMY OF HAIR
## 119                           SYLVAIN MELLOUL INTERNATIONAL HAIR ACADEMY
## 120                      STANDARD HEALTHCARE SERVICES COLLEGE OF NURSING
## 121                                    AVIATION INSTITUTE OF MAINTENANCE
## 122                                            CAREER TRAINING SOLUTIONS
## 123                                          WARDS CORNER BEAUTY ACADEMY
## 124               SOUTHSIDE REGIONAL MEDICAL CENTER PROFESSIONAL SCHOOLS
## 125                                                                 RSHT
## 126                                                      SKYLINE COLLEGE
## 127                                   CENTRAL VIRGINIA COMMUNITY COLLEGE
## 128                              RUDY AND KELLY ACADEMY OF HAIR ANDNAILS
## 129                                    AVIATION INSTITUTE OF MAINTENANCE
## 130                                            CENTRA COLLEGE OF NURSING
## 131                                                GLOBAL HEALTH COLLEGE
## 132                                   RIVERSIDE SCHOOL OF HEALTH CAREERS
## 133                                         WYTHEVILLE COMMUNITY COLLEGE
## 134                                        ADVANCED TECHNOLOGY INSTITUTE
## 135                                 DABNEY S LANCASTER COMMUNITY COLLEGE
## 136                                                       TIDEWATER TECH
## 137                                                      CENTURA COLLEGE
## 138                                        WASHINGTON AND LEE UNIVERSITY
## 139                                           DANVILLE COMMUNITY COLLEGE
## 140             RICHARD BLAND COLLEGE OF THE COLLEGE OF WILLIAM AND MARY
## 141                                   SENTARA COLLEGE OF HEALTH SCIENCES
## 142                              BON SECOURS MEMORIAL COLLEGE OF NURSING
## 143                                                  SWEET BRIAR COLLEGE
## 144                                     VIRGINIA UNIVERSITY OF LYNCHBURG
## 145                                  PIEDMONT VIRGINIA COMMUNITY COLLEGE
## 146                                                   HOLLINS UNIVERSITY
## 147                                                      MEDTECH COLLEGE
## 148                                         SOUTHERN VIRGINIA UNIVERSITY
## 149                                                     RANDOLPH COLLEGE
## 150                                           GERMANNA COMMUNITY COLLEGE
## 151                                       LORD FAIRFAX COMMUNITY COLLEGE
## 152                                                      EVEREST COLLEGE
## 153                                          NEW RIVER COMMUNITY COLLEGE
## 154                                               HAMPDEN SYDNEY COLLEGE
## 155                                                       FORTIS COLLEGE
## 156                                                    BLUEFIELD COLLEGE
## 157                                         BLUE RIDGE COMMUNITY COLLEGE
## 158                                 JEFFERSON COLLEGE OF HEALTH SCIENCES
## 159                                              EMORY AND HENRY COLLEGE
## 160                                          VIRGINIA MILITARY INSTITUTE
## 161                                         EASTERN MENNONITE UNIVERSITY
## 162                          UNIVERSITY OF VIRGINIAS COLLEGE AT WISE THE
## 163                                                      CENTURA COLLEGE
## 164                                                RANDOLPHMACON COLLEGE
## 165                                         JOHN TYLER COMMUNITY COLLEGE
## 166                                                   AVERETT UNIVERSITY
## 167                                            VIRGINIA WESLEYAN COLLEGE
## 168                                               UNIVERSITY OF RICHMOND
## 169                                                 STRATFORD UNIVERSITY
## 170                                                 MARY BALDWIN COLLEGE
## 171                                                  BRIDGEWATER COLLEGE
## 172                                   VIRGINIA WESTERN COMMUNITY COLLEGE
## 173                                                       FERRUM COLLEGE
## 174                                                SHENANDOAH UNIVERSITY
## 175                                            VIRGINIA UNION UNIVERSITY
## 176                                          AMERICANNATIONAL UNIVERSITY
## 177                                                      ROANOKE COLLEGE
## 178                                                 MARYMOUNT UNIVERSITY
## 179                                                    REGENT UNIVERSITY
## 180                                                    LYNCHBURG COLLEGE
## 181                                        UNIVERSITY OF MARY WASHINGTON
## 182                                          COLLEGE OF WILLIAM AND MARY
## 183                                        MILLERMOTTE TECHNICAL COLLEGE
## 184                                       CHRISTOPHER NEWPORT UNIVERSITY
## 185                                                  LONGWOOD UNIVERSITY
## 186                                      THOMAS NELSON COMMUNITY COLLEGE
## 187                                                   HAMPTON UNIVERSITY
## 188                                J SARGEANT REYNOLDS COMMUNITY COLLEGE
## 189                                               UNIVERSITY OF VIRGINIA
## 190                                                      ECPI UNIVERSITY
## 191                                            VIRGINIA STATE UNIVERSITY
## 192                                             NORFOLK STATE UNIVERSITY
## 193                                                   RADFORD UNIVERSITY
## 194                                          TIDEWATER COMMUNITY COLLEGE
## 195                                             JAMES MADISON UNIVERSITY
## 196                                  NORTHERN VIRGINIA COMMUNITY COLLEGE
## 197                  VIRGINIA POLYTECHNIC INSTITUTE AND STATE UNIVERSITY
## 198                                              GEORGE MASON UNIVERSITY
## 199                                              OLD DOMINION UNIVERSITY
## 200                                     VIRGINIA COMMONWEALTH UNIVERSITY
## 201                                                   LIBERTY UNIVERSITY
## 202                                          UNION PRESBYTERIAN SEMINARY
## 203                                      EASTERN VIRGINIA MEDICAL SCHOOL
## 204                             BAPTIST THEOLOGICAL SEMINARY AT RICHMOND
## 205                                            APPALACHIAN SCHOOL OF LAW
## 206                  EDWARD VIA VIRGINIA COLLEGE OF OSTEOPATHIC MEDICINE
## 207                             INSTITUTE FOR THE PSYCHOLOGICAL SCIENCES
## 208                              INSTITUTE OF ADVANCED MEDICAL ESTHETICS
## 209                                      APPALACHIAN COLLEGE OF PHARMACY
## 210                            VIRGINIA TECH CARILION SCHOOL OF MEDICINE
##     State      School_Type SubsidizedDL UNSubsidizedDL
## 1      DC PrivateNonprofit        40812          21963
## 2      DC      Proprietary        84000         128000
## 3      DC      Proprietary       107642          88632
## 4      DC      Proprietary       340038         514081
## 5      DC PrivateNonprofit       356355         360715
## 6      DC      Proprietary       416911         685909
## 7      DC PrivateNonprofit       679602         561785
## 8      DC PrivateNonprofit      2522961        2850888
## 9      DC PrivateNonprofit      3619502        3520966
## 10     DC PrivateNonprofit      3824260        1318290
## 11     DC           Public      3850272        4248284
## 12     DC PrivateNonprofit      6213538        4517728
## 13     DC PrivateNonprofit      7463145        5913027
## 14     DC PrivateNonprofit      9414766        9021712
## 15     DC      Proprietary     22490396       34840102
## 16     DC PrivateNonprofit           NA          22250
## 17     DC PrivateNonprofit           NA             NA
## 18     DC      Proprietary           NA             NA
## 19     DC PrivateNonprofit           NA             NA
## 20     DC PrivateNonprofit           NA             NA
## 21     MD      Proprietary         8165          15832
## 22     MD      Proprietary         9750          11000
## 23     MD      Proprietary        12266           5600
## 24     MD PrivateNonprofit        12832          19666
## 25     MD      Proprietary        13973          19876
## 26     MD      Proprietary        20573          24171
## 27     MD      Proprietary        21875          33375
## 28     MD      Proprietary        23861          24999
## 29     MD      Proprietary        24249          33499
## 30     MD      Proprietary        31723          49455
## 31     MD      Proprietary        33224          37891
## 32     MD      Proprietary        46285          62073
## 33     MD      Proprietary        48698          52385
## 34     MD      Proprietary        50260          52483
## 35     MD      Proprietary        52234          77251
## 36     MD      Proprietary        59017          57179
## 37     MD      Proprietary        61250          68022
## 38     MD      Proprietary        63574          97427
## 39     MD      Proprietary       107306         157442
## 40     MD      Proprietary       116268         115914
## 41     MD      Proprietary       126302         153268
## 42     MD      Proprietary       153776         234372
## 43     MD PrivateNonprofit       196352         320716
## 44     MD           Public       207666         416588
## 45     MD      Proprietary       231284         389641
## 46     MD      Proprietary       268744         371619
## 47     MD      Proprietary       270825         414703
## 48     MD      Proprietary       274339         283712
## 49     MD      Proprietary       305942         439905
## 50     MD PrivateNonprofit       361594         864259
## 51     MD PrivateNonprofit       397211         405964
## 52     MD      Proprietary       400537         660202
## 53     MD           Public       411657         499914
## 54     MD      Proprietary       420951         614068
## 55     MD           Public       424451         425844
## 56     MD      Proprietary       587391         795882
## 57     MD PrivateNonprofit       589510         355243
## 58     MD           Public       595801         231267
## 59     MD           Public       730994        1233936
## 60     MD           Public       785716         946044
## 61     MD           Public       790624         831014
## 62     MD PrivateNonprofit       921184        1231367
## 63     MD           Public       950019        1387749
## 64     MD      Proprietary      1072935        1607727
## 65     MD           Public      1199357        1274362
## 66     MD PrivateNonprofit      1362268        1768461
## 67     MD PrivateNonprofit      1426570        1079658
## 68     MD PrivateNonprofit      1499542        1323401
## 69     MD           Public      1562603        1825338
## 70     MD PrivateNonprofit      1796922        1705136
## 71     MD PrivateNonprofit      1954513        1812060
## 72     MD           Public      1985362        2200457
## 73     MD PrivateNonprofit      1987977        1803872
## 74     MD PrivateNonprofit      2043470        1607827
## 75     MD           Public      2173223        1658469
## 76     MD      Proprietary      2279404        3399863
## 77     MD           Public      3104310        3299252
## 78     MD           Public      3480695        3197808
## 79     MD PrivateNonprofit      3974615        2536180
## 80     MD           Public      4075560        2612912
## 81     MD PrivateNonprofit      4234858        2986646
## 82     MD           Public      4266355        4914444
## 83     MD           Public      4278085        1571303
## 84     MD PrivateNonprofit      4701919        5113543
## 85     MD           Public      4777700        4991245
## 86     MD           Public      5013413        5617903
## 87     MD           Public      5385806        4202264
## 88     MD           Public      6156842        5663646
## 89     MD           Public      6714119        7547759
## 90     MD           Public      7886884        9144625
## 91     MD           Public      8771888        9752653
## 92     MD           Public     13557544       16185580
## 93     MD           Public     15673125       16470065
## 94     MD           Public     18151752       25195382
## 95     MD      Proprietary           NA             NA
## 96     MD PrivateNonprofit           NA             NA
## 97     VA PrivateNonprofit         5147           6000
## 98     VA PrivateNonprofit        12249          21001
## 99     VA PrivateNonprofit        12750           6500
## 100    VA      Proprietary        12890          14278
## 101    VA      Proprietary        15000          17462
## 102    VA      Proprietary        15959          23541
## 103    VA      Proprietary        17495          23250
## 104    VA      Proprietary        18541          35337
## 105    VA      Proprietary        20105          14600
## 106    VA      Proprietary        24936          70482
## 107    VA      Proprietary        26250             NA
## 108    VA      Proprietary        26250          41000
## 109    VA           Public        28000          27000
## 110    VA      Proprietary        28174          33448
## 111    VA           Public        31423          24000
## 112    VA      Proprietary        35580          27380
## 113    VA PrivateNonprofit        35750          36530
## 114    VA      Proprietary        38111          18514
## 115    VA      Proprietary        41964          66668
## 116    VA      Proprietary        48250          51206
## 117    VA      Proprietary        59045          92271
## 118    VA      Proprietary        67166         109107
## 119    VA      Proprietary        70674          94252
## 120    VA      Proprietary        71149          60318
## 121    VA      Proprietary        89968         137505
## 122    VA      Proprietary       111533         162120
## 123    VA      Proprietary       133201         207518
## 124    VA      Proprietary       140484         171366
## 125    VA      Proprietary       145437         161528
## 126    VA      Proprietary       154745         201463
## 127    VA           Public       159993         135936
## 128    VA      Proprietary       167524         214304
## 129    VA      Proprietary       198041         297444
## 130    VA PrivateNonprofit       203893         238185
## 131    VA      Proprietary       222008         356307
## 132    VA PrivateNonprofit       230382         279193
## 133    VA           Public       253477         190780
## 134    VA      Proprietary       269314         293631
## 135    VA           Public       273176         320029
## 136    VA      Proprietary       294696         464251
## 137    VA      Proprietary       374092         582553
## 138    VA PrivateNonprofit       398089         843015
## 139    VA           Public       443175          88910
## 140    VA           Public       487220         513443
## 141    VA PrivateNonprofit       505549         667711
## 142    VA PrivateNonprofit       557370         649045
## 143    VA PrivateNonprofit       664838         661229
## 144    VA PrivateNonprofit       672743         846236
## 145    VA           Public       689524         782121
## 146    VA PrivateNonprofit       794850         740752
## 147    VA      Proprietary       826924        1309772
## 148    VA PrivateNonprofit       832550         745373
## 149    VA PrivateNonprofit       844514         631027
## 150    VA           Public       909281        1398799
## 151    VA           Public       923958        1095893
## 152    VA      Proprietary       938851        1414879
## 153    VA           Public      1011638         814314
## 154    VA PrivateNonprofit      1047900        1022398
## 155    VA      Proprietary      1071599        1500366
## 156    VA PrivateNonprofit      1092293        1275166
## 157    VA           Public      1122476        1188958
## 158    VA PrivateNonprofit      1133856        1341021
## 159    VA PrivateNonprofit      1140253        1126487
## 160    VA           Public      1170083        1129315
## 161    VA PrivateNonprofit      1226696        1033267
## 162    VA           Public      1280922        1136560
## 163    VA      Proprietary      1474419        2238020
## 164    VA PrivateNonprofit      1543289        1605771
## 165    VA           Public      1675718        1850693
## 166    VA PrivateNonprofit      1794119        2188292
## 167    VA PrivateNonprofit      1811545        1881968
## 168    VA PrivateNonprofit      1974696        1505859
## 169    VA      Proprietary      2003400        3121887
## 170    VA PrivateNonprofit      2119592        2369374
## 171    VA PrivateNonprofit      2122312        2245622
## 172    VA           Public      2140538        2200558
## 173    VA PrivateNonprofit      2181804        2430597
## 174    VA PrivateNonprofit      2200957        2368719
## 175    VA PrivateNonprofit      2284041        2478730
## 176    VA      Proprietary      2293904        3444632
## 177    VA PrivateNonprofit      2479693        2445616
## 178    VA PrivateNonprofit      2527085        2903345
## 179    VA PrivateNonprofit      2697919        3271132
## 180    VA PrivateNonprofit      2715188        2831224
## 181    VA           Public      2719426        3737298
## 182    VA           Public      2933520        2918768
## 183    VA      Proprietary      3717804        5401391
## 184    VA           Public      3951490        4478591
## 185    VA           Public      3959652        4187127
## 186    VA           Public      4249355        4234544
## 187    VA PrivateNonprofit      4499732        4862738
## 188    VA           Public      5030445        5115887
## 189    VA           Public      5873500        6377457
## 190    VA      Proprietary      7100695        9060778
## 191    VA           Public      7802174        9099782
## 192    VA           Public      8349935       10312789
## 193    VA           Public      8414375        9320944
## 194    VA           Public     10448009       11067030
## 195    VA           Public     10756253       11941932
## 196    VA           Public     13782616       15202571
## 197    VA           Public     16751772       16470730
## 198    VA           Public     18050265       16648719
## 199    VA           Public     20240533       21935690
## 200    VA           Public     21959084       20934687
## 201    VA PrivateNonprofit     42052986       53196359
## 202    VA PrivateNonprofit           NA             NA
## 203    VA           Public           NA             NA
## 204    VA PrivateNonprofit           NA             NA
## 205    VA PrivateNonprofit           NA             NA
## 206    VA PrivateNonprofit           NA             NA
## 207    VA PrivateNonprofit           NA             NA
## 208    VA      Proprietary           NA             NA
## 209    VA PrivateNonprofit           NA             NA
## 210    VA PrivateNonprofit           NA             NA
arrange(loans, State, desc(SubsidizedDL))
##                                                                   School
## 1                                                     STRAYER UNIVERSITY
## 2                                                      HOWARD UNIVERSITY
## 3                                           GEORGE WASHINGTON UNIVERSITY
## 4                                                    AMERICAN UNIVERSITY
## 5                                 UNIVERSITY OF THE DISTRICT OF COLUMBIA
## 6                                                  GEORGETOWN UNIVERSITY
## 7                                         CATHOLIC UNIVERSITY OF AMERICA
## 8                                                        TRINITY COLLEGE
## 9                                                   GALLAUDET UNIVERSITY
## 10                                            CAREER TECHNICAL INSTITUTE
## 11                                    CORCORAN COLLEGE OF ART AND DESIGN
## 12                                                       RADIANS COLLEGE
## 13                                              BENNETT CAREER INSTITUTE
## 14                                            TECHNICAL LEARNING CENTERS
## 15                                NATIONAL CONSERVATORY OF DRAMATIC ARTS
## 16                                           WESLEY THEOLOGICAL SEMINARY
## 17                                            DOMINICAN HOUSE OF STUDIES
## 18                                                       POTOMAC COLLEGE
## 19                                       INSTITUTE OF WORLD POLITICS THE
## 20  PONTIFICAL JOHN PAUL II INSTITUTE FOR STUDIES ON MARRIAGE AND FAMILY
## 21                             UNIVERSITY OF MARYLAND UNIVERSITY COLLEGE
## 22                                   UNIVERSITY OF MARYLAND COLLEGE PARK
## 23                                                     TOWSON UNIVERSITY
## 24                                               MORGAN STATE UNIVERSITY
## 25                              UNIVERSITY OF MARYLAND  BALTIMORE COUNTY
## 26                                                  SALISBURY UNIVERSITY
## 27                                 COMMUNITY COLLEGE OF BALTIMORE COUNTY
## 28                                                    MONTGOMERY COLLEGE
## 29                                                BOWIE STATE UNIVERSITY
## 30                                 UNIVERSITY OF MARYLAND  EASTERN SHORE
## 31                                                  STEVENSON UNIVERSITY
## 32                                      PRINCE GEORGES COMMUNITY COLLEGE
## 33                                            FROSTBURG STATE UNIVERSITY
## 34                                            LOYOLA UNIVERSITY MARYLAND
## 35                                               COPPIN STATE UNIVERSITY
## 36                                              JOHNS HOPKINS UNIVERSITY
## 37                                               UNIVERSITY OF BALTIMORE
## 38                                        ANNE ARUNDEL COMMUNITY COLLEGE
## 39                                                      FORTIS INSTITUTE
## 40                                          HAGERSTOWN COMMUNITY COLLEGE
## 41                                     MARYLAND INSTITUTE COLLEGE OF ART
## 42                                                      MCDANIEL COLLEGE
## 43                                          ALLEGANY COLLEGE OF MARYLAND
## 44                                                          HOOD COLLEGE
## 45                                          MOUNT SAINT MARYS UNIVERSITY
## 46                                              HOWARD COMMUNITY COLLEGE
## 47                                                    WASHINGTON COLLEGE
## 48                                                       GOUCHER COLLEGE
## 49                                       WASHINGTON ADVENTIST UNIVERSITY
## 50                                          ST MARYS COLLEGE OF MARYLAND
## 51                                                       ALLSTATE CAREER
## 52                                          COLLEGE OF SOUTHERN MARYLAND
## 53                                     NOTRE DAME OF MARYLAND UNIVERSITY
## 54                                      UNIVERSITY OF MARYLAND BALTIMORE
## 55                                           FREDERICK COMMUNITY COLLEGE
## 56                                                         CECIL COLLEGE
## 57                                              WORWIC COMMUNITY COLLEGE
## 58                                                      ST JOHNS COLLEGE
## 59                                         LINCOLN COLLEGE OF TECHNOLOGY
## 60                                                       GARRETT COLLEGE
## 61                                          NORTH AMERICAN TRADE SCHOOLS
## 62                                             HARFORD COMMUNITY COLLEGE
## 63                                               AMERICAN BEAUTY ACADEMY
## 64                                                       CAPITOL COLLEGE
## 65                                             SOJOURNERDOUGLASS COLLEGE
## 66                                           TESST COLLEGE OF TECHNOLOGY
## 67                                                          HAIR ACADEMY
## 68                                           TESST COLLEGE OF TECHNOLOGY
## 69                                           TESST COLLEGE OF TECHNOLOGY
## 70                                           BALTIMORE SCHOOL OF MASSAGE
## 71                                             CARROLL COMMUNITY COLLEGE
## 72                                                NATIONAL LABOR COLLEGE
## 73                            TEMPLE THE: A PAUL MITCHELL PARTNER SCHOOL
## 74                                              HAIR EXPRESSIONS ACADEMY
## 75                                                   AWARD BEAUTY SCHOOL
## 76                                                  LACADEMIE DE CUISINE
## 77                                          INSTITUTE OF HEALTH SCIENCES
## 78                                               DELMARVA BEAUTY ACADEMY
## 79                                              MONTGOMERY BEAUTY SCHOOL
## 80                                          BLADES SCHOOL OF HAIR DESIGN
## 81                                      MARYLAND BEAUTY ACADEMY OF ESSEX
## 82                                          ASPEN BEAUTY ACADEMY  LAUREL
## 83                                                       HAIR ACADEMY II
## 84                                       BALTIMORE STUDIO OF HAIR DESIGN
## 85                                          COLORLAB ACADEMY OF HAIR THE
## 86                                   AESTHETICS INSTITUTE OF COSMETOLOGY
## 87                                       FREDERICK SCHOOL OF COSMETOLOGY
## 88           OMEGA STUDIOS SCHOOL OF APPLIED RECORDING ARTS AND SCIENCES
## 89                  ROBERT PAUL ACADEMY OF COSMETOLOGY ARTS AND SCIENCES
## 90                                              AARONS ACADEMY OF BEAUTY
## 91                                            FAITH THEOLOGICAL SEMINARY
## 92                                               MARYLAND BEAUTY ACADEMY
## 93                                                 HARMONS BEAUTY SCHOOL
## 94                                   HOLISTIC MASSAGE TRAINING INSTITUTE
## 95                                           INTERNATIONAL BEAUTY SCHOOL
## 96                             MARYLAND UNIVERSITY OF INTEGRATIVE HEALTH
## 97                                                    LIBERTY UNIVERSITY
## 98                                      VIRGINIA COMMONWEALTH UNIVERSITY
## 99                                               OLD DOMINION UNIVERSITY
## 100                                              GEORGE MASON UNIVERSITY
## 101                  VIRGINIA POLYTECHNIC INSTITUTE AND STATE UNIVERSITY
## 102                                  NORTHERN VIRGINIA COMMUNITY COLLEGE
## 103                                             JAMES MADISON UNIVERSITY
## 104                                          TIDEWATER COMMUNITY COLLEGE
## 105                                                   RADFORD UNIVERSITY
## 106                                             NORFOLK STATE UNIVERSITY
## 107                                            VIRGINIA STATE UNIVERSITY
## 108                                                      ECPI UNIVERSITY
## 109                                               UNIVERSITY OF VIRGINIA
## 110                                J SARGEANT REYNOLDS COMMUNITY COLLEGE
## 111                                                   HAMPTON UNIVERSITY
## 112                                      THOMAS NELSON COMMUNITY COLLEGE
## 113                                                  LONGWOOD UNIVERSITY
## 114                                       CHRISTOPHER NEWPORT UNIVERSITY
## 115                                        MILLERMOTTE TECHNICAL COLLEGE
## 116                                          COLLEGE OF WILLIAM AND MARY
## 117                                        UNIVERSITY OF MARY WASHINGTON
## 118                                                    LYNCHBURG COLLEGE
## 119                                                    REGENT UNIVERSITY
## 120                                                 MARYMOUNT UNIVERSITY
## 121                                                      ROANOKE COLLEGE
## 122                                          AMERICANNATIONAL UNIVERSITY
## 123                                            VIRGINIA UNION UNIVERSITY
## 124                                                SHENANDOAH UNIVERSITY
## 125                                                       FERRUM COLLEGE
## 126                                   VIRGINIA WESTERN COMMUNITY COLLEGE
## 127                                                  BRIDGEWATER COLLEGE
## 128                                                 MARY BALDWIN COLLEGE
## 129                                                 STRATFORD UNIVERSITY
## 130                                               UNIVERSITY OF RICHMOND
## 131                                            VIRGINIA WESLEYAN COLLEGE
## 132                                                   AVERETT UNIVERSITY
## 133                                         JOHN TYLER COMMUNITY COLLEGE
## 134                                                RANDOLPHMACON COLLEGE
## 135                                                      CENTURA COLLEGE
## 136                          UNIVERSITY OF VIRGINIAS COLLEGE AT WISE THE
## 137                                         EASTERN MENNONITE UNIVERSITY
## 138                                          VIRGINIA MILITARY INSTITUTE
## 139                                              EMORY AND HENRY COLLEGE
## 140                                 JEFFERSON COLLEGE OF HEALTH SCIENCES
## 141                                         BLUE RIDGE COMMUNITY COLLEGE
## 142                                                    BLUEFIELD COLLEGE
## 143                                                       FORTIS COLLEGE
## 144                                               HAMPDEN SYDNEY COLLEGE
## 145                                          NEW RIVER COMMUNITY COLLEGE
## 146                                                      EVEREST COLLEGE
## 147                                       LORD FAIRFAX COMMUNITY COLLEGE
## 148                                           GERMANNA COMMUNITY COLLEGE
## 149                                                     RANDOLPH COLLEGE
## 150                                         SOUTHERN VIRGINIA UNIVERSITY
## 151                                                      MEDTECH COLLEGE
## 152                                                   HOLLINS UNIVERSITY
## 153                                  PIEDMONT VIRGINIA COMMUNITY COLLEGE
## 154                                     VIRGINIA UNIVERSITY OF LYNCHBURG
## 155                                                  SWEET BRIAR COLLEGE
## 156                              BON SECOURS MEMORIAL COLLEGE OF NURSING
## 157                                   SENTARA COLLEGE OF HEALTH SCIENCES
## 158             RICHARD BLAND COLLEGE OF THE COLLEGE OF WILLIAM AND MARY
## 159                                           DANVILLE COMMUNITY COLLEGE
## 160                                        WASHINGTON AND LEE UNIVERSITY
## 161                                                      CENTURA COLLEGE
## 162                                                       TIDEWATER TECH
## 163                                 DABNEY S LANCASTER COMMUNITY COLLEGE
## 164                                        ADVANCED TECHNOLOGY INSTITUTE
## 165                                         WYTHEVILLE COMMUNITY COLLEGE
## 166                                   RIVERSIDE SCHOOL OF HEALTH CAREERS
## 167                                                GLOBAL HEALTH COLLEGE
## 168                                            CENTRA COLLEGE OF NURSING
## 169                                    AVIATION INSTITUTE OF MAINTENANCE
## 170                              RUDY AND KELLY ACADEMY OF HAIR ANDNAILS
## 171                                   CENTRAL VIRGINIA COMMUNITY COLLEGE
## 172                                                      SKYLINE COLLEGE
## 173                                                                 RSHT
## 174               SOUTHSIDE REGIONAL MEDICAL CENTER PROFESSIONAL SCHOOLS
## 175                                          WARDS CORNER BEAUTY ACADEMY
## 176                                            CAREER TRAINING SOLUTIONS
## 177                                    AVIATION INSTITUTE OF MAINTENANCE
## 178                      STANDARD HEALTHCARE SERVICES COLLEGE OF NURSING
## 179                           SYLVAIN MELLOUL INTERNATIONAL HAIR ACADEMY
## 180                            GRAHAM WEBB INTERNATIONAL ACADEMY OF HAIR
## 181                                                 SANFORDBROWN COLLEGE
## 182                                               SUFFOLK BEAUTY ACADEMY
## 183                                           VIRGINIA SCHOOL OF MASSAGE
## 184                                           SPRINGFIELD BEAUTY ACADEMY
## 185              BON SECOURS ST MARYS HOSPITAL SCHOOL OF MEDICAL IMAGING
## 186                          UNIVERSITY OF MANAGEMENT AND TECHNOLOGY THE
## 187                                 CULPEPER COSMETOLOGY TRAINING CENTER
## 188                                     BAR PALMA BEAUTY CAREERS ACADEMY
## 189       HENRICO COUNTYSAINT MARYS HOSPITAL SCHOOL OF PRACTICAL NURSING
## 190                                  COSMOPOLITAN BEAUTY AND TECH SCHOOL
## 191                           TOMORROWS IMAGE BARBER ACADEMY OF VIRGINIA
## 192                      NORTHERN VIRGINIA SCHOOL OF THERAPEUTIC MASSAGE
## 193                                                     COLUMBIA COLLEGE
## 194                                    CHRYSM INSTITUTE OF ESTHETICS THE
## 195                                       DOMINION SCHOOL OF HAIR DESIGN
## 196                                                  AVI CAREER TRAINING
## 197        DANVILLE REGIONAL MEDICAL CENTER SCHOOL OF HEALTH PROFESSIONS
## 198                                       STAUNTON SCHOOL OF COSMETOLOGY
## 199                                           VIRGINIA INTERMONT COLLEGE
## 200                                  CAYCE/REILLY SCHOOL OF MASSOTHERAPY
## 201                                                       BETHEL COLLEGE
## 202                                          UNION PRESBYTERIAN SEMINARY
## 203                                      EASTERN VIRGINIA MEDICAL SCHOOL
## 204                             BAPTIST THEOLOGICAL SEMINARY AT RICHMOND
## 205                                            APPALACHIAN SCHOOL OF LAW
## 206                  EDWARD VIA VIRGINIA COLLEGE OF OSTEOPATHIC MEDICINE
## 207                             INSTITUTE FOR THE PSYCHOLOGICAL SCIENCES
## 208                              INSTITUTE OF ADVANCED MEDICAL ESTHETICS
## 209                                      APPALACHIAN COLLEGE OF PHARMACY
## 210                            VIRGINIA TECH CARILION SCHOOL OF MEDICINE
##     State      School_Type SubsidizedDL UNSubsidizedDL
## 1      DC      Proprietary     22490396       34840102
## 2      DC PrivateNonprofit      9414766        9021712
## 3      DC PrivateNonprofit      7463145        5913027
## 4      DC PrivateNonprofit      6213538        4517728
## 5      DC           Public      3850272        4248284
## 6      DC PrivateNonprofit      3824260        1318290
## 7      DC PrivateNonprofit      3619502        3520966
## 8      DC PrivateNonprofit      2522961        2850888
## 9      DC PrivateNonprofit       679602         561785
## 10     DC      Proprietary       416911         685909
## 11     DC PrivateNonprofit       356355         360715
## 12     DC      Proprietary       340038         514081
## 13     DC      Proprietary       107642          88632
## 14     DC      Proprietary        84000         128000
## 15     DC PrivateNonprofit        40812          21963
## 16     DC PrivateNonprofit           NA          22250
## 17     DC PrivateNonprofit           NA             NA
## 18     DC      Proprietary           NA             NA
## 19     DC PrivateNonprofit           NA             NA
## 20     DC PrivateNonprofit           NA             NA
## 21     MD           Public     18151752       25195382
## 22     MD           Public     15673125       16470065
## 23     MD           Public     13557544       16185580
## 24     MD           Public      8771888        9752653
## 25     MD           Public      7886884        9144625
## 26     MD           Public      6714119        7547759
## 27     MD           Public      6156842        5663646
## 28     MD           Public      5385806        4202264
## 29     MD           Public      5013413        5617903
## 30     MD           Public      4777700        4991245
## 31     MD PrivateNonprofit      4701919        5113543
## 32     MD           Public      4278085        1571303
## 33     MD           Public      4266355        4914444
## 34     MD PrivateNonprofit      4234858        2986646
## 35     MD           Public      4075560        2612912
## 36     MD PrivateNonprofit      3974615        2536180
## 37     MD           Public      3480695        3197808
## 38     MD           Public      3104310        3299252
## 39     MD      Proprietary      2279404        3399863
## 40     MD           Public      2173223        1658469
## 41     MD PrivateNonprofit      2043470        1607827
## 42     MD PrivateNonprofit      1987977        1803872
## 43     MD           Public      1985362        2200457
## 44     MD PrivateNonprofit      1954513        1812060
## 45     MD PrivateNonprofit      1796922        1705136
## 46     MD           Public      1562603        1825338
## 47     MD PrivateNonprofit      1499542        1323401
## 48     MD PrivateNonprofit      1426570        1079658
## 49     MD PrivateNonprofit      1362268        1768461
## 50     MD           Public      1199357        1274362
## 51     MD      Proprietary      1072935        1607727
## 52     MD           Public       950019        1387749
## 53     MD PrivateNonprofit       921184        1231367
## 54     MD           Public       790624         831014
## 55     MD           Public       785716         946044
## 56     MD           Public       730994        1233936
## 57     MD           Public       595801         231267
## 58     MD PrivateNonprofit       589510         355243
## 59     MD      Proprietary       587391         795882
## 60     MD           Public       424451         425844
## 61     MD      Proprietary       420951         614068
## 62     MD           Public       411657         499914
## 63     MD      Proprietary       400537         660202
## 64     MD PrivateNonprofit       397211         405964
## 65     MD PrivateNonprofit       361594         864259
## 66     MD      Proprietary       305942         439905
## 67     MD      Proprietary       274339         283712
## 68     MD      Proprietary       270825         414703
## 69     MD      Proprietary       268744         371619
## 70     MD      Proprietary       231284         389641
## 71     MD           Public       207666         416588
## 72     MD PrivateNonprofit       196352         320716
## 73     MD      Proprietary       153776         234372
## 74     MD      Proprietary       126302         153268
## 75     MD      Proprietary       116268         115914
## 76     MD      Proprietary       107306         157442
## 77     MD      Proprietary        63574          97427
## 78     MD      Proprietary        61250          68022
## 79     MD      Proprietary        59017          57179
## 80     MD      Proprietary        52234          77251
## 81     MD      Proprietary        50260          52483
## 82     MD      Proprietary        48698          52385
## 83     MD      Proprietary        46285          62073
## 84     MD      Proprietary        33224          37891
## 85     MD      Proprietary        31723          49455
## 86     MD      Proprietary        24249          33499
## 87     MD      Proprietary        23861          24999
## 88     MD      Proprietary        21875          33375
## 89     MD      Proprietary        20573          24171
## 90     MD      Proprietary        13973          19876
## 91     MD PrivateNonprofit        12832          19666
## 92     MD      Proprietary        12266           5600
## 93     MD      Proprietary         9750          11000
## 94     MD      Proprietary         8165          15832
## 95     MD      Proprietary           NA             NA
## 96     MD PrivateNonprofit           NA             NA
## 97     VA PrivateNonprofit     42052986       53196359
## 98     VA           Public     21959084       20934687
## 99     VA           Public     20240533       21935690
## 100    VA           Public     18050265       16648719
## 101    VA           Public     16751772       16470730
## 102    VA           Public     13782616       15202571
## 103    VA           Public     10756253       11941932
## 104    VA           Public     10448009       11067030
## 105    VA           Public      8414375        9320944
## 106    VA           Public      8349935       10312789
## 107    VA           Public      7802174        9099782
## 108    VA      Proprietary      7100695        9060778
## 109    VA           Public      5873500        6377457
## 110    VA           Public      5030445        5115887
## 111    VA PrivateNonprofit      4499732        4862738
## 112    VA           Public      4249355        4234544
## 113    VA           Public      3959652        4187127
## 114    VA           Public      3951490        4478591
## 115    VA      Proprietary      3717804        5401391
## 116    VA           Public      2933520        2918768
## 117    VA           Public      2719426        3737298
## 118    VA PrivateNonprofit      2715188        2831224
## 119    VA PrivateNonprofit      2697919        3271132
## 120    VA PrivateNonprofit      2527085        2903345
## 121    VA PrivateNonprofit      2479693        2445616
## 122    VA      Proprietary      2293904        3444632
## 123    VA PrivateNonprofit      2284041        2478730
## 124    VA PrivateNonprofit      2200957        2368719
## 125    VA PrivateNonprofit      2181804        2430597
## 126    VA           Public      2140538        2200558
## 127    VA PrivateNonprofit      2122312        2245622
## 128    VA PrivateNonprofit      2119592        2369374
## 129    VA      Proprietary      2003400        3121887
## 130    VA PrivateNonprofit      1974696        1505859
## 131    VA PrivateNonprofit      1811545        1881968
## 132    VA PrivateNonprofit      1794119        2188292
## 133    VA           Public      1675718        1850693
## 134    VA PrivateNonprofit      1543289        1605771
## 135    VA      Proprietary      1474419        2238020
## 136    VA           Public      1280922        1136560
## 137    VA PrivateNonprofit      1226696        1033267
## 138    VA           Public      1170083        1129315
## 139    VA PrivateNonprofit      1140253        1126487
## 140    VA PrivateNonprofit      1133856        1341021
## 141    VA           Public      1122476        1188958
## 142    VA PrivateNonprofit      1092293        1275166
## 143    VA      Proprietary      1071599        1500366
## 144    VA PrivateNonprofit      1047900        1022398
## 145    VA           Public      1011638         814314
## 146    VA      Proprietary       938851        1414879
## 147    VA           Public       923958        1095893
## 148    VA           Public       909281        1398799
## 149    VA PrivateNonprofit       844514         631027
## 150    VA PrivateNonprofit       832550         745373
## 151    VA      Proprietary       826924        1309772
## 152    VA PrivateNonprofit       794850         740752
## 153    VA           Public       689524         782121
## 154    VA PrivateNonprofit       672743         846236
## 155    VA PrivateNonprofit       664838         661229
## 156    VA PrivateNonprofit       557370         649045
## 157    VA PrivateNonprofit       505549         667711
## 158    VA           Public       487220         513443
## 159    VA           Public       443175          88910
## 160    VA PrivateNonprofit       398089         843015
## 161    VA      Proprietary       374092         582553
## 162    VA      Proprietary       294696         464251
## 163    VA           Public       273176         320029
## 164    VA      Proprietary       269314         293631
## 165    VA           Public       253477         190780
## 166    VA PrivateNonprofit       230382         279193
## 167    VA      Proprietary       222008         356307
## 168    VA PrivateNonprofit       203893         238185
## 169    VA      Proprietary       198041         297444
## 170    VA      Proprietary       167524         214304
## 171    VA           Public       159993         135936
## 172    VA      Proprietary       154745         201463
## 173    VA      Proprietary       145437         161528
## 174    VA      Proprietary       140484         171366
## 175    VA      Proprietary       133201         207518
## 176    VA      Proprietary       111533         162120
## 177    VA      Proprietary        89968         137505
## 178    VA      Proprietary        71149          60318
## 179    VA      Proprietary        70674          94252
## 180    VA      Proprietary        67166         109107
## 181    VA      Proprietary        59045          92271
## 182    VA      Proprietary        48250          51206
## 183    VA      Proprietary        41964          66668
## 184    VA      Proprietary        38111          18514
## 185    VA PrivateNonprofit        35750          36530
## 186    VA      Proprietary        35580          27380
## 187    VA           Public        31423          24000
## 188    VA      Proprietary        28174          33448
## 189    VA           Public        28000          27000
## 190    VA      Proprietary        26250             NA
## 191    VA      Proprietary        26250          41000
## 192    VA      Proprietary        24936          70482
## 193    VA      Proprietary        20105          14600
## 194    VA      Proprietary        18541          35337
## 195    VA      Proprietary        17495          23250
## 196    VA      Proprietary        15959          23541
## 197    VA      Proprietary        15000          17462
## 198    VA      Proprietary        12890          14278
## 199    VA PrivateNonprofit        12750           6500
## 200    VA PrivateNonprofit        12249          21001
## 201    VA PrivateNonprofit         5147           6000
## 202    VA PrivateNonprofit           NA             NA
## 203    VA           Public           NA             NA
## 204    VA PrivateNonprofit           NA             NA
## 205    VA PrivateNonprofit           NA             NA
## 206    VA PrivateNonprofit           NA             NA
## 207    VA PrivateNonprofit           NA             NA
## 208    VA      Proprietary           NA             NA
## 209    VA PrivateNonprofit           NA             NA
## 210    VA PrivateNonprofit           NA             NA

select()

This function pulls out colums of interest. You can select ranges of columns using the : operator syntax. (Note: usually this only works with numeric data, but this is a special usage defined in the dplyr package)

select(loans, State, SubsidizedDL)
##     State SubsidizedDL
## 1      DC      6213538
## 2      DC      3619502
## 3      DC      3850272
## 4      DC       679602
## 5      DC      7463145
## 6      DC      3824260
## 7      DC      9414766
## 8      DC     22490396
## 9      DC      2522961
## 10     DC           NA
## 11     DC       356355
## 12     DC           NA
## 13     DC        40812
## 14     DC       416911
## 15     DC           NA
## 16     DC       107642
## 17     DC        84000
## 18     DC           NA
## 19     DC           NA
## 20     DC       340038
## 21     MD       397211
## 22     MD      1985362
## 23     MD      3104310
## 24     MD      5013413
## 25     MD      6156842
## 26     MD       950019
## 27     MD       921184
## 28     MD      1362268
## 29     MD      4075560
## 30     MD       785716
## 31     MD      4266355
## 32     MD      1426570
## 33     MD      2173223
## 34     MD       411657
## 35     MD      1954513
## 36     MD      3974615
## 37     MD      4234858
## 38     MD      2043470
## 39     MD      8771888
## 40     MD      1796922
## 41     MD      4278085
## 42     MD      6714119
## 43     MD       589510
## 44     MD      1199357
## 45     MD     13557544
## 46     MD      3480695
## 47     MD     15673125
## 48     MD       790624
## 49     MD      7886884
## 50     MD      4777700
## 51     MD      4701919
## 52     MD      1499542
## 53     MD      1987977
## 54     MD      5385806
## 55     MD           NA
## 56     MD        61250
## 57     MD       305942
## 58     MD       587391
## 59     MD      1562603
## 60     MD       116268
## 61     MD       730994
## 62     MD       424451
## 63     MD      2279404
## 64     MD       268744
## 65     MD     18151752
## 66     MD       595801
## 67     MD       270825
## 68     MD       361594
## 69     MD        31723
## 70     MD        50260
## 71     MD       274339
## 72     MD        59017
## 73     MD        33224
## 74     MD        20573
## 75     MD        12266
## 76     MD       420951
## 77     MD       107306
## 78     MD           NA
## 79     MD        52234
## 80     MD        13973
## 81     MD        24249
## 82     MD       207666
## 83     MD       400537
## 84     MD       231284
## 85     MD        46285
## 86     MD       196352
## 87     MD      1072935
## 88     MD        12832
## 89     MD       126302
## 90     MD        23861
## 91     MD        21875
## 92     MD       153776
## 93     MD         8165
## 94     MD        48698
## 95     MD        63574
## 96     MD         9750
## 97     VA      1794119
## 98     VA      1092293
## 99     VA      2122312
## 100    VA      2933520
## 101    VA      3951490
## 102    VA       487220
## 103    VA      1226696
## 104    VA      1140253
## 105    VA      2181804
## 106    VA     10448009
## 107    VA      1047900
## 108    VA      4499732
## 109    VA       794850
## 110    VA      3959652
## 111    VA      2715188
## 112    VA     10756253
## 113    VA      2119592
## 114    VA      2527085
## 115    VA      2293904
## 116    VA     13782616
## 117    VA     20240533
## 118    VA      8414375
## 119    VA      1543289
## 120    VA       844514
## 121    VA     21959084
## 122    VA      2479693
## 123    VA      2200957
## 124    VA       832550
## 125    VA       664838
## 126    VA           NA
## 127    VA      1974696
## 128    VA      5873500
## 129    VA      2719426
## 130    VA      1280922
## 131    VA     18050265
## 132    VA        12750
## 133    VA      1170083
## 134    VA     16751772
## 135    VA       443175
## 136    VA      5030445
## 137    VA      2140538
## 138    VA       253477
## 139    VA       672743
## 140    VA      7802174
## 141    VA      8349935
## 142    VA      2284041
## 143    VA      1811545
## 144    VA       398089
## 145    VA      1675718
## 146    VA       159993
## 147    VA      3717804
## 148    VA       273176
## 149    VA      1011638
## 150    VA      1133856
## 151    VA      1122476
## 152    VA      4249355
## 153    VA       923958
## 154    VA       909281
## 155    VA       938851
## 156    VA        59045
## 157    VA        12890
## 158    VA       689524
## 159    VA       557370
## 160    VA      7100695
## 161    VA           NA
## 162    VA        70674
## 163    VA       140484
## 164    VA     42052986
## 165    VA       133201
## 166    VA        15000
## 167    VA       230382
## 168    VA       203893
## 169    VA        28000
## 170    VA       294696
## 171    VA      1474419
## 172    VA      1071599
## 173    VA        35750
## 174    VA        48250
## 175    VA      2003400
## 176    VA       826924
## 177    VA        67166
## 178    VA        28174
## 179    VA      2697919
## 180    VA       154745
## 181    VA        38111
## 182    VA       505549
## 183    VA           NA
## 184    VA       198041
## 185    VA       374092
## 186    VA       269314
## 187    VA        41964
## 188    VA       145437
## 189    VA           NA
## 190    VA       167524
## 191    VA       111533
## 192    VA           NA
## 193    VA           NA
## 194    VA        31423
## 195    VA        89968
## 196    VA        15959
## 197    VA        35580
## 198    VA        17495
## 199    VA        20105
## 200    VA        12249
## 201    VA       222008
## 202    VA         5147
## 203    VA           NA
## 204    VA        24936
## 205    VA        26250
## 206    VA        26250
## 207    VA           NA
## 208    VA           NA
## 209    VA        18541
## 210    VA        71149
select(loans, -State, -SubsidizedDL)
##                                                                   School
## 1                                                    AMERICAN UNIVERSITY
## 2                                         CATHOLIC UNIVERSITY OF AMERICA
## 3                                 UNIVERSITY OF THE DISTRICT OF COLUMBIA
## 4                                                   GALLAUDET UNIVERSITY
## 5                                           GEORGE WASHINGTON UNIVERSITY
## 6                                                  GEORGETOWN UNIVERSITY
## 7                                                      HOWARD UNIVERSITY
## 8                                                     STRAYER UNIVERSITY
## 9                                                        TRINITY COLLEGE
## 10                                           WESLEY THEOLOGICAL SEMINARY
## 11                                    CORCORAN COLLEGE OF ART AND DESIGN
## 12                                            DOMINICAN HOUSE OF STUDIES
## 13                                NATIONAL CONSERVATORY OF DRAMATIC ARTS
## 14                                            CAREER TECHNICAL INSTITUTE
## 15                                                       POTOMAC COLLEGE
## 16                                              BENNETT CAREER INSTITUTE
## 17                                            TECHNICAL LEARNING CENTERS
## 18                                       INSTITUTE OF WORLD POLITICS THE
## 19  PONTIFICAL JOHN PAUL II INSTITUTE FOR STUDIES ON MARRIAGE AND FAMILY
## 20                                                       RADIANS COLLEGE
## 21                                                       CAPITOL COLLEGE
## 22                                          ALLEGANY COLLEGE OF MARYLAND
## 23                                        ANNE ARUNDEL COMMUNITY COLLEGE
## 24                                                BOWIE STATE UNIVERSITY
## 25                                 COMMUNITY COLLEGE OF BALTIMORE COUNTY
## 26                                          COLLEGE OF SOUTHERN MARYLAND
## 27                                     NOTRE DAME OF MARYLAND UNIVERSITY
## 28                                       WASHINGTON ADVENTIST UNIVERSITY
## 29                                               COPPIN STATE UNIVERSITY
## 30                                           FREDERICK COMMUNITY COLLEGE
## 31                                            FROSTBURG STATE UNIVERSITY
## 32                                                       GOUCHER COLLEGE
## 33                                          HAGERSTOWN COMMUNITY COLLEGE
## 34                                             HARFORD COMMUNITY COLLEGE
## 35                                                          HOOD COLLEGE
## 36                                              JOHNS HOPKINS UNIVERSITY
## 37                                            LOYOLA UNIVERSITY MARYLAND
## 38                                     MARYLAND INSTITUTE COLLEGE OF ART
## 39                                               MORGAN STATE UNIVERSITY
## 40                                          MOUNT SAINT MARYS UNIVERSITY
## 41                                      PRINCE GEORGES COMMUNITY COLLEGE
## 42                                                  SALISBURY UNIVERSITY
## 43                                                      ST JOHNS COLLEGE
## 44                                          ST MARYS COLLEGE OF MARYLAND
## 45                                                     TOWSON UNIVERSITY
## 46                                               UNIVERSITY OF BALTIMORE
## 47                                   UNIVERSITY OF MARYLAND COLLEGE PARK
## 48                                      UNIVERSITY OF MARYLAND BALTIMORE
## 49                              UNIVERSITY OF MARYLAND  BALTIMORE COUNTY
## 50                                 UNIVERSITY OF MARYLAND  EASTERN SHORE
## 51                                                  STEVENSON UNIVERSITY
## 52                                                    WASHINGTON COLLEGE
## 53                                                      MCDANIEL COLLEGE
## 54                                                    MONTGOMERY COLLEGE
## 55                                           INTERNATIONAL BEAUTY SCHOOL
## 56                                               DELMARVA BEAUTY ACADEMY
## 57                                           TESST COLLEGE OF TECHNOLOGY
## 58                                         LINCOLN COLLEGE OF TECHNOLOGY
## 59                                              HOWARD COMMUNITY COLLEGE
## 60                                                   AWARD BEAUTY SCHOOL
## 61                                                         CECIL COLLEGE
## 62                                                       GARRETT COLLEGE
## 63                                                      FORTIS INSTITUTE
## 64                                           TESST COLLEGE OF TECHNOLOGY
## 65                             UNIVERSITY OF MARYLAND UNIVERSITY COLLEGE
## 66                                              WORWIC COMMUNITY COLLEGE
## 67                                           TESST COLLEGE OF TECHNOLOGY
## 68                                             SOJOURNERDOUGLASS COLLEGE
## 69                                          COLORLAB ACADEMY OF HAIR THE
## 70                                      MARYLAND BEAUTY ACADEMY OF ESSEX
## 71                                                          HAIR ACADEMY
## 72                                              MONTGOMERY BEAUTY SCHOOL
## 73                                       BALTIMORE STUDIO OF HAIR DESIGN
## 74                  ROBERT PAUL ACADEMY OF COSMETOLOGY ARTS AND SCIENCES
## 75                                               MARYLAND BEAUTY ACADEMY
## 76                                          NORTH AMERICAN TRADE SCHOOLS
## 77                                                  LACADEMIE DE CUISINE
## 78                             MARYLAND UNIVERSITY OF INTEGRATIVE HEALTH
## 79                                          BLADES SCHOOL OF HAIR DESIGN
## 80                                              AARONS ACADEMY OF BEAUTY
## 81                                   AESTHETICS INSTITUTE OF COSMETOLOGY
## 82                                             CARROLL COMMUNITY COLLEGE
## 83                                               AMERICAN BEAUTY ACADEMY
## 84                                           BALTIMORE SCHOOL OF MASSAGE
## 85                                                       HAIR ACADEMY II
## 86                                                NATIONAL LABOR COLLEGE
## 87                                                       ALLSTATE CAREER
## 88                                            FAITH THEOLOGICAL SEMINARY
## 89                                              HAIR EXPRESSIONS ACADEMY
## 90                                       FREDERICK SCHOOL OF COSMETOLOGY
## 91           OMEGA STUDIOS SCHOOL OF APPLIED RECORDING ARTS AND SCIENCES
## 92                            TEMPLE THE: A PAUL MITCHELL PARTNER SCHOOL
## 93                                   HOLISTIC MASSAGE TRAINING INSTITUTE
## 94                                          ASPEN BEAUTY ACADEMY  LAUREL
## 95                                          INSTITUTE OF HEALTH SCIENCES
## 96                                                 HARMONS BEAUTY SCHOOL
## 97                                                    AVERETT UNIVERSITY
## 98                                                     BLUEFIELD COLLEGE
## 99                                                   BRIDGEWATER COLLEGE
## 100                                          COLLEGE OF WILLIAM AND MARY
## 101                                       CHRISTOPHER NEWPORT UNIVERSITY
## 102             RICHARD BLAND COLLEGE OF THE COLLEGE OF WILLIAM AND MARY
## 103                                         EASTERN MENNONITE UNIVERSITY
## 104                                              EMORY AND HENRY COLLEGE
## 105                                                       FERRUM COLLEGE
## 106                                          TIDEWATER COMMUNITY COLLEGE
## 107                                               HAMPDEN SYDNEY COLLEGE
## 108                                                   HAMPTON UNIVERSITY
## 109                                                   HOLLINS UNIVERSITY
## 110                                                  LONGWOOD UNIVERSITY
## 111                                                    LYNCHBURG COLLEGE
## 112                                             JAMES MADISON UNIVERSITY
## 113                                                 MARY BALDWIN COLLEGE
## 114                                                 MARYMOUNT UNIVERSITY
## 115                                          AMERICANNATIONAL UNIVERSITY
## 116                                  NORTHERN VIRGINIA COMMUNITY COLLEGE
## 117                                              OLD DOMINION UNIVERSITY
## 118                                                   RADFORD UNIVERSITY
## 119                                                RANDOLPHMACON COLLEGE
## 120                                                     RANDOLPH COLLEGE
## 121                                     VIRGINIA COMMONWEALTH UNIVERSITY
## 122                                                      ROANOKE COLLEGE
## 123                                                SHENANDOAH UNIVERSITY
## 124                                         SOUTHERN VIRGINIA UNIVERSITY
## 125                                                  SWEET BRIAR COLLEGE
## 126                                          UNION PRESBYTERIAN SEMINARY
## 127                                               UNIVERSITY OF RICHMOND
## 128                                               UNIVERSITY OF VIRGINIA
## 129                                        UNIVERSITY OF MARY WASHINGTON
## 130                          UNIVERSITY OF VIRGINIAS COLLEGE AT WISE THE
## 131                                              GEORGE MASON UNIVERSITY
## 132                                           VIRGINIA INTERMONT COLLEGE
## 133                                          VIRGINIA MILITARY INSTITUTE
## 134                  VIRGINIA POLYTECHNIC INSTITUTE AND STATE UNIVERSITY
## 135                                           DANVILLE COMMUNITY COLLEGE
## 136                                J SARGEANT REYNOLDS COMMUNITY COLLEGE
## 137                                   VIRGINIA WESTERN COMMUNITY COLLEGE
## 138                                         WYTHEVILLE COMMUNITY COLLEGE
## 139                                     VIRGINIA UNIVERSITY OF LYNCHBURG
## 140                                            VIRGINIA STATE UNIVERSITY
## 141                                             NORFOLK STATE UNIVERSITY
## 142                                            VIRGINIA UNION UNIVERSITY
## 143                                            VIRGINIA WESLEYAN COLLEGE
## 144                                        WASHINGTON AND LEE UNIVERSITY
## 145                                         JOHN TYLER COMMUNITY COLLEGE
## 146                                   CENTRAL VIRGINIA COMMUNITY COLLEGE
## 147                                        MILLERMOTTE TECHNICAL COLLEGE
## 148                                 DABNEY S LANCASTER COMMUNITY COLLEGE
## 149                                          NEW RIVER COMMUNITY COLLEGE
## 150                                 JEFFERSON COLLEGE OF HEALTH SCIENCES
## 151                                         BLUE RIDGE COMMUNITY COLLEGE
## 152                                      THOMAS NELSON COMMUNITY COLLEGE
## 153                                       LORD FAIRFAX COMMUNITY COLLEGE
## 154                                           GERMANNA COMMUNITY COLLEGE
## 155                                                      EVEREST COLLEGE
## 156                                                 SANFORDBROWN COLLEGE
## 157                                       STAUNTON SCHOOL OF COSMETOLOGY
## 158                                  PIEDMONT VIRGINIA COMMUNITY COLLEGE
## 159                              BON SECOURS MEMORIAL COLLEGE OF NURSING
## 160                                                      ECPI UNIVERSITY
## 161                                      EASTERN VIRGINIA MEDICAL SCHOOL
## 162                           SYLVAIN MELLOUL INTERNATIONAL HAIR ACADEMY
## 163               SOUTHSIDE REGIONAL MEDICAL CENTER PROFESSIONAL SCHOOLS
## 164                                                   LIBERTY UNIVERSITY
## 165                                          WARDS CORNER BEAUTY ACADEMY
## 166        DANVILLE REGIONAL MEDICAL CENTER SCHOOL OF HEALTH PROFESSIONS
## 167                                   RIVERSIDE SCHOOL OF HEALTH CAREERS
## 168                                            CENTRA COLLEGE OF NURSING
## 169       HENRICO COUNTYSAINT MARYS HOSPITAL SCHOOL OF PRACTICAL NURSING
## 170                                                       TIDEWATER TECH
## 171                                                      CENTURA COLLEGE
## 172                                                       FORTIS COLLEGE
## 173              BON SECOURS ST MARYS HOSPITAL SCHOOL OF MEDICAL IMAGING
## 174                                               SUFFOLK BEAUTY ACADEMY
## 175                                                 STRATFORD UNIVERSITY
## 176                                                      MEDTECH COLLEGE
## 177                            GRAHAM WEBB INTERNATIONAL ACADEMY OF HAIR
## 178                                     BAR PALMA BEAUTY CAREERS ACADEMY
## 179                                                    REGENT UNIVERSITY
## 180                                                      SKYLINE COLLEGE
## 181                                           SPRINGFIELD BEAUTY ACADEMY
## 182                                   SENTARA COLLEGE OF HEALTH SCIENCES
## 183                             BAPTIST THEOLOGICAL SEMINARY AT RICHMOND
## 184                                    AVIATION INSTITUTE OF MAINTENANCE
## 185                                                      CENTURA COLLEGE
## 186                                        ADVANCED TECHNOLOGY INSTITUTE
## 187                                           VIRGINIA SCHOOL OF MASSAGE
## 188                                                                 RSHT
## 189                                            APPALACHIAN SCHOOL OF LAW
## 190                              RUDY AND KELLY ACADEMY OF HAIR ANDNAILS
## 191                                            CAREER TRAINING SOLUTIONS
## 192                  EDWARD VIA VIRGINIA COLLEGE OF OSTEOPATHIC MEDICINE
## 193                             INSTITUTE FOR THE PSYCHOLOGICAL SCIENCES
## 194                                 CULPEPER COSMETOLOGY TRAINING CENTER
## 195                                    AVIATION INSTITUTE OF MAINTENANCE
## 196                                                  AVI CAREER TRAINING
## 197                          UNIVERSITY OF MANAGEMENT AND TECHNOLOGY THE
## 198                                       DOMINION SCHOOL OF HAIR DESIGN
## 199                                                     COLUMBIA COLLEGE
## 200                                  CAYCE/REILLY SCHOOL OF MASSOTHERAPY
## 201                                                GLOBAL HEALTH COLLEGE
## 202                                                       BETHEL COLLEGE
## 203                              INSTITUTE OF ADVANCED MEDICAL ESTHETICS
## 204                      NORTHERN VIRGINIA SCHOOL OF THERAPEUTIC MASSAGE
## 205                                  COSMOPOLITAN BEAUTY AND TECH SCHOOL
## 206                           TOMORROWS IMAGE BARBER ACADEMY OF VIRGINIA
## 207                                      APPALACHIAN COLLEGE OF PHARMACY
## 208                            VIRGINIA TECH CARILION SCHOOL OF MEDICINE
## 209                                    CHRYSM INSTITUTE OF ESTHETICS THE
## 210                      STANDARD HEALTHCARE SERVICES COLLEGE OF NURSING
##          School_Type UNSubsidizedDL
## 1   PrivateNonprofit        4517728
## 2   PrivateNonprofit        3520966
## 3             Public        4248284
## 4   PrivateNonprofit         561785
## 5   PrivateNonprofit        5913027
## 6   PrivateNonprofit        1318290
## 7   PrivateNonprofit        9021712
## 8        Proprietary       34840102
## 9   PrivateNonprofit        2850888
## 10  PrivateNonprofit          22250
## 11  PrivateNonprofit         360715
## 12  PrivateNonprofit             NA
## 13  PrivateNonprofit          21963
## 14       Proprietary         685909
## 15       Proprietary             NA
## 16       Proprietary          88632
## 17       Proprietary         128000
## 18  PrivateNonprofit             NA
## 19  PrivateNonprofit             NA
## 20       Proprietary         514081
## 21  PrivateNonprofit         405964
## 22            Public        2200457
## 23            Public        3299252
## 24            Public        5617903
## 25            Public        5663646
## 26            Public        1387749
## 27  PrivateNonprofit        1231367
## 28  PrivateNonprofit        1768461
## 29            Public        2612912
## 30            Public         946044
## 31            Public        4914444
## 32  PrivateNonprofit        1079658
## 33            Public        1658469
## 34            Public         499914
## 35  PrivateNonprofit        1812060
## 36  PrivateNonprofit        2536180
## 37  PrivateNonprofit        2986646
## 38  PrivateNonprofit        1607827
## 39            Public        9752653
## 40  PrivateNonprofit        1705136
## 41            Public        1571303
## 42            Public        7547759
## 43  PrivateNonprofit         355243
## 44            Public        1274362
## 45            Public       16185580
## 46            Public        3197808
## 47            Public       16470065
## 48            Public         831014
## 49            Public        9144625
## 50            Public        4991245
## 51  PrivateNonprofit        5113543
## 52  PrivateNonprofit        1323401
## 53  PrivateNonprofit        1803872
## 54            Public        4202264
## 55       Proprietary             NA
## 56       Proprietary          68022
## 57       Proprietary         439905
## 58       Proprietary         795882
## 59            Public        1825338
## 60       Proprietary         115914
## 61            Public        1233936
## 62            Public         425844
## 63       Proprietary        3399863
## 64       Proprietary         371619
## 65            Public       25195382
## 66            Public         231267
## 67       Proprietary         414703
## 68  PrivateNonprofit         864259
## 69       Proprietary          49455
## 70       Proprietary          52483
## 71       Proprietary         283712
## 72       Proprietary          57179
## 73       Proprietary          37891
## 74       Proprietary          24171
## 75       Proprietary           5600
## 76       Proprietary         614068
## 77       Proprietary         157442
## 78  PrivateNonprofit             NA
## 79       Proprietary          77251
## 80       Proprietary          19876
## 81       Proprietary          33499
## 82            Public         416588
## 83       Proprietary         660202
## 84       Proprietary         389641
## 85       Proprietary          62073
## 86  PrivateNonprofit         320716
## 87       Proprietary        1607727
## 88  PrivateNonprofit          19666
## 89       Proprietary         153268
## 90       Proprietary          24999
## 91       Proprietary          33375
## 92       Proprietary         234372
## 93       Proprietary          15832
## 94       Proprietary          52385
## 95       Proprietary          97427
## 96       Proprietary          11000
## 97  PrivateNonprofit        2188292
## 98  PrivateNonprofit        1275166
## 99  PrivateNonprofit        2245622
## 100           Public        2918768
## 101           Public        4478591
## 102           Public         513443
## 103 PrivateNonprofit        1033267
## 104 PrivateNonprofit        1126487
## 105 PrivateNonprofit        2430597
## 106           Public       11067030
## 107 PrivateNonprofit        1022398
## 108 PrivateNonprofit        4862738
## 109 PrivateNonprofit         740752
## 110           Public        4187127
## 111 PrivateNonprofit        2831224
## 112           Public       11941932
## 113 PrivateNonprofit        2369374
## 114 PrivateNonprofit        2903345
## 115      Proprietary        3444632
## 116           Public       15202571
## 117           Public       21935690
## 118           Public        9320944
## 119 PrivateNonprofit        1605771
## 120 PrivateNonprofit         631027
## 121           Public       20934687
## 122 PrivateNonprofit        2445616
## 123 PrivateNonprofit        2368719
## 124 PrivateNonprofit         745373
## 125 PrivateNonprofit         661229
## 126 PrivateNonprofit             NA
## 127 PrivateNonprofit        1505859
## 128           Public        6377457
## 129           Public        3737298
## 130           Public        1136560
## 131           Public       16648719
## 132 PrivateNonprofit           6500
## 133           Public        1129315
## 134           Public       16470730
## 135           Public          88910
## 136           Public        5115887
## 137           Public        2200558
## 138           Public         190780
## 139 PrivateNonprofit         846236
## 140           Public        9099782
## 141           Public       10312789
## 142 PrivateNonprofit        2478730
## 143 PrivateNonprofit        1881968
## 144 PrivateNonprofit         843015
## 145           Public        1850693
## 146           Public         135936
## 147      Proprietary        5401391
## 148           Public         320029
## 149           Public         814314
## 150 PrivateNonprofit        1341021
## 151           Public        1188958
## 152           Public        4234544
## 153           Public        1095893
## 154           Public        1398799
## 155      Proprietary        1414879
## 156      Proprietary          92271
## 157      Proprietary          14278
## 158           Public         782121
## 159 PrivateNonprofit         649045
## 160      Proprietary        9060778
## 161           Public             NA
## 162      Proprietary          94252
## 163      Proprietary         171366
## 164 PrivateNonprofit       53196359
## 165      Proprietary         207518
## 166      Proprietary          17462
## 167 PrivateNonprofit         279193
## 168 PrivateNonprofit         238185
## 169           Public          27000
## 170      Proprietary         464251
## 171      Proprietary        2238020
## 172      Proprietary        1500366
## 173 PrivateNonprofit          36530
## 174      Proprietary          51206
## 175      Proprietary        3121887
## 176      Proprietary        1309772
## 177      Proprietary         109107
## 178      Proprietary          33448
## 179 PrivateNonprofit        3271132
## 180      Proprietary         201463
## 181      Proprietary          18514
## 182 PrivateNonprofit         667711
## 183 PrivateNonprofit             NA
## 184      Proprietary         297444
## 185      Proprietary         582553
## 186      Proprietary         293631
## 187      Proprietary          66668
## 188      Proprietary         161528
## 189 PrivateNonprofit             NA
## 190      Proprietary         214304
## 191      Proprietary         162120
## 192 PrivateNonprofit             NA
## 193 PrivateNonprofit             NA
## 194           Public          24000
## 195      Proprietary         137505
## 196      Proprietary          23541
## 197      Proprietary          27380
## 198      Proprietary          23250
## 199      Proprietary          14600
## 200 PrivateNonprofit          21001
## 201      Proprietary         356307
## 202 PrivateNonprofit           6000
## 203      Proprietary             NA
## 204      Proprietary          70482
## 205      Proprietary             NA
## 206      Proprietary          41000
## 207 PrivateNonprofit             NA
## 208 PrivateNonprofit             NA
## 209      Proprietary          35337
## 210      Proprietary          60318
select(loans, State:SubsidizedDL)
##     State      School_Type SubsidizedDL
## 1      DC PrivateNonprofit      6213538
## 2      DC PrivateNonprofit      3619502
## 3      DC           Public      3850272
## 4      DC PrivateNonprofit       679602
## 5      DC PrivateNonprofit      7463145
## 6      DC PrivateNonprofit      3824260
## 7      DC PrivateNonprofit      9414766
## 8      DC      Proprietary     22490396
## 9      DC PrivateNonprofit      2522961
## 10     DC PrivateNonprofit           NA
## 11     DC PrivateNonprofit       356355
## 12     DC PrivateNonprofit           NA
## 13     DC PrivateNonprofit        40812
## 14     DC      Proprietary       416911
## 15     DC      Proprietary           NA
## 16     DC      Proprietary       107642
## 17     DC      Proprietary        84000
## 18     DC PrivateNonprofit           NA
## 19     DC PrivateNonprofit           NA
## 20     DC      Proprietary       340038
## 21     MD PrivateNonprofit       397211
## 22     MD           Public      1985362
## 23     MD           Public      3104310
## 24     MD           Public      5013413
## 25     MD           Public      6156842
## 26     MD           Public       950019
## 27     MD PrivateNonprofit       921184
## 28     MD PrivateNonprofit      1362268
## 29     MD           Public      4075560
## 30     MD           Public       785716
## 31     MD           Public      4266355
## 32     MD PrivateNonprofit      1426570
## 33     MD           Public      2173223
## 34     MD           Public       411657
## 35     MD PrivateNonprofit      1954513
## 36     MD PrivateNonprofit      3974615
## 37     MD PrivateNonprofit      4234858
## 38     MD PrivateNonprofit      2043470
## 39     MD           Public      8771888
## 40     MD PrivateNonprofit      1796922
## 41     MD           Public      4278085
## 42     MD           Public      6714119
## 43     MD PrivateNonprofit       589510
## 44     MD           Public      1199357
## 45     MD           Public     13557544
## 46     MD           Public      3480695
## 47     MD           Public     15673125
## 48     MD           Public       790624
## 49     MD           Public      7886884
## 50     MD           Public      4777700
## 51     MD PrivateNonprofit      4701919
## 52     MD PrivateNonprofit      1499542
## 53     MD PrivateNonprofit      1987977
## 54     MD           Public      5385806
## 55     MD      Proprietary           NA
## 56     MD      Proprietary        61250
## 57     MD      Proprietary       305942
## 58     MD      Proprietary       587391
## 59     MD           Public      1562603
## 60     MD      Proprietary       116268
## 61     MD           Public       730994
## 62     MD           Public       424451
## 63     MD      Proprietary      2279404
## 64     MD      Proprietary       268744
## 65     MD           Public     18151752
## 66     MD           Public       595801
## 67     MD      Proprietary       270825
## 68     MD PrivateNonprofit       361594
## 69     MD      Proprietary        31723
## 70     MD      Proprietary        50260
## 71     MD      Proprietary       274339
## 72     MD      Proprietary        59017
## 73     MD      Proprietary        33224
## 74     MD      Proprietary        20573
## 75     MD      Proprietary        12266
## 76     MD      Proprietary       420951
## 77     MD      Proprietary       107306
## 78     MD PrivateNonprofit           NA
## 79     MD      Proprietary        52234
## 80     MD      Proprietary        13973
## 81     MD      Proprietary        24249
## 82     MD           Public       207666
## 83     MD      Proprietary       400537
## 84     MD      Proprietary       231284
## 85     MD      Proprietary        46285
## 86     MD PrivateNonprofit       196352
## 87     MD      Proprietary      1072935
## 88     MD PrivateNonprofit        12832
## 89     MD      Proprietary       126302
## 90     MD      Proprietary        23861
## 91     MD      Proprietary        21875
## 92     MD      Proprietary       153776
## 93     MD      Proprietary         8165
## 94     MD      Proprietary        48698
## 95     MD      Proprietary        63574
## 96     MD      Proprietary         9750
## 97     VA PrivateNonprofit      1794119
## 98     VA PrivateNonprofit      1092293
## 99     VA PrivateNonprofit      2122312
## 100    VA           Public      2933520
## 101    VA           Public      3951490
## 102    VA           Public       487220
## 103    VA PrivateNonprofit      1226696
## 104    VA PrivateNonprofit      1140253
## 105    VA PrivateNonprofit      2181804
## 106    VA           Public     10448009
## 107    VA PrivateNonprofit      1047900
## 108    VA PrivateNonprofit      4499732
## 109    VA PrivateNonprofit       794850
## 110    VA           Public      3959652
## 111    VA PrivateNonprofit      2715188
## 112    VA           Public     10756253
## 113    VA PrivateNonprofit      2119592
## 114    VA PrivateNonprofit      2527085
## 115    VA      Proprietary      2293904
## 116    VA           Public     13782616
## 117    VA           Public     20240533
## 118    VA           Public      8414375
## 119    VA PrivateNonprofit      1543289
## 120    VA PrivateNonprofit       844514
## 121    VA           Public     21959084
## 122    VA PrivateNonprofit      2479693
## 123    VA PrivateNonprofit      2200957
## 124    VA PrivateNonprofit       832550
## 125    VA PrivateNonprofit       664838
## 126    VA PrivateNonprofit           NA
## 127    VA PrivateNonprofit      1974696
## 128    VA           Public      5873500
## 129    VA           Public      2719426
## 130    VA           Public      1280922
## 131    VA           Public     18050265
## 132    VA PrivateNonprofit        12750
## 133    VA           Public      1170083
## 134    VA           Public     16751772
## 135    VA           Public       443175
## 136    VA           Public      5030445
## 137    VA           Public      2140538
## 138    VA           Public       253477
## 139    VA PrivateNonprofit       672743
## 140    VA           Public      7802174
## 141    VA           Public      8349935
## 142    VA PrivateNonprofit      2284041
## 143    VA PrivateNonprofit      1811545
## 144    VA PrivateNonprofit       398089
## 145    VA           Public      1675718
## 146    VA           Public       159993
## 147    VA      Proprietary      3717804
## 148    VA           Public       273176
## 149    VA           Public      1011638
## 150    VA PrivateNonprofit      1133856
## 151    VA           Public      1122476
## 152    VA           Public      4249355
## 153    VA           Public       923958
## 154    VA           Public       909281
## 155    VA      Proprietary       938851
## 156    VA      Proprietary        59045
## 157    VA      Proprietary        12890
## 158    VA           Public       689524
## 159    VA PrivateNonprofit       557370
## 160    VA      Proprietary      7100695
## 161    VA           Public           NA
## 162    VA      Proprietary        70674
## 163    VA      Proprietary       140484
## 164    VA PrivateNonprofit     42052986
## 165    VA      Proprietary       133201
## 166    VA      Proprietary        15000
## 167    VA PrivateNonprofit       230382
## 168    VA PrivateNonprofit       203893
## 169    VA           Public        28000
## 170    VA      Proprietary       294696
## 171    VA      Proprietary      1474419
## 172    VA      Proprietary      1071599
## 173    VA PrivateNonprofit        35750
## 174    VA      Proprietary        48250
## 175    VA      Proprietary      2003400
## 176    VA      Proprietary       826924
## 177    VA      Proprietary        67166
## 178    VA      Proprietary        28174
## 179    VA PrivateNonprofit      2697919
## 180    VA      Proprietary       154745
## 181    VA      Proprietary        38111
## 182    VA PrivateNonprofit       505549
## 183    VA PrivateNonprofit           NA
## 184    VA      Proprietary       198041
## 185    VA      Proprietary       374092
## 186    VA      Proprietary       269314
## 187    VA      Proprietary        41964
## 188    VA      Proprietary       145437
## 189    VA PrivateNonprofit           NA
## 190    VA      Proprietary       167524
## 191    VA      Proprietary       111533
## 192    VA PrivateNonprofit           NA
## 193    VA PrivateNonprofit           NA
## 194    VA           Public        31423
## 195    VA      Proprietary        89968
## 196    VA      Proprietary        15959
## 197    VA      Proprietary        35580
## 198    VA      Proprietary        17495
## 199    VA      Proprietary        20105
## 200    VA PrivateNonprofit        12249
## 201    VA      Proprietary       222008
## 202    VA PrivateNonprofit         5147
## 203    VA      Proprietary           NA
## 204    VA      Proprietary        24936
## 205    VA      Proprietary        26250
## 206    VA      Proprietary        26250
## 207    VA PrivateNonprofit           NA
## 208    VA PrivateNonprofit           NA
## 209    VA      Proprietary        18541
## 210    VA      Proprietary        71149

distinct()

This function extracts the distinct rows. It is most useful when combined with select

distinct(loans)
##                                                                   School
## 1                                                    AMERICAN UNIVERSITY
## 2                                         CATHOLIC UNIVERSITY OF AMERICA
## 3                                 UNIVERSITY OF THE DISTRICT OF COLUMBIA
## 4                                                   GALLAUDET UNIVERSITY
## 5                                           GEORGE WASHINGTON UNIVERSITY
## 6                                                  GEORGETOWN UNIVERSITY
## 7                                                      HOWARD UNIVERSITY
## 8                                                     STRAYER UNIVERSITY
## 9                                                        TRINITY COLLEGE
## 10                                           WESLEY THEOLOGICAL SEMINARY
## 11                                    CORCORAN COLLEGE OF ART AND DESIGN
## 12                                            DOMINICAN HOUSE OF STUDIES
## 13                                NATIONAL CONSERVATORY OF DRAMATIC ARTS
## 14                                            CAREER TECHNICAL INSTITUTE
## 15                                                       POTOMAC COLLEGE
## 16                                              BENNETT CAREER INSTITUTE
## 17                                            TECHNICAL LEARNING CENTERS
## 18                                       INSTITUTE OF WORLD POLITICS THE
## 19  PONTIFICAL JOHN PAUL II INSTITUTE FOR STUDIES ON MARRIAGE AND FAMILY
## 20                                                       RADIANS COLLEGE
## 21                                                       CAPITOL COLLEGE
## 22                                          ALLEGANY COLLEGE OF MARYLAND
## 23                                        ANNE ARUNDEL COMMUNITY COLLEGE
## 24                                                BOWIE STATE UNIVERSITY
## 25                                 COMMUNITY COLLEGE OF BALTIMORE COUNTY
## 26                                          COLLEGE OF SOUTHERN MARYLAND
## 27                                     NOTRE DAME OF MARYLAND UNIVERSITY
## 28                                       WASHINGTON ADVENTIST UNIVERSITY
## 29                                               COPPIN STATE UNIVERSITY
## 30                                           FREDERICK COMMUNITY COLLEGE
## 31                                            FROSTBURG STATE UNIVERSITY
## 32                                                       GOUCHER COLLEGE
## 33                                          HAGERSTOWN COMMUNITY COLLEGE
## 34                                             HARFORD COMMUNITY COLLEGE
## 35                                                          HOOD COLLEGE
## 36                                              JOHNS HOPKINS UNIVERSITY
## 37                                            LOYOLA UNIVERSITY MARYLAND
## 38                                     MARYLAND INSTITUTE COLLEGE OF ART
## 39                                               MORGAN STATE UNIVERSITY
## 40                                          MOUNT SAINT MARYS UNIVERSITY
## 41                                      PRINCE GEORGES COMMUNITY COLLEGE
## 42                                                  SALISBURY UNIVERSITY
## 43                                                      ST JOHNS COLLEGE
## 44                                          ST MARYS COLLEGE OF MARYLAND
## 45                                                     TOWSON UNIVERSITY
## 46                                               UNIVERSITY OF BALTIMORE
## 47                                   UNIVERSITY OF MARYLAND COLLEGE PARK
## 48                                      UNIVERSITY OF MARYLAND BALTIMORE
## 49                              UNIVERSITY OF MARYLAND  BALTIMORE COUNTY
## 50                                 UNIVERSITY OF MARYLAND  EASTERN SHORE
## 51                                                  STEVENSON UNIVERSITY
## 52                                                    WASHINGTON COLLEGE
## 53                                                      MCDANIEL COLLEGE
## 54                                                    MONTGOMERY COLLEGE
## 55                                           INTERNATIONAL BEAUTY SCHOOL
## 56                                               DELMARVA BEAUTY ACADEMY
## 57                                           TESST COLLEGE OF TECHNOLOGY
## 58                                         LINCOLN COLLEGE OF TECHNOLOGY
## 59                                              HOWARD COMMUNITY COLLEGE
## 60                                                   AWARD BEAUTY SCHOOL
## 61                                                         CECIL COLLEGE
## 62                                                       GARRETT COLLEGE
## 63                                                      FORTIS INSTITUTE
## 64                                           TESST COLLEGE OF TECHNOLOGY
## 65                             UNIVERSITY OF MARYLAND UNIVERSITY COLLEGE
## 66                                              WORWIC COMMUNITY COLLEGE
## 67                                           TESST COLLEGE OF TECHNOLOGY
## 68                                             SOJOURNERDOUGLASS COLLEGE
## 69                                          COLORLAB ACADEMY OF HAIR THE
## 70                                      MARYLAND BEAUTY ACADEMY OF ESSEX
## 71                                                          HAIR ACADEMY
## 72                                              MONTGOMERY BEAUTY SCHOOL
## 73                                       BALTIMORE STUDIO OF HAIR DESIGN
## 74                  ROBERT PAUL ACADEMY OF COSMETOLOGY ARTS AND SCIENCES
## 75                                               MARYLAND BEAUTY ACADEMY
## 76                                          NORTH AMERICAN TRADE SCHOOLS
## 77                                                  LACADEMIE DE CUISINE
## 78                             MARYLAND UNIVERSITY OF INTEGRATIVE HEALTH
## 79                                          BLADES SCHOOL OF HAIR DESIGN
## 80                                              AARONS ACADEMY OF BEAUTY
## 81                                   AESTHETICS INSTITUTE OF COSMETOLOGY
## 82                                             CARROLL COMMUNITY COLLEGE
## 83                                               AMERICAN BEAUTY ACADEMY
## 84                                           BALTIMORE SCHOOL OF MASSAGE
## 85                                                       HAIR ACADEMY II
## 86                                                NATIONAL LABOR COLLEGE
## 87                                                       ALLSTATE CAREER
## 88                                            FAITH THEOLOGICAL SEMINARY
## 89                                              HAIR EXPRESSIONS ACADEMY
## 90                                       FREDERICK SCHOOL OF COSMETOLOGY
## 91           OMEGA STUDIOS SCHOOL OF APPLIED RECORDING ARTS AND SCIENCES
## 92                            TEMPLE THE: A PAUL MITCHELL PARTNER SCHOOL
## 93                                   HOLISTIC MASSAGE TRAINING INSTITUTE
## 94                                          ASPEN BEAUTY ACADEMY  LAUREL
## 95                                          INSTITUTE OF HEALTH SCIENCES
## 96                                                 HARMONS BEAUTY SCHOOL
## 97                                                    AVERETT UNIVERSITY
## 98                                                     BLUEFIELD COLLEGE
## 99                                                   BRIDGEWATER COLLEGE
## 100                                          COLLEGE OF WILLIAM AND MARY
## 101                                       CHRISTOPHER NEWPORT UNIVERSITY
## 102             RICHARD BLAND COLLEGE OF THE COLLEGE OF WILLIAM AND MARY
## 103                                         EASTERN MENNONITE UNIVERSITY
## 104                                              EMORY AND HENRY COLLEGE
## 105                                                       FERRUM COLLEGE
## 106                                          TIDEWATER COMMUNITY COLLEGE
## 107                                               HAMPDEN SYDNEY COLLEGE
## 108                                                   HAMPTON UNIVERSITY
## 109                                                   HOLLINS UNIVERSITY
## 110                                                  LONGWOOD UNIVERSITY
## 111                                                    LYNCHBURG COLLEGE
## 112                                             JAMES MADISON UNIVERSITY
## 113                                                 MARY BALDWIN COLLEGE
## 114                                                 MARYMOUNT UNIVERSITY
## 115                                          AMERICANNATIONAL UNIVERSITY
## 116                                  NORTHERN VIRGINIA COMMUNITY COLLEGE
## 117                                              OLD DOMINION UNIVERSITY
## 118                                                   RADFORD UNIVERSITY
## 119                                                RANDOLPHMACON COLLEGE
## 120                                                     RANDOLPH COLLEGE
## 121                                     VIRGINIA COMMONWEALTH UNIVERSITY
## 122                                                      ROANOKE COLLEGE
## 123                                                SHENANDOAH UNIVERSITY
## 124                                         SOUTHERN VIRGINIA UNIVERSITY
## 125                                                  SWEET BRIAR COLLEGE
## 126                                          UNION PRESBYTERIAN SEMINARY
## 127                                               UNIVERSITY OF RICHMOND
## 128                                               UNIVERSITY OF VIRGINIA
## 129                                        UNIVERSITY OF MARY WASHINGTON
## 130                          UNIVERSITY OF VIRGINIAS COLLEGE AT WISE THE
## 131                                              GEORGE MASON UNIVERSITY
## 132                                           VIRGINIA INTERMONT COLLEGE
## 133                                          VIRGINIA MILITARY INSTITUTE
## 134                  VIRGINIA POLYTECHNIC INSTITUTE AND STATE UNIVERSITY
## 135                                           DANVILLE COMMUNITY COLLEGE
## 136                                J SARGEANT REYNOLDS COMMUNITY COLLEGE
## 137                                   VIRGINIA WESTERN COMMUNITY COLLEGE
## 138                                         WYTHEVILLE COMMUNITY COLLEGE
## 139                                     VIRGINIA UNIVERSITY OF LYNCHBURG
## 140                                            VIRGINIA STATE UNIVERSITY
## 141                                             NORFOLK STATE UNIVERSITY
## 142                                            VIRGINIA UNION UNIVERSITY
## 143                                            VIRGINIA WESLEYAN COLLEGE
## 144                                        WASHINGTON AND LEE UNIVERSITY
## 145                                         JOHN TYLER COMMUNITY COLLEGE
## 146                                   CENTRAL VIRGINIA COMMUNITY COLLEGE
## 147                                        MILLERMOTTE TECHNICAL COLLEGE
## 148                                 DABNEY S LANCASTER COMMUNITY COLLEGE
## 149                                          NEW RIVER COMMUNITY COLLEGE
## 150                                 JEFFERSON COLLEGE OF HEALTH SCIENCES
## 151                                         BLUE RIDGE COMMUNITY COLLEGE
## 152                                      THOMAS NELSON COMMUNITY COLLEGE
## 153                                       LORD FAIRFAX COMMUNITY COLLEGE
## 154                                           GERMANNA COMMUNITY COLLEGE
## 155                                                      EVEREST COLLEGE
## 156                                                 SANFORDBROWN COLLEGE
## 157                                       STAUNTON SCHOOL OF COSMETOLOGY
## 158                                  PIEDMONT VIRGINIA COMMUNITY COLLEGE
## 159                              BON SECOURS MEMORIAL COLLEGE OF NURSING
## 160                                                      ECPI UNIVERSITY
## 161                                      EASTERN VIRGINIA MEDICAL SCHOOL
## 162                           SYLVAIN MELLOUL INTERNATIONAL HAIR ACADEMY
## 163               SOUTHSIDE REGIONAL MEDICAL CENTER PROFESSIONAL SCHOOLS
## 164                                                   LIBERTY UNIVERSITY
## 165                                          WARDS CORNER BEAUTY ACADEMY
## 166        DANVILLE REGIONAL MEDICAL CENTER SCHOOL OF HEALTH PROFESSIONS
## 167                                   RIVERSIDE SCHOOL OF HEALTH CAREERS
## 168                                            CENTRA COLLEGE OF NURSING
## 169       HENRICO COUNTYSAINT MARYS HOSPITAL SCHOOL OF PRACTICAL NURSING
## 170                                                       TIDEWATER TECH
## 171                                                      CENTURA COLLEGE
## 172                                                       FORTIS COLLEGE
## 173              BON SECOURS ST MARYS HOSPITAL SCHOOL OF MEDICAL IMAGING
## 174                                               SUFFOLK BEAUTY ACADEMY
## 175                                                 STRATFORD UNIVERSITY
## 176                                                      MEDTECH COLLEGE
## 177                            GRAHAM WEBB INTERNATIONAL ACADEMY OF HAIR
## 178                                     BAR PALMA BEAUTY CAREERS ACADEMY
## 179                                                    REGENT UNIVERSITY
## 180                                                      SKYLINE COLLEGE
## 181                                           SPRINGFIELD BEAUTY ACADEMY
## 182                                   SENTARA COLLEGE OF HEALTH SCIENCES
## 183                             BAPTIST THEOLOGICAL SEMINARY AT RICHMOND
## 184                                    AVIATION INSTITUTE OF MAINTENANCE
## 185                                                      CENTURA COLLEGE
## 186                                        ADVANCED TECHNOLOGY INSTITUTE
## 187                                           VIRGINIA SCHOOL OF MASSAGE
## 188                                                                 RSHT
## 189                                            APPALACHIAN SCHOOL OF LAW
## 190                              RUDY AND KELLY ACADEMY OF HAIR ANDNAILS
## 191                                            CAREER TRAINING SOLUTIONS
## 192                  EDWARD VIA VIRGINIA COLLEGE OF OSTEOPATHIC MEDICINE
## 193                             INSTITUTE FOR THE PSYCHOLOGICAL SCIENCES
## 194                                 CULPEPER COSMETOLOGY TRAINING CENTER
## 195                                    AVIATION INSTITUTE OF MAINTENANCE
## 196                                                  AVI CAREER TRAINING
## 197                          UNIVERSITY OF MANAGEMENT AND TECHNOLOGY THE
## 198                                       DOMINION SCHOOL OF HAIR DESIGN
## 199                                                     COLUMBIA COLLEGE
## 200                                  CAYCE/REILLY SCHOOL OF MASSOTHERAPY
## 201                                                GLOBAL HEALTH COLLEGE
## 202                                                       BETHEL COLLEGE
## 203                              INSTITUTE OF ADVANCED MEDICAL ESTHETICS
## 204                      NORTHERN VIRGINIA SCHOOL OF THERAPEUTIC MASSAGE
## 205                                  COSMOPOLITAN BEAUTY AND TECH SCHOOL
## 206                           TOMORROWS IMAGE BARBER ACADEMY OF VIRGINIA
## 207                                      APPALACHIAN COLLEGE OF PHARMACY
## 208                            VIRGINIA TECH CARILION SCHOOL OF MEDICINE
## 209                                    CHRYSM INSTITUTE OF ESTHETICS THE
## 210                      STANDARD HEALTHCARE SERVICES COLLEGE OF NURSING
##     State      School_Type SubsidizedDL UNSubsidizedDL
## 1      DC PrivateNonprofit      6213538        4517728
## 2      DC PrivateNonprofit      3619502        3520966
## 3      DC           Public      3850272        4248284
## 4      DC PrivateNonprofit       679602         561785
## 5      DC PrivateNonprofit      7463145        5913027
## 6      DC PrivateNonprofit      3824260        1318290
## 7      DC PrivateNonprofit      9414766        9021712
## 8      DC      Proprietary     22490396       34840102
## 9      DC PrivateNonprofit      2522961        2850888
## 10     DC PrivateNonprofit           NA          22250
## 11     DC PrivateNonprofit       356355         360715
## 12     DC PrivateNonprofit           NA             NA
## 13     DC PrivateNonprofit        40812          21963
## 14     DC      Proprietary       416911         685909
## 15     DC      Proprietary           NA             NA
## 16     DC      Proprietary       107642          88632
## 17     DC      Proprietary        84000         128000
## 18     DC PrivateNonprofit           NA             NA
## 19     DC PrivateNonprofit           NA             NA
## 20     DC      Proprietary       340038         514081
## 21     MD PrivateNonprofit       397211         405964
## 22     MD           Public      1985362        2200457
## 23     MD           Public      3104310        3299252
## 24     MD           Public      5013413        5617903
## 25     MD           Public      6156842        5663646
## 26     MD           Public       950019        1387749
## 27     MD PrivateNonprofit       921184        1231367
## 28     MD PrivateNonprofit      1362268        1768461
## 29     MD           Public      4075560        2612912
## 30     MD           Public       785716         946044
## 31     MD           Public      4266355        4914444
## 32     MD PrivateNonprofit      1426570        1079658
## 33     MD           Public      2173223        1658469
## 34     MD           Public       411657         499914
## 35     MD PrivateNonprofit      1954513        1812060
## 36     MD PrivateNonprofit      3974615        2536180
## 37     MD PrivateNonprofit      4234858        2986646
## 38     MD PrivateNonprofit      2043470        1607827
## 39     MD           Public      8771888        9752653
## 40     MD PrivateNonprofit      1796922        1705136
## 41     MD           Public      4278085        1571303
## 42     MD           Public      6714119        7547759
## 43     MD PrivateNonprofit       589510         355243
## 44     MD           Public      1199357        1274362
## 45     MD           Public     13557544       16185580
## 46     MD           Public      3480695        3197808
## 47     MD           Public     15673125       16470065
## 48     MD           Public       790624         831014
## 49     MD           Public      7886884        9144625
## 50     MD           Public      4777700        4991245
## 51     MD PrivateNonprofit      4701919        5113543
## 52     MD PrivateNonprofit      1499542        1323401
## 53     MD PrivateNonprofit      1987977        1803872
## 54     MD           Public      5385806        4202264
## 55     MD      Proprietary           NA             NA
## 56     MD      Proprietary        61250          68022
## 57     MD      Proprietary       305942         439905
## 58     MD      Proprietary       587391         795882
## 59     MD           Public      1562603        1825338
## 60     MD      Proprietary       116268         115914
## 61     MD           Public       730994        1233936
## 62     MD           Public       424451         425844
## 63     MD      Proprietary      2279404        3399863
## 64     MD      Proprietary       268744         371619
## 65     MD           Public     18151752       25195382
## 66     MD           Public       595801         231267
## 67     MD      Proprietary       270825         414703
## 68     MD PrivateNonprofit       361594         864259
## 69     MD      Proprietary        31723          49455
## 70     MD      Proprietary        50260          52483
## 71     MD      Proprietary       274339         283712
## 72     MD      Proprietary        59017          57179
## 73     MD      Proprietary        33224          37891
## 74     MD      Proprietary        20573          24171
## 75     MD      Proprietary        12266           5600
## 76     MD      Proprietary       420951         614068
## 77     MD      Proprietary       107306         157442
## 78     MD PrivateNonprofit           NA             NA
## 79     MD      Proprietary        52234          77251
## 80     MD      Proprietary        13973          19876
## 81     MD      Proprietary        24249          33499
## 82     MD           Public       207666         416588
## 83     MD      Proprietary       400537         660202
## 84     MD      Proprietary       231284         389641
## 85     MD      Proprietary        46285          62073
## 86     MD PrivateNonprofit       196352         320716
## 87     MD      Proprietary      1072935        1607727
## 88     MD PrivateNonprofit        12832          19666
## 89     MD      Proprietary       126302         153268
## 90     MD      Proprietary        23861          24999
## 91     MD      Proprietary        21875          33375
## 92     MD      Proprietary       153776         234372
## 93     MD      Proprietary         8165          15832
## 94     MD      Proprietary        48698          52385
## 95     MD      Proprietary        63574          97427
## 96     MD      Proprietary         9750          11000
## 97     VA PrivateNonprofit      1794119        2188292
## 98     VA PrivateNonprofit      1092293        1275166
## 99     VA PrivateNonprofit      2122312        2245622
## 100    VA           Public      2933520        2918768
## 101    VA           Public      3951490        4478591
## 102    VA           Public       487220         513443
## 103    VA PrivateNonprofit      1226696        1033267
## 104    VA PrivateNonprofit      1140253        1126487
## 105    VA PrivateNonprofit      2181804        2430597
## 106    VA           Public     10448009       11067030
## 107    VA PrivateNonprofit      1047900        1022398
## 108    VA PrivateNonprofit      4499732        4862738
## 109    VA PrivateNonprofit       794850         740752
## 110    VA           Public      3959652        4187127
## 111    VA PrivateNonprofit      2715188        2831224
## 112    VA           Public     10756253       11941932
## 113    VA PrivateNonprofit      2119592        2369374
## 114    VA PrivateNonprofit      2527085        2903345
## 115    VA      Proprietary      2293904        3444632
## 116    VA           Public     13782616       15202571
## 117    VA           Public     20240533       21935690
## 118    VA           Public      8414375        9320944
## 119    VA PrivateNonprofit      1543289        1605771
## 120    VA PrivateNonprofit       844514         631027
## 121    VA           Public     21959084       20934687
## 122    VA PrivateNonprofit      2479693        2445616
## 123    VA PrivateNonprofit      2200957        2368719
## 124    VA PrivateNonprofit       832550         745373
## 125    VA PrivateNonprofit       664838         661229
## 126    VA PrivateNonprofit           NA             NA
## 127    VA PrivateNonprofit      1974696        1505859
## 128    VA           Public      5873500        6377457
## 129    VA           Public      2719426        3737298
## 130    VA           Public      1280922        1136560
## 131    VA           Public     18050265       16648719
## 132    VA PrivateNonprofit        12750           6500
## 133    VA           Public      1170083        1129315
## 134    VA           Public     16751772       16470730
## 135    VA           Public       443175          88910
## 136    VA           Public      5030445        5115887
## 137    VA           Public      2140538        2200558
## 138    VA           Public       253477         190780
## 139    VA PrivateNonprofit       672743         846236
## 140    VA           Public      7802174        9099782
## 141    VA           Public      8349935       10312789
## 142    VA PrivateNonprofit      2284041        2478730
## 143    VA PrivateNonprofit      1811545        1881968
## 144    VA PrivateNonprofit       398089         843015
## 145    VA           Public      1675718        1850693
## 146    VA           Public       159993         135936
## 147    VA      Proprietary      3717804        5401391
## 148    VA           Public       273176         320029
## 149    VA           Public      1011638         814314
## 150    VA PrivateNonprofit      1133856        1341021
## 151    VA           Public      1122476        1188958
## 152    VA           Public      4249355        4234544
## 153    VA           Public       923958        1095893
## 154    VA           Public       909281        1398799
## 155    VA      Proprietary       938851        1414879
## 156    VA      Proprietary        59045          92271
## 157    VA      Proprietary        12890          14278
## 158    VA           Public       689524         782121
## 159    VA PrivateNonprofit       557370         649045
## 160    VA      Proprietary      7100695        9060778
## 161    VA           Public           NA             NA
## 162    VA      Proprietary        70674          94252
## 163    VA      Proprietary       140484         171366
## 164    VA PrivateNonprofit     42052986       53196359
## 165    VA      Proprietary       133201         207518
## 166    VA      Proprietary        15000          17462
## 167    VA PrivateNonprofit       230382         279193
## 168    VA PrivateNonprofit       203893         238185
## 169    VA           Public        28000          27000
## 170    VA      Proprietary       294696         464251
## 171    VA      Proprietary      1474419        2238020
## 172    VA      Proprietary      1071599        1500366
## 173    VA PrivateNonprofit        35750          36530
## 174    VA      Proprietary        48250          51206
## 175    VA      Proprietary      2003400        3121887
## 176    VA      Proprietary       826924        1309772
## 177    VA      Proprietary        67166         109107
## 178    VA      Proprietary        28174          33448
## 179    VA PrivateNonprofit      2697919        3271132
## 180    VA      Proprietary       154745         201463
## 181    VA      Proprietary        38111          18514
## 182    VA PrivateNonprofit       505549         667711
## 183    VA PrivateNonprofit           NA             NA
## 184    VA      Proprietary       198041         297444
## 185    VA      Proprietary       374092         582553
## 186    VA      Proprietary       269314         293631
## 187    VA      Proprietary        41964          66668
## 188    VA      Proprietary       145437         161528
## 189    VA PrivateNonprofit           NA             NA
## 190    VA      Proprietary       167524         214304
## 191    VA      Proprietary       111533         162120
## 192    VA PrivateNonprofit           NA             NA
## 193    VA PrivateNonprofit           NA             NA
## 194    VA           Public        31423          24000
## 195    VA      Proprietary        89968         137505
## 196    VA      Proprietary        15959          23541
## 197    VA      Proprietary        35580          27380
## 198    VA      Proprietary        17495          23250
## 199    VA      Proprietary        20105          14600
## 200    VA PrivateNonprofit        12249          21001
## 201    VA      Proprietary       222008         356307
## 202    VA PrivateNonprofit         5147           6000
## 203    VA      Proprietary           NA             NA
## 204    VA      Proprietary        24936          70482
## 205    VA      Proprietary        26250             NA
## 206    VA      Proprietary        26250          41000
## 207    VA PrivateNonprofit           NA             NA
## 208    VA PrivateNonprofit           NA             NA
## 209    VA      Proprietary        18541          35337
## 210    VA      Proprietary        71149          60318
distinct(select(loans, State, School_Type))
##   State      School_Type
## 1    DC PrivateNonprofit
## 2    DC           Public
## 3    DC      Proprietary
## 4    MD PrivateNonprofit
## 5    MD           Public
## 6    MD      Proprietary
## 7    VA PrivateNonprofit
## 8    VA           Public
## 9    VA      Proprietary

mutate()

Adds new columns that are some function of existing columns

mutate(loans, Total_Loans = SubsidizedDL + UNSubsidizedDL)
##                                                                   School
## 1                                                    AMERICAN UNIVERSITY
## 2                                         CATHOLIC UNIVERSITY OF AMERICA
## 3                                 UNIVERSITY OF THE DISTRICT OF COLUMBIA
## 4                                                   GALLAUDET UNIVERSITY
## 5                                           GEORGE WASHINGTON UNIVERSITY
## 6                                                  GEORGETOWN UNIVERSITY
## 7                                                      HOWARD UNIVERSITY
## 8                                                     STRAYER UNIVERSITY
## 9                                                        TRINITY COLLEGE
## 10                                           WESLEY THEOLOGICAL SEMINARY
## 11                                    CORCORAN COLLEGE OF ART AND DESIGN
## 12                                            DOMINICAN HOUSE OF STUDIES
## 13                                NATIONAL CONSERVATORY OF DRAMATIC ARTS
## 14                                            CAREER TECHNICAL INSTITUTE
## 15                                                       POTOMAC COLLEGE
## 16                                              BENNETT CAREER INSTITUTE
## 17                                            TECHNICAL LEARNING CENTERS
## 18                                       INSTITUTE OF WORLD POLITICS THE
## 19  PONTIFICAL JOHN PAUL II INSTITUTE FOR STUDIES ON MARRIAGE AND FAMILY
## 20                                                       RADIANS COLLEGE
## 21                                                       CAPITOL COLLEGE
## 22                                          ALLEGANY COLLEGE OF MARYLAND
## 23                                        ANNE ARUNDEL COMMUNITY COLLEGE
## 24                                                BOWIE STATE UNIVERSITY
## 25                                 COMMUNITY COLLEGE OF BALTIMORE COUNTY
## 26                                          COLLEGE OF SOUTHERN MARYLAND
## 27                                     NOTRE DAME OF MARYLAND UNIVERSITY
## 28                                       WASHINGTON ADVENTIST UNIVERSITY
## 29                                               COPPIN STATE UNIVERSITY
## 30                                           FREDERICK COMMUNITY COLLEGE
## 31                                            FROSTBURG STATE UNIVERSITY
## 32                                                       GOUCHER COLLEGE
## 33                                          HAGERSTOWN COMMUNITY COLLEGE
## 34                                             HARFORD COMMUNITY COLLEGE
## 35                                                          HOOD COLLEGE
## 36                                              JOHNS HOPKINS UNIVERSITY
## 37                                            LOYOLA UNIVERSITY MARYLAND
## 38                                     MARYLAND INSTITUTE COLLEGE OF ART
## 39                                               MORGAN STATE UNIVERSITY
## 40                                          MOUNT SAINT MARYS UNIVERSITY
## 41                                      PRINCE GEORGES COMMUNITY COLLEGE
## 42                                                  SALISBURY UNIVERSITY
## 43                                                      ST JOHNS COLLEGE
## 44                                          ST MARYS COLLEGE OF MARYLAND
## 45                                                     TOWSON UNIVERSITY
## 46                                               UNIVERSITY OF BALTIMORE
## 47                                   UNIVERSITY OF MARYLAND COLLEGE PARK
## 48                                      UNIVERSITY OF MARYLAND BALTIMORE
## 49                              UNIVERSITY OF MARYLAND  BALTIMORE COUNTY
## 50                                 UNIVERSITY OF MARYLAND  EASTERN SHORE
## 51                                                  STEVENSON UNIVERSITY
## 52                                                    WASHINGTON COLLEGE
## 53                                                      MCDANIEL COLLEGE
## 54                                                    MONTGOMERY COLLEGE
## 55                                           INTERNATIONAL BEAUTY SCHOOL
## 56                                               DELMARVA BEAUTY ACADEMY
## 57                                           TESST COLLEGE OF TECHNOLOGY
## 58                                         LINCOLN COLLEGE OF TECHNOLOGY
## 59                                              HOWARD COMMUNITY COLLEGE
## 60                                                   AWARD BEAUTY SCHOOL
## 61                                                         CECIL COLLEGE
## 62                                                       GARRETT COLLEGE
## 63                                                      FORTIS INSTITUTE
## 64                                           TESST COLLEGE OF TECHNOLOGY
## 65                             UNIVERSITY OF MARYLAND UNIVERSITY COLLEGE
## 66                                              WORWIC COMMUNITY COLLEGE
## 67                                           TESST COLLEGE OF TECHNOLOGY
## 68                                             SOJOURNERDOUGLASS COLLEGE
## 69                                          COLORLAB ACADEMY OF HAIR THE
## 70                                      MARYLAND BEAUTY ACADEMY OF ESSEX
## 71                                                          HAIR ACADEMY
## 72                                              MONTGOMERY BEAUTY SCHOOL
## 73                                       BALTIMORE STUDIO OF HAIR DESIGN
## 74                  ROBERT PAUL ACADEMY OF COSMETOLOGY ARTS AND SCIENCES
## 75                                               MARYLAND BEAUTY ACADEMY
## 76                                          NORTH AMERICAN TRADE SCHOOLS
## 77                                                  LACADEMIE DE CUISINE
## 78                             MARYLAND UNIVERSITY OF INTEGRATIVE HEALTH
## 79                                          BLADES SCHOOL OF HAIR DESIGN
## 80                                              AARONS ACADEMY OF BEAUTY
## 81                                   AESTHETICS INSTITUTE OF COSMETOLOGY
## 82                                             CARROLL COMMUNITY COLLEGE
## 83                                               AMERICAN BEAUTY ACADEMY
## 84                                           BALTIMORE SCHOOL OF MASSAGE
## 85                                                       HAIR ACADEMY II
## 86                                                NATIONAL LABOR COLLEGE
## 87                                                       ALLSTATE CAREER
## 88                                            FAITH THEOLOGICAL SEMINARY
## 89                                              HAIR EXPRESSIONS ACADEMY
## 90                                       FREDERICK SCHOOL OF COSMETOLOGY
## 91           OMEGA STUDIOS SCHOOL OF APPLIED RECORDING ARTS AND SCIENCES
## 92                            TEMPLE THE: A PAUL MITCHELL PARTNER SCHOOL
## 93                                   HOLISTIC MASSAGE TRAINING INSTITUTE
## 94                                          ASPEN BEAUTY ACADEMY  LAUREL
## 95                                          INSTITUTE OF HEALTH SCIENCES
## 96                                                 HARMONS BEAUTY SCHOOL
## 97                                                    AVERETT UNIVERSITY
## 98                                                     BLUEFIELD COLLEGE
## 99                                                   BRIDGEWATER COLLEGE
## 100                                          COLLEGE OF WILLIAM AND MARY
## 101                                       CHRISTOPHER NEWPORT UNIVERSITY
## 102             RICHARD BLAND COLLEGE OF THE COLLEGE OF WILLIAM AND MARY
## 103                                         EASTERN MENNONITE UNIVERSITY
## 104                                              EMORY AND HENRY COLLEGE
## 105                                                       FERRUM COLLEGE
## 106                                          TIDEWATER COMMUNITY COLLEGE
## 107                                               HAMPDEN SYDNEY COLLEGE
## 108                                                   HAMPTON UNIVERSITY
## 109                                                   HOLLINS UNIVERSITY
## 110                                                  LONGWOOD UNIVERSITY
## 111                                                    LYNCHBURG COLLEGE
## 112                                             JAMES MADISON UNIVERSITY
## 113                                                 MARY BALDWIN COLLEGE
## 114                                                 MARYMOUNT UNIVERSITY
## 115                                          AMERICANNATIONAL UNIVERSITY
## 116                                  NORTHERN VIRGINIA COMMUNITY COLLEGE
## 117                                              OLD DOMINION UNIVERSITY
## 118                                                   RADFORD UNIVERSITY
## 119                                                RANDOLPHMACON COLLEGE
## 120                                                     RANDOLPH COLLEGE
## 121                                     VIRGINIA COMMONWEALTH UNIVERSITY
## 122                                                      ROANOKE COLLEGE
## 123                                                SHENANDOAH UNIVERSITY
## 124                                         SOUTHERN VIRGINIA UNIVERSITY
## 125                                                  SWEET BRIAR COLLEGE
## 126                                          UNION PRESBYTERIAN SEMINARY
## 127                                               UNIVERSITY OF RICHMOND
## 128                                               UNIVERSITY OF VIRGINIA
## 129                                        UNIVERSITY OF MARY WASHINGTON
## 130                          UNIVERSITY OF VIRGINIAS COLLEGE AT WISE THE
## 131                                              GEORGE MASON UNIVERSITY
## 132                                           VIRGINIA INTERMONT COLLEGE
## 133                                          VIRGINIA MILITARY INSTITUTE
## 134                  VIRGINIA POLYTECHNIC INSTITUTE AND STATE UNIVERSITY
## 135                                           DANVILLE COMMUNITY COLLEGE
## 136                                J SARGEANT REYNOLDS COMMUNITY COLLEGE
## 137                                   VIRGINIA WESTERN COMMUNITY COLLEGE
## 138                                         WYTHEVILLE COMMUNITY COLLEGE
## 139                                     VIRGINIA UNIVERSITY OF LYNCHBURG
## 140                                            VIRGINIA STATE UNIVERSITY
## 141                                             NORFOLK STATE UNIVERSITY
## 142                                            VIRGINIA UNION UNIVERSITY
## 143                                            VIRGINIA WESLEYAN COLLEGE
## 144                                        WASHINGTON AND LEE UNIVERSITY
## 145                                         JOHN TYLER COMMUNITY COLLEGE
## 146                                   CENTRAL VIRGINIA COMMUNITY COLLEGE
## 147                                        MILLERMOTTE TECHNICAL COLLEGE
## 148                                 DABNEY S LANCASTER COMMUNITY COLLEGE
## 149                                          NEW RIVER COMMUNITY COLLEGE
## 150                                 JEFFERSON COLLEGE OF HEALTH SCIENCES
## 151                                         BLUE RIDGE COMMUNITY COLLEGE
## 152                                      THOMAS NELSON COMMUNITY COLLEGE
## 153                                       LORD FAIRFAX COMMUNITY COLLEGE
## 154                                           GERMANNA COMMUNITY COLLEGE
## 155                                                      EVEREST COLLEGE
## 156                                                 SANFORDBROWN COLLEGE
## 157                                       STAUNTON SCHOOL OF COSMETOLOGY
## 158                                  PIEDMONT VIRGINIA COMMUNITY COLLEGE
## 159                              BON SECOURS MEMORIAL COLLEGE OF NURSING
## 160                                                      ECPI UNIVERSITY
## 161                                      EASTERN VIRGINIA MEDICAL SCHOOL
## 162                           SYLVAIN MELLOUL INTERNATIONAL HAIR ACADEMY
## 163               SOUTHSIDE REGIONAL MEDICAL CENTER PROFESSIONAL SCHOOLS
## 164                                                   LIBERTY UNIVERSITY
## 165                                          WARDS CORNER BEAUTY ACADEMY
## 166        DANVILLE REGIONAL MEDICAL CENTER SCHOOL OF HEALTH PROFESSIONS
## 167                                   RIVERSIDE SCHOOL OF HEALTH CAREERS
## 168                                            CENTRA COLLEGE OF NURSING
## 169       HENRICO COUNTYSAINT MARYS HOSPITAL SCHOOL OF PRACTICAL NURSING
## 170                                                       TIDEWATER TECH
## 171                                                      CENTURA COLLEGE
## 172                                                       FORTIS COLLEGE
## 173              BON SECOURS ST MARYS HOSPITAL SCHOOL OF MEDICAL IMAGING
## 174                                               SUFFOLK BEAUTY ACADEMY
## 175                                                 STRATFORD UNIVERSITY
## 176                                                      MEDTECH COLLEGE
## 177                            GRAHAM WEBB INTERNATIONAL ACADEMY OF HAIR
## 178                                     BAR PALMA BEAUTY CAREERS ACADEMY
## 179                                                    REGENT UNIVERSITY
## 180                                                      SKYLINE COLLEGE
## 181                                           SPRINGFIELD BEAUTY ACADEMY
## 182                                   SENTARA COLLEGE OF HEALTH SCIENCES
## 183                             BAPTIST THEOLOGICAL SEMINARY AT RICHMOND
## 184                                    AVIATION INSTITUTE OF MAINTENANCE
## 185                                                      CENTURA COLLEGE
## 186                                        ADVANCED TECHNOLOGY INSTITUTE
## 187                                           VIRGINIA SCHOOL OF MASSAGE
## 188                                                                 RSHT
## 189                                            APPALACHIAN SCHOOL OF LAW
## 190                              RUDY AND KELLY ACADEMY OF HAIR ANDNAILS
## 191                                            CAREER TRAINING SOLUTIONS
## 192                  EDWARD VIA VIRGINIA COLLEGE OF OSTEOPATHIC MEDICINE
## 193                             INSTITUTE FOR THE PSYCHOLOGICAL SCIENCES
## 194                                 CULPEPER COSMETOLOGY TRAINING CENTER
## 195                                    AVIATION INSTITUTE OF MAINTENANCE
## 196                                                  AVI CAREER TRAINING
## 197                          UNIVERSITY OF MANAGEMENT AND TECHNOLOGY THE
## 198                                       DOMINION SCHOOL OF HAIR DESIGN
## 199                                                     COLUMBIA COLLEGE
## 200                                  CAYCE/REILLY SCHOOL OF MASSOTHERAPY
## 201                                                GLOBAL HEALTH COLLEGE
## 202                                                       BETHEL COLLEGE
## 203                              INSTITUTE OF ADVANCED MEDICAL ESTHETICS
## 204                      NORTHERN VIRGINIA SCHOOL OF THERAPEUTIC MASSAGE
## 205                                  COSMOPOLITAN BEAUTY AND TECH SCHOOL
## 206                           TOMORROWS IMAGE BARBER ACADEMY OF VIRGINIA
## 207                                      APPALACHIAN COLLEGE OF PHARMACY
## 208                            VIRGINIA TECH CARILION SCHOOL OF MEDICINE
## 209                                    CHRYSM INSTITUTE OF ESTHETICS THE
## 210                      STANDARD HEALTHCARE SERVICES COLLEGE OF NURSING
##     State      School_Type SubsidizedDL UNSubsidizedDL Total_Loans
## 1      DC PrivateNonprofit      6213538        4517728    10731266
## 2      DC PrivateNonprofit      3619502        3520966     7140468
## 3      DC           Public      3850272        4248284     8098556
## 4      DC PrivateNonprofit       679602         561785     1241387
## 5      DC PrivateNonprofit      7463145        5913027    13376172
## 6      DC PrivateNonprofit      3824260        1318290     5142550
## 7      DC PrivateNonprofit      9414766        9021712    18436478
## 8      DC      Proprietary     22490396       34840102    57330498
## 9      DC PrivateNonprofit      2522961        2850888     5373849
## 10     DC PrivateNonprofit           NA          22250          NA
## 11     DC PrivateNonprofit       356355         360715      717070
## 12     DC PrivateNonprofit           NA             NA          NA
## 13     DC PrivateNonprofit        40812          21963       62775
## 14     DC      Proprietary       416911         685909     1102820
## 15     DC      Proprietary           NA             NA          NA
## 16     DC      Proprietary       107642          88632      196274
## 17     DC      Proprietary        84000         128000      212000
## 18     DC PrivateNonprofit           NA             NA          NA
## 19     DC PrivateNonprofit           NA             NA          NA
## 20     DC      Proprietary       340038         514081      854119
## 21     MD PrivateNonprofit       397211         405964      803175
## 22     MD           Public      1985362        2200457     4185819
## 23     MD           Public      3104310        3299252     6403562
## 24     MD           Public      5013413        5617903    10631316
## 25     MD           Public      6156842        5663646    11820488
## 26     MD           Public       950019        1387749     2337768
## 27     MD PrivateNonprofit       921184        1231367     2152551
## 28     MD PrivateNonprofit      1362268        1768461     3130729
## 29     MD           Public      4075560        2612912     6688472
## 30     MD           Public       785716         946044     1731760
## 31     MD           Public      4266355        4914444     9180799
## 32     MD PrivateNonprofit      1426570        1079658     2506228
## 33     MD           Public      2173223        1658469     3831692
## 34     MD           Public       411657         499914      911571
## 35     MD PrivateNonprofit      1954513        1812060     3766573
## 36     MD PrivateNonprofit      3974615        2536180     6510795
## 37     MD PrivateNonprofit      4234858        2986646     7221504
## 38     MD PrivateNonprofit      2043470        1607827     3651297
## 39     MD           Public      8771888        9752653    18524541
## 40     MD PrivateNonprofit      1796922        1705136     3502058
## 41     MD           Public      4278085        1571303     5849388
## 42     MD           Public      6714119        7547759    14261878
## 43     MD PrivateNonprofit       589510         355243      944753
## 44     MD           Public      1199357        1274362     2473719
## 45     MD           Public     13557544       16185580    29743124
## 46     MD           Public      3480695        3197808     6678503
## 47     MD           Public     15673125       16470065    32143190
## 48     MD           Public       790624         831014     1621638
## 49     MD           Public      7886884        9144625    17031509
## 50     MD           Public      4777700        4991245     9768945
## 51     MD PrivateNonprofit      4701919        5113543     9815462
## 52     MD PrivateNonprofit      1499542        1323401     2822943
## 53     MD PrivateNonprofit      1987977        1803872     3791849
## 54     MD           Public      5385806        4202264     9588070
## 55     MD      Proprietary           NA             NA          NA
## 56     MD      Proprietary        61250          68022      129272
## 57     MD      Proprietary       305942         439905      745847
## 58     MD      Proprietary       587391         795882     1383273
## 59     MD           Public      1562603        1825338     3387941
## 60     MD      Proprietary       116268         115914      232182
## 61     MD           Public       730994        1233936     1964930
## 62     MD           Public       424451         425844      850295
## 63     MD      Proprietary      2279404        3399863     5679267
## 64     MD      Proprietary       268744         371619      640363
## 65     MD           Public     18151752       25195382    43347134
## 66     MD           Public       595801         231267      827068
## 67     MD      Proprietary       270825         414703      685528
## 68     MD PrivateNonprofit       361594         864259     1225853
## 69     MD      Proprietary        31723          49455       81178
## 70     MD      Proprietary        50260          52483      102743
## 71     MD      Proprietary       274339         283712      558051
## 72     MD      Proprietary        59017          57179      116196
## 73     MD      Proprietary        33224          37891       71115
## 74     MD      Proprietary        20573          24171       44744
## 75     MD      Proprietary        12266           5600       17866
## 76     MD      Proprietary       420951         614068     1035019
## 77     MD      Proprietary       107306         157442      264748
## 78     MD PrivateNonprofit           NA             NA          NA
## 79     MD      Proprietary        52234          77251      129485
## 80     MD      Proprietary        13973          19876       33849
## 81     MD      Proprietary        24249          33499       57748
## 82     MD           Public       207666         416588      624254
## 83     MD      Proprietary       400537         660202     1060739
## 84     MD      Proprietary       231284         389641      620925
## 85     MD      Proprietary        46285          62073      108358
## 86     MD PrivateNonprofit       196352         320716      517068
## 87     MD      Proprietary      1072935        1607727     2680662
## 88     MD PrivateNonprofit        12832          19666       32498
## 89     MD      Proprietary       126302         153268      279570
## 90     MD      Proprietary        23861          24999       48860
## 91     MD      Proprietary        21875          33375       55250
## 92     MD      Proprietary       153776         234372      388148
## 93     MD      Proprietary         8165          15832       23997
## 94     MD      Proprietary        48698          52385      101083
## 95     MD      Proprietary        63574          97427      161001
## 96     MD      Proprietary         9750          11000       20750
## 97     VA PrivateNonprofit      1794119        2188292     3982411
## 98     VA PrivateNonprofit      1092293        1275166     2367459
## 99     VA PrivateNonprofit      2122312        2245622     4367934
## 100    VA           Public      2933520        2918768     5852288
## 101    VA           Public      3951490        4478591     8430081
## 102    VA           Public       487220         513443     1000663
## 103    VA PrivateNonprofit      1226696        1033267     2259963
## 104    VA PrivateNonprofit      1140253        1126487     2266740
## 105    VA PrivateNonprofit      2181804        2430597     4612401
## 106    VA           Public     10448009       11067030    21515039
## 107    VA PrivateNonprofit      1047900        1022398     2070298
## 108    VA PrivateNonprofit      4499732        4862738     9362470
## 109    VA PrivateNonprofit       794850         740752     1535602
## 110    VA           Public      3959652        4187127     8146779
## 111    VA PrivateNonprofit      2715188        2831224     5546412
## 112    VA           Public     10756253       11941932    22698185
## 113    VA PrivateNonprofit      2119592        2369374     4488966
## 114    VA PrivateNonprofit      2527085        2903345     5430430
## 115    VA      Proprietary      2293904        3444632     5738536
## 116    VA           Public     13782616       15202571    28985187
## 117    VA           Public     20240533       21935690    42176223
## 118    VA           Public      8414375        9320944    17735319
## 119    VA PrivateNonprofit      1543289        1605771     3149060
## 120    VA PrivateNonprofit       844514         631027     1475541
## 121    VA           Public     21959084       20934687    42893771
## 122    VA PrivateNonprofit      2479693        2445616     4925309
## 123    VA PrivateNonprofit      2200957        2368719     4569676
## 124    VA PrivateNonprofit       832550         745373     1577923
## 125    VA PrivateNonprofit       664838         661229     1326067
## 126    VA PrivateNonprofit           NA             NA          NA
## 127    VA PrivateNonprofit      1974696        1505859     3480555
## 128    VA           Public      5873500        6377457    12250957
## 129    VA           Public      2719426        3737298     6456724
## 130    VA           Public      1280922        1136560     2417482
## 131    VA           Public     18050265       16648719    34698984
## 132    VA PrivateNonprofit        12750           6500       19250
## 133    VA           Public      1170083        1129315     2299398
## 134    VA           Public     16751772       16470730    33222502
## 135    VA           Public       443175          88910      532085
## 136    VA           Public      5030445        5115887    10146332
## 137    VA           Public      2140538        2200558     4341096
## 138    VA           Public       253477         190780      444257
## 139    VA PrivateNonprofit       672743         846236     1518979
## 140    VA           Public      7802174        9099782    16901956
## 141    VA           Public      8349935       10312789    18662724
## 142    VA PrivateNonprofit      2284041        2478730     4762771
## 143    VA PrivateNonprofit      1811545        1881968     3693513
## 144    VA PrivateNonprofit       398089         843015     1241104
## 145    VA           Public      1675718        1850693     3526411
## 146    VA           Public       159993         135936      295929
## 147    VA      Proprietary      3717804        5401391     9119195
## 148    VA           Public       273176         320029      593205
## 149    VA           Public      1011638         814314     1825952
## 150    VA PrivateNonprofit      1133856        1341021     2474877
## 151    VA           Public      1122476        1188958     2311434
## 152    VA           Public      4249355        4234544     8483899
## 153    VA           Public       923958        1095893     2019851
## 154    VA           Public       909281        1398799     2308080
## 155    VA      Proprietary       938851        1414879     2353730
## 156    VA      Proprietary        59045          92271      151316
## 157    VA      Proprietary        12890          14278       27168
## 158    VA           Public       689524         782121     1471645
## 159    VA PrivateNonprofit       557370         649045     1206415
## 160    VA      Proprietary      7100695        9060778    16161473
## 161    VA           Public           NA             NA          NA
## 162    VA      Proprietary        70674          94252      164926
## 163    VA      Proprietary       140484         171366      311850
## 164    VA PrivateNonprofit     42052986       53196359    95249345
## 165    VA      Proprietary       133201         207518      340719
## 166    VA      Proprietary        15000          17462       32462
## 167    VA PrivateNonprofit       230382         279193      509575
## 168    VA PrivateNonprofit       203893         238185      442078
## 169    VA           Public        28000          27000       55000
## 170    VA      Proprietary       294696         464251      758947
## 171    VA      Proprietary      1474419        2238020     3712439
## 172    VA      Proprietary      1071599        1500366     2571965
## 173    VA PrivateNonprofit        35750          36530       72280
## 174    VA      Proprietary        48250          51206       99456
## 175    VA      Proprietary      2003400        3121887     5125287
## 176    VA      Proprietary       826924        1309772     2136696
## 177    VA      Proprietary        67166         109107      176273
## 178    VA      Proprietary        28174          33448       61622
## 179    VA PrivateNonprofit      2697919        3271132     5969051
## 180    VA      Proprietary       154745         201463      356208
## 181    VA      Proprietary        38111          18514       56625
## 182    VA PrivateNonprofit       505549         667711     1173260
## 183    VA PrivateNonprofit           NA             NA          NA
## 184    VA      Proprietary       198041         297444      495485
## 185    VA      Proprietary       374092         582553      956645
## 186    VA      Proprietary       269314         293631      562945
## 187    VA      Proprietary        41964          66668      108632
## 188    VA      Proprietary       145437         161528      306965
## 189    VA PrivateNonprofit           NA             NA          NA
## 190    VA      Proprietary       167524         214304      381828
## 191    VA      Proprietary       111533         162120      273653
## 192    VA PrivateNonprofit           NA             NA          NA
## 193    VA PrivateNonprofit           NA             NA          NA
## 194    VA           Public        31423          24000       55423
## 195    VA      Proprietary        89968         137505      227473
## 196    VA      Proprietary        15959          23541       39500
## 197    VA      Proprietary        35580          27380       62960
## 198    VA      Proprietary        17495          23250       40745
## 199    VA      Proprietary        20105          14600       34705
## 200    VA PrivateNonprofit        12249          21001       33250
## 201    VA      Proprietary       222008         356307      578315
## 202    VA PrivateNonprofit         5147           6000       11147
## 203    VA      Proprietary           NA             NA          NA
## 204    VA      Proprietary        24936          70482       95418
## 205    VA      Proprietary        26250             NA          NA
## 206    VA      Proprietary        26250          41000       67250
## 207    VA PrivateNonprofit           NA             NA          NA
## 208    VA PrivateNonprofit           NA             NA          NA
## 209    VA      Proprietary        18541          35337       53878
## 210    VA      Proprietary        71149          60318      131467

rowwise()

Mutate works as expected when you want to manupulate whole columns at once, but sometimes you want to do something on a row-by-row basis.

For example: this code doesn't work as you might expect

myDF <- data.frame(x=c(1,2,3), y=c(10, 11, 12))
mutate(myDF, sum=sum(x, y))
##   x  y sum
## 1 1 10  39
## 2 2 11  39
## 3 3 12  39

rowwise()

But this code computes the sum on a row-by-row basis, as you might expect

myDF <- data.frame(x=c(1,2,3), y=c(10, 11, 12))
mutate(rowwise(myDF), sum=sum(x, y))
## Source: local data frame [3 x 3]
## Groups: <by row>
## 
## # A tibble: 3 x 3
##       x     y   sum
##   <dbl> <dbl> <dbl>
## 1     1    10    11
## 2     2    11    13
## 3     3    12    15

summarise()

Summarizes data into a single row. This may seem not that useful, but it will become useful when we start grouping data.

summarise(loans, meanSubDL = mean(SubsidizedDL, na.rm=TRUE))
##   meanSubDL
## 1   2607474

Grouping Data

These functions above get really powerful when you start grouping data based on factors in your dataset.

group_by()

groupedLoans <- group_by(loans, State)
summarise(groupedLoans, meanSubDL = mean(SubsidizedDL, na.rm=TRUE))
## # A tibble: 3 x 2
##   State meanSubDL
##   <fct>     <dbl>
## 1 DC     4094947.
## 2 MD     2132025.
## 3 VA     2730055.

Chaining operations

dplyr also provides a way of chaining together commplicated operations with the %>% operator.

This prevents having to save intermediate steps, or to have a complicated series of nested functions.

Note that the resulting dataframe from each step is passed as the first argument to the next function in the chain.

Chaining operations

group_by(loans, School_Type) %>%
  mutate(Total_Loans = SubsidizedDL + UNSubsidizedDL) %>%
  select(-State) %>%
  summarise(mean_total_loans = mean(Total_Loans, na.rm=TRUE))
## # A tibble: 3 x 2
##   School_Type      mean_total_loans
##   <fct>                       <dbl>
## 1 PrivateNonprofit         5115076.
## 2 Proprietary              1796278.
## 3 Public                  10315783.

Chaining works with non-dplyr() functions too

#chained syntax
rnorm(1000, mean=20, sd=1.4) %>% log %>% hist(main="my nice histogram")

#compare with nested function calls 

hist(log(rnorm(1000, mean=20, sd=1.4)))

do()

do anything to grouped data

linearModels <- loans %>% group_by(State) %>%
  do(regression=lm(UNSubsidizedDL~SubsidizedDL, data=.))
linearModels
## Source: local data frame [3 x 2]
## Groups: <by row>
## 
## # A tibble: 3 x 2
##   State regression
## * <fct> <list>    
## 1 DC    <S3: lm>  
## 2 MD    <S3: lm>  
## 3 VA    <S3: lm>

do()

linearModels <- loans %>% group_by(State) %>%
  do(regression=lm(UNSubsidizedDL~SubsidizedDL, data=.))
linearModels
linearModels %>% 
  summarize(sum=summary(regression)$r.squared)
## # A tibble: 3 x 1
##     sum
##   <dbl>
## 1 0.939
## 2 0.958
## 3 0.983

Challenge

Using the diamonds dataset that is built in to the ggplot2 package:

  • calculate the mean price of diamonds for each of the different clarity ratings
  • create a new column called volume that is the product of x, y and z
  • plot volume against carat

More info

Bonus content: programming in R

R is a programming language, which means that it gives you all the tools you need to automate repetitive tasks. There are three (or more) main ways to do this:

  • for loops
  • the lapply() function
  • the dplyr package

for loops

for loops will be familiar if you have ever used any other programming languages. The basic structure looks like this:

vector <- 1:10
for(i in vector){
  #do something with i
}

for loops

Here is a (slightly) more complicated example.

myVector <- 1:10
for(counter in myVector){
  result <- paste("counter ^ 2 = ", counter^2)
  print(result)
}
## [1] "counter ^ 2 =  1"
## [1] "counter ^ 2 =  4"
## [1] "counter ^ 2 =  9"
## [1] "counter ^ 2 =  16"
## [1] "counter ^ 2 =  25"
## [1] "counter ^ 2 =  36"
## [1] "counter ^ 2 =  49"
## [1] "counter ^ 2 =  64"
## [1] "counter ^ 2 =  81"
## [1] "counter ^ 2 =  100"

explanation of previous loop

  • We loop over a vector 1:100, and sequentially assign its values to a temporary variable we are calling counter. (Note: we can call this variable whatever we want.)
  • Then R does what is within the curly braces {} for each iteration of the loop.
  • In this case, it pastes together some text with the square of the value of counter and prints this all to the console.

  • After running the above code, what is the value of counter? What is the value of myVector? Has this value changed?

getting stuff out of a loop

  • Create a results vector in advance that is the same length as the vector we are looping over
  • Then save the results each time in the appropriate slot.
myVector <- runif(5, min = 1, max=10); myVector
## [1] 3.075945 1.313335 9.683253 7.920894 8.643216
results <- numeric(5)
for(each in 1:length(myVector)){
  results[each] <- paste(myVector[each], "^ 2 = ", myVector[each]^2)
}

results[3]
## [1] "9.68325309897773 ^ 2 =  93.7653905788618"

if statements

  • Often during a loop, you may want to do a test and do something different based on the results of the test.
  • Imagine a vector of germination outcomes from a seed experiment.
  • 0 indicates the seed did not germinate due to insect predatoin
  • 1 indicates that it did not germinate but no insect predation occurrend
  • 2 indicates that the seed germinated.

We can use the if() function to evaluate the outcome and provide context specific output.

outcomes <- c(0,1,0,2,0,1,0,2,0,1,0,1,0,0)
for(trial in outcomes){
  if(trial == 2) print("Welcome to the world, plantling!")
  else print("RIP")
}
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"
## [1] "Welcome to the world, plantling!"
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"
## [1] "Welcome to the world, plantling!"
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"
## [1] "RIP"

Challenge

Write a for loop to examine the law of large numbers to illustrate how, as sample size increases, estimates of the mean of a population converge on the true value. Do this in the following steps:

  • create a numeric results vector of length 2000
  • loop over each integer i from 1 to 2000
  • at each iteration use the rnorm() function to simulate a sample of size i from a population with a mean of 100 and standard deviation of 30.
  • calculate the mean of this sample, and be sure to save these results to the appropriate place in the results vector
  • finally, make a plot of the results with the integers 1 to 2000 on the x axis, and the corresponding value from the results vector on the y axis

lapply()

The function lapply() is like a for loop, but is optimized and explicitly functional.

lapply() usually takes two arguments

  • X which is a list or a vector to loop over
  • FUN which is a function to apply to each element of X.

Thus, FUN must be able to accept any element of X as an argument.

x <- c("dog","cat", "cucumber")
lapply(x, FUN=nchar)
## [[1]]
## [1] 3
## 
## [[2]]
## [1] 3
## 
## [[3]]
## [1] 8

Writing your own functions

Functions are the best way to encapsulate code that you want to repeat again and again.

A function accepts arguments and returns a single (and only a single) object.

Variable names defined within a function only exist within the function (not within the global environment).

Writing your own functions

is.even <- function(number){
  if(number %% 2 == 0) {return("The number is even")}
  else {return("The number is not even")}
}

is.even(1233)
## [1] "The number is not even"
is.even(1234)
## [1] "The number is even"
is.even(-1.2)
## [1] "The number is not even"

Lists

The "l" in lapply() stands for "list", because that's what you get as a result.

lists can hold any type of data, not every element needs to be the same type.

myList <- list(firstOne=1, nextOne="too", lastOne=rnorm(10))
myList
## $firstOne
## [1] 1
## 
## $nextOne
## [1] "too"
## 
## $lastOne
##  [1]  0.84466722  0.08560900 -1.41884320  0.77558494  0.68531686
##  [6]  0.70119908  0.83377500  0.09936071  1.35451968  0.01123037

often use double brackets [[]] to index a list

myList[[3]]
##  [1]  0.84466722  0.08560900 -1.41884320  0.77558494  0.68531686
##  [6]  0.70119908  0.83377500  0.09936071  1.35451968  0.01123037
myList[3]
## $lastOne
##  [1]  0.84466722  0.08560900 -1.41884320  0.77558494  0.68531686
##  [6]  0.70119908  0.83377500  0.09936071  1.35451968  0.01123037

For five marks….what is the difference?

[[]] versus []