Background Information on the Dataset

In the wake of the Great Recession of 2009, there has been a good deal of focus on employment statistics, one of the most important metrics policymakers use to gauge the overall strength of the economy. In the United States, the government measures unemployment using the Current Population Survey (CPS), which collects demographic and employment information from a wide range of Americans each month. In this exercise, we will employ the topics reviewed in the lectures as well as a few new techniques using the September 2013 version of this rich, nationally representative dataset (available online.

The observations in the dataset represent people surveyed in the September 2013 CPS who actually completed a survey. While the full dataset has 385 variables, in this exercise we will use a more compact version of the dataset, CPSData.csv, which has the following variables:

In this problem, we’ll take a look at how the stock dynamics of these companies have changed over time.

R Exercises

Load the dataset from CPSData.csv into a data frame called CPS, and view the dataset with the summary() and str() commands.

CPS = read.csv("CPSData.csv")
MetroAreaMap = read.csv("MetroAreaCodes.csv")
CountryMap = read.csv("CountryCodes.csv")

How many interviewees are in the dataset?

str(CPS)
## 'data.frame':    131302 obs. of  14 variables:
##  $ PeopleInHousehold : int  1 3 3 3 3 3 3 2 2 2 ...
##  $ Region            : Factor w/ 4 levels "Midwest","Northeast",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ State             : Factor w/ 51 levels "Alabama","Alaska",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ MetroAreaCode     : int  26620 13820 13820 13820 26620 26620 26620 33660 33660 26620 ...
##  $ Age               : int  85 21 37 18 52 24 26 71 43 52 ...
##  $ Married           : Factor w/ 5 levels "Divorced","Married",..: 5 3 3 3 5 3 3 1 1 3 ...
##  $ Sex               : Factor w/ 2 levels "Female","Male": 1 2 1 2 1 2 2 1 2 2 ...
##  $ Education         : Factor w/ 8 levels "Associate degree",..: 1 4 4 6 1 2 4 4 4 2 ...
##  $ Race              : Factor w/ 6 levels "American Indian",..: 6 3 3 3 6 6 6 6 6 6 ...
##  $ Hispanic          : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ CountryOfBirthCode: int  57 57 57 57 57 57 57 57 57 57 ...
##  $ Citizenship       : Factor w/ 3 levels "Citizen, Native",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ EmploymentStatus  : Factor w/ 5 levels "Disabled","Employed",..: 4 5 1 3 2 2 2 2 3 2 ...
##  $ Industry          : Factor w/ 14 levels "Agriculture, forestry, fishing, and hunting",..: NA 11 NA NA 11 4 14 4 NA 12 ...

Explanation: From str(CPS), we can read that there are 131302 interviewees.

Among the interviewees with a value reported for the Industry variable, what is the most common industry of employment?

summary(CPS)
##  PeopleInHousehold       Region               State       MetroAreaCode        Age                 Married          Sex                          Education    
##  Min.   : 1.000    Midwest  :30684   California  :11570   Min.   :10420   Min.   : 0.00   Divorced     :11151   Female:67481   High school            :30906  
##  1st Qu.: 2.000    Northeast:25939   Texas       : 7077   1st Qu.:21780   1st Qu.:19.00   Married      :55509   Male  :63821   Bachelor's degree      :19443  
##  Median : 3.000    South    :41502   New York    : 5595   Median :34740   Median :39.00   Never Married:30772                  Some college, no degree:18863  
##  Mean   : 3.284    West     :33177   Florida     : 5149   Mean   :35075   Mean   :38.83   Separated    : 2027                  No high school diploma :16095  
##  3rd Qu.: 4.000                      Pennsylvania: 3930   3rd Qu.:41860   3rd Qu.:57.00   Widowed      : 6505                  Associate degree       : 9913  
##  Max.   :15.000                      Illinois    : 3912   Max.   :79600   Max.   :85.00   NA's         :25338                  (Other)                :10744  
##                                      (Other)     :94069   NA's   :34238                                                        NA's                   :25338  
##                Race           Hispanic      CountryOfBirthCode               Citizenship               EmploymentStatus
##  American Indian :  1433   Min.   :0.0000   Min.   : 57.00     Citizen, Native     :116639   Disabled          : 5712  
##  Asian           :  6520   1st Qu.:0.0000   1st Qu.: 57.00     Citizen, Naturalized:  7073   Employed          :61733  
##  Black           : 13913   Median :0.0000   Median : 57.00     Non-Citizen         :  7590   Not in Labor Force:15246  
##  Multiracial     :  2897   Mean   :0.1393   Mean   : 82.68                                   Retired           :18619  
##  Pacific Islander:   618   3rd Qu.:0.0000   3rd Qu.: 57.00                                   Unemployed        : 4203  
##  White           :105921   Max.   :1.0000   Max.   :555.00                                   NA's              :25789  
##                                                                                                                        
##                                Industry    
##  Educational and health services   :15017  
##  Trade                             : 8933  
##  Professional and business services: 7519  
##  Manufacturing                     : 6791  
##  Leisure and hospitality           : 6364  
##  (Other)                           :21618  
##  NA's                              :65060

table(CPS$Industry)
## 
## Agriculture, forestry, fishing, and hunting                                Armed forces                                Construction 
##                                        1307                                          29                                        4387 
##             Educational and health services                                   Financial                                 Information 
##                                       15017                                        4347                                        1328 
##                     Leisure and hospitality                               Manufacturing                                      Mining 
##                                        6364                                        6791                                         550 
##                              Other services          Professional and business services                       Public administration 
##                                        3224                                        7519                                        3186 
##                                       Trade                Transportation and utilities 
##                                        8933                                        3260

Explanation: The output of summary(CPS) orders the levels of a factor variable like Industry from largest to smallest, so we can see that “Educational and health services” is the most common Industry. table(CPS$Industry) would have provided the breakdown across all industries.

Which state has the fewest interviewees?

sort(table(CPS$State))
## 
##           New Mexico              Montana          Mississippi              Alabama        West Virginia             Arkansas            Louisiana 
##                 1102                 1214                 1230                 1376                 1409                 1421                 1450 
##                Idaho             Oklahoma              Arizona               Alaska              Wyoming         North Dakota       South Carolina 
##                 1518                 1523                 1528                 1590                 1624                 1645                 1658 
##            Tennessee District of Columbia             Kentucky                 Utah               Nevada              Vermont               Kansas 
##                 1784                 1791                 1841                 1842                 1856                 1890                 1935 
##               Oregon             Nebraska        Massachusetts         South Dakota              Indiana               Hawaii             Missouri 
##                 1943                 1949                 1987                 2000                 2004                 2099                 2145 
##         Rhode Island             Delaware                Maine           Washington                 Iowa           New Jersey       North Carolina 
##                 2209                 2214                 2263                 2366                 2528                 2567                 2619 
##        New Hampshire            Wisconsin              Georgia          Connecticut             Colorado             Virginia             Michigan 
##                 2662                 2686                 2807                 2836                 2925                 2953                 3063 
##            Minnesota             Maryland                 Ohio             Illinois         Pennsylvania              Florida             New York 
##                 3139                 3200                 3678                 3912                 3930                 5149                 5595 
##                Texas           California 
##                 7077                11570

New Mexico.

Which state has the largest number of interviewees?

sort(table(CPS$State))
## 
##           New Mexico              Montana          Mississippi              Alabama        West Virginia             Arkansas            Louisiana 
##                 1102                 1214                 1230                 1376                 1409                 1421                 1450 
##                Idaho             Oklahoma              Arizona               Alaska              Wyoming         North Dakota       South Carolina 
##                 1518                 1523                 1528                 1590                 1624                 1645                 1658 
##            Tennessee District of Columbia             Kentucky                 Utah               Nevada              Vermont               Kansas 
##                 1784                 1791                 1841                 1842                 1856                 1890                 1935 
##               Oregon             Nebraska        Massachusetts         South Dakota              Indiana               Hawaii             Missouri 
##                 1943                 1949                 1987                 2000                 2004                 2099                 2145 
##         Rhode Island             Delaware                Maine           Washington                 Iowa           New Jersey       North Carolina 
##                 2209                 2214                 2263                 2366                 2528                 2567                 2619 
##        New Hampshire            Wisconsin              Georgia          Connecticut             Colorado             Virginia             Michigan 
##                 2662                 2686                 2807                 2836                 2925                 2953                 3063 
##            Minnesota             Maryland                 Ohio             Illinois         Pennsylvania              Florida             New York 
##                 3139                 3200                 3678                 3912                 3930                 5149                 5595 
##                Texas           California 
##                 7077                11570

California.

What proportion of interviewees are citizens of the United States?

table(CPS$Citizenship)
## 
##      Citizen, Native Citizen, Naturalized          Non-Citizen 
##               116639                 7073                 7590

m = table(CPS$Citizenship)

(m[1]+m[2])/(m[1]+m[2]+m[3])
## Citizen, Native 
##       0.9421943

Explanation: From table(CPS$Citizenship), we see that 123,712 of the 131,302 interviewees are citizens of the United States (either native or naturalized). This is a proportion of 123712/131302=0.942.

For which races are there at least 250 interviewees in the CPS dataset of Hispanic ethnicity?

table(CPS$Race, CPS$Hispanic) >=250
##                   
##                       0     1
##   American Indian  TRUE  TRUE
##   Asian            TRUE FALSE
##   Black            TRUE  TRUE
##   Multiracial      TRUE  TRUE
##   Pacific Islander TRUE FALSE
##   White            TRUE  TRUE

Explanation: The breakdown of race and Hispanic ethnicity can be obtained with table(CPS\(Race, CPS\)Hispanic).

Which variables have at least one interviewee with a missing (NA) value?

summary(CPS)
##  PeopleInHousehold       Region               State       MetroAreaCode        Age                 Married          Sex                          Education    
##  Min.   : 1.000    Midwest  :30684   California  :11570   Min.   :10420   Min.   : 0.00   Divorced     :11151   Female:67481   High school            :30906  
##  1st Qu.: 2.000    Northeast:25939   Texas       : 7077   1st Qu.:21780   1st Qu.:19.00   Married      :55509   Male  :63821   Bachelor's degree      :19443  
##  Median : 3.000    South    :41502   New York    : 5595   Median :34740   Median :39.00   Never Married:30772                  Some college, no degree:18863  
##  Mean   : 3.284    West     :33177   Florida     : 5149   Mean   :35075   Mean   :38.83   Separated    : 2027                  No high school diploma :16095  
##  3rd Qu.: 4.000                      Pennsylvania: 3930   3rd Qu.:41860   3rd Qu.:57.00   Widowed      : 6505                  Associate degree       : 9913  
##  Max.   :15.000                      Illinois    : 3912   Max.   :79600   Max.   :85.00   NA's         :25338                  (Other)                :10744  
##                                      (Other)     :94069   NA's   :34238                                                        NA's                   :25338  
##                Race           Hispanic      CountryOfBirthCode               Citizenship               EmploymentStatus
##  American Indian :  1433   Min.   :0.0000   Min.   : 57.00     Citizen, Native     :116639   Disabled          : 5712  
##  Asian           :  6520   1st Qu.:0.0000   1st Qu.: 57.00     Citizen, Naturalized:  7073   Employed          :61733  
##  Black           : 13913   Median :0.0000   Median : 57.00     Non-Citizen         :  7590   Not in Labor Force:15246  
##  Multiracial     :  2897   Mean   :0.1393   Mean   : 82.68                                   Retired           :18619  
##  Pacific Islander:   618   3rd Qu.:0.0000   3rd Qu.: 57.00                                   Unemployed        : 4203  
##  White           :105921   Max.   :1.0000   Max.   :555.00                                   NA's              :25789  
##                                                                                                                        
##                                Industry    
##  Educational and health services   :15017  
##  Trade                             : 8933  
##  Professional and business services: 7519  
##  Manufacturing                     : 6791  
##  Leisure and hospitality           : 6364  
##  (Other)                           :21618  
##  NA's                              :65060

Explanation: This can be read from the output of summary(CPS).

Often when evaluating a new dataset, we try to identify if there is a pattern in the missing values in the dataset.

table(CPS$Region, is.na(CPS$Married))
##            
##             FALSE  TRUE
##   Midwest   24609  6075
##   Northeast 21432  4507
##   South     33535  7967
##   West      26388  6789

table(CPS$Sex, is.na(CPS$Married))
##         
##          FALSE  TRUE
##   Female 55264 12217
##   Male   50700 13121

table(CPS$Age, is.na(CPS$Married))
##     
##      FALSE TRUE
##   0      0 1283
##   1      0 1559
##   2      0 1574
##   3      0 1693
##   4      0 1695
##   5      0 1795
##   6      0 1721
##   7      0 1681
##   8      0 1729
##   9      0 1748
##   10     0 1750
##   11     0 1721
##   12     0 1797
##   13     0 1802
##   14     0 1790
##   15  1795    0
##   16  1751    0
##   17  1764    0
##   18  1596    0
##   19  1517    0
##   20  1398    0
##   21  1525    0
##   22  1536    0
##   23  1638    0
##   24  1627    0
##   25  1604    0
##   26  1643    0
##   27  1657    0
##   28  1736    0
##   29  1645    0
##   30  1854    0
##   31  1762    0
##   32  1790    0
##   33  1804    0
##   34  1653    0
##   35  1716    0
##   36  1663    0
##   37  1531    0
##   38  1530    0
##   39  1542    0
##   40  1571    0
##   41  1673    0
##   42  1711    0
##   43  1819    0
##   44  1764    0
##   45  1749    0
##   46  1665    0
##   47  1647    0
##   48  1791    0
##   49  1989    0
##   50  1966    0
##   51  1931    0
##   52  1935    0
##   53  1994    0
##   54  1912    0
##   55  1895    0
##   56  1935    0
##   57  1827    0
##   58  1874    0
##   59  1758    0
##   60  1746    0
##   61  1735    0
##   62  1595    0
##   63  1596    0
##   64  1519    0
##   65  1569    0
##   66  1577    0
##   67  1227    0
##   68  1130    0
##   69  1062    0
##   70  1195    0
##   71  1031    0
##   72   941    0
##   73   896    0
##   74   842    0
##   75   763    0
##   76   729    0
##   77   698    0
##   78   659    0
##   79   661    0
##   80  2664    0
##   85  2446    0

table(CPS$Citizenship, is.na(CPS$Married))
##                       
##                        FALSE  TRUE
##   Citizen, Native      91956 24683
##   Citizen, Naturalized  6910   163
##   Non-Citizen           7098   492

Explanation: For each possible value of Region, Sex, and Citizenship, there are both interviewees with missing and non-missing Married values. However, Married is missing for all interviewees Aged 0-14 and is present for all interviewees aged 15 and older. This is because the CPS does not ask about marriage status for interviewees 14 and younger.

How many states had all interviewees living in a non-metropolitan area (aka they have a missing MetroAreaCode value)?

table(CPS$State, is.na(CPS$MetroAreaCode))
##                       
##                        FALSE  TRUE
##   Alabama               1020   356
##   Alaska                   0  1590
##   Arizona               1327   201
##   Arkansas               724   697
##   California           11333   237
##   Colorado              2545   380
##   Connecticut           2593   243
##   Delaware              1696   518
##   District of Columbia  1791     0
##   Florida               4947   202
##   Georgia               2250   557
##   Hawaii                1576   523
##   Idaho                  761   757
##   Illinois              3473   439
##   Indiana               1420   584
##   Iowa                  1297  1231
##   Kansas                1234   701
##   Kentucky               908   933
##   Louisiana             1216   234
##   Maine                  909  1354
##   Maryland              2978   222
##   Massachusetts         1858   129
##   Michigan              2517   546
##   Minnesota             2150   989
##   Mississippi            376   854
##   Missouri              1440   705
##   Montana                199  1015
##   Nebraska               816  1133
##   Nevada                1609   247
##   New Hampshire         1148  1514
##   New Jersey            2567     0
##   New Mexico             832   270
##   New York              5144   451
##   North Carolina        1642   977
##   North Dakota           432  1213
##   Ohio                  2754   924
##   Oklahoma              1024   499
##   Oregon                1519   424
##   Pennsylvania          3245   685
##   Rhode Island          2209     0
##   South Carolina        1139   519
##   South Dakota           595  1405
##   Tennessee             1149   635
##   Texas                 6060  1017
##   Utah                  1455   387
##   Vermont                657  1233
##   Virginia              2367   586
##   Washington            1937   429
##   West Virginia          344  1065
##   Wisconsin             1882   804
##   Wyoming                  0  1624

How many states had all interviewees living in a metropolitan area?

table(CPS$State, is.na(CPS$MetroAreaCode))
##                       
##                        FALSE  TRUE
##   Alabama               1020   356
##   Alaska                   0  1590
##   Arizona               1327   201
##   Arkansas               724   697
##   California           11333   237
##   Colorado              2545   380
##   Connecticut           2593   243
##   Delaware              1696   518
##   District of Columbia  1791     0
##   Florida               4947   202
##   Georgia               2250   557
##   Hawaii                1576   523
##   Idaho                  761   757
##   Illinois              3473   439
##   Indiana               1420   584
##   Iowa                  1297  1231
##   Kansas                1234   701
##   Kentucky               908   933
##   Louisiana             1216   234
##   Maine                  909  1354
##   Maryland              2978   222
##   Massachusetts         1858   129
##   Michigan              2517   546
##   Minnesota             2150   989
##   Mississippi            376   854
##   Missouri              1440   705
##   Montana                199  1015
##   Nebraska               816  1133
##   Nevada                1609   247
##   New Hampshire         1148  1514
##   New Jersey            2567     0
##   New Mexico             832   270
##   New York              5144   451
##   North Carolina        1642   977
##   North Dakota           432  1213
##   Ohio                  2754   924
##   Oklahoma              1024   499
##   Oregon                1519   424
##   Pennsylvania          3245   685
##   Rhode Island          2209     0
##   South Carolina        1139   519
##   South Dakota           595  1405
##   Tennessee             1149   635
##   Texas                 6060  1017
##   Utah                  1455   387
##   Vermont                657  1233
##   Virginia              2367   586
##   Washington            1937   429
##   West Virginia          344  1065
##   Wisconsin             1882   804
##   Wyoming                  0  1624

Which region of the United States has the largest proportion of interviewees living in a non-metropolitan area?

m = table(CPS$Region, is.na(CPS$MetroAreaCode))

prop.table(m,1)
##            
##                 FALSE      TRUE
##   Midwest   0.6521314 0.3478686
##   Northeast 0.7837619 0.2162381
##   South     0.7621560 0.2378440
##   West      0.7563372 0.2436628

Explanation: We can then compute the proportion of interviewees in each region that live in a non-metropolitan area: 34.8% in the Midwest, 21.6% in the Northeast, 23.8% in the South, and 24.4% in the West.

Which state has a proportion of interviewees living in a non-metropolitan area closest to 30%?

sort(tapply(is.na(CPS$MetroAreaCode), CPS$State, mean))
## District of Columbia           New Jersey         Rhode Island           California              Florida        Massachusetts             Maryland 
##           0.00000000           0.00000000           0.00000000           0.02048401           0.03923092           0.06492199           0.06937500 
##             New York          Connecticut             Illinois             Colorado              Arizona               Nevada                Texas 
##           0.08060769           0.08568406           0.11221881           0.12991453           0.13154450           0.13308190           0.14370496 
##            Louisiana         Pennsylvania             Michigan           Washington              Georgia             Virginia                 Utah 
##           0.16137931           0.17430025           0.17825661           0.18131868           0.19843249           0.19844226           0.21009772 
##               Oregon             Delaware           New Mexico               Hawaii                 Ohio              Alabama              Indiana 
##           0.21821925           0.23396567           0.24500907           0.24916627           0.25122349           0.25872093           0.29141717 
##            Wisconsin       South Carolina            Minnesota             Oklahoma             Missouri            Tennessee               Kansas 
##           0.29932986           0.31302774           0.31506849           0.32764281           0.32867133           0.35594170           0.36227390 
##       North Carolina                 Iowa             Arkansas                Idaho             Kentucky        New Hampshire             Nebraska 
##           0.37304315           0.48694620           0.49049965           0.49868248           0.50678979           0.56874530           0.58132376 
##                Maine              Vermont          Mississippi         South Dakota         North Dakota        West Virginia              Montana 
##           0.59832081           0.65238095           0.69430894           0.70250000           0.73738602           0.75585522           0.83607908 
##               Alaska              Wyoming 
##           1.00000000           1.00000000

Wisconsin.

Which state has the largest proportion of non-metropolitan interviewees, ignoring states where all interviewees were non-metropolitan?

sort(tapply(is.na(CPS$MetroAreaCode), CPS$State, mean))
## District of Columbia           New Jersey         Rhode Island           California              Florida        Massachusetts             Maryland 
##           0.00000000           0.00000000           0.00000000           0.02048401           0.03923092           0.06492199           0.06937500 
##             New York          Connecticut             Illinois             Colorado              Arizona               Nevada                Texas 
##           0.08060769           0.08568406           0.11221881           0.12991453           0.13154450           0.13308190           0.14370496 
##            Louisiana         Pennsylvania             Michigan           Washington              Georgia             Virginia                 Utah 
##           0.16137931           0.17430025           0.17825661           0.18131868           0.19843249           0.19844226           0.21009772 
##               Oregon             Delaware           New Mexico               Hawaii                 Ohio              Alabama              Indiana 
##           0.21821925           0.23396567           0.24500907           0.24916627           0.25122349           0.25872093           0.29141717 
##            Wisconsin       South Carolina            Minnesota             Oklahoma             Missouri            Tennessee               Kansas 
##           0.29932986           0.31302774           0.31506849           0.32764281           0.32867133           0.35594170           0.36227390 
##       North Carolina                 Iowa             Arkansas                Idaho             Kentucky        New Hampshire             Nebraska 
##           0.37304315           0.48694620           0.49049965           0.49868248           0.50678979           0.56874530           0.58132376 
##                Maine              Vermont          Mississippi         South Dakota         North Dakota        West Virginia              Montana 
##           0.59832081           0.65238095           0.69430894           0.70250000           0.73738602           0.75585522           0.83607908 
##               Alaska              Wyoming 
##           1.00000000           1.00000000

Montana

Integrating Metropolitan Area Data

Codes like MetroAreaCode and CountryOfBirthCode are a compact way to encode factor variables with text as their possible values, and they are therefore quite common in survey datasets. In fact, all but one of the variables in this dataset were actually stored by a numeric code in the original CPS datafile.

When analyzing a variable stored by a numeric code, we will often want to convert it into the values the codes represent. To do this, we will use a dictionary, which maps the the code to the actual value of the variable. We have provided dictionaries MetroAreaCodes.csv and CountryCodes.csv, which respectively map MetroAreaCode and CountryOfBirthCode into their true values. Read these two dictionaries into data frames MetroAreaMap and CountryMap.

How many observations (codes for metropolitan areas) are there in MetroAreaMap?

str(MetroAreaMap)
## 'data.frame':    271 obs. of  2 variables:
##  $ Code     : int  460 3000 3160 3610 3720 6450 10420 10500 10580 10740 ...
##  $ MetroArea: Factor w/ 271 levels "Akron, OH","Albany-Schenectady-Troy, NY",..: 12 92 97 117 122 195 1 3 2 4 ...

How many observations (codes for metropolitan areas) are there in MetroAreaMap?

str(CountryMap)
## 'data.frame':    149 obs. of  2 variables:
##  $ Code   : int  57 66 73 78 96 100 102 103 104 105 ...
##  $ Country: Factor w/ 149 levels "Afghanistan",..: 139 57 105 135 97 3 11 18 24 37 ...

To merge in the metropolitan areas, we want to connect the field MetroAreaCode from the CPS data frame with the field Code in MetroAreaMap. The following command merges the two data frames on these columns, overwriting the CPS data frame with the result:

CPS = merge(CPS, MetroAreaMap, by.x="MetroAreaCode", by.y="Code", all.x=TRUE)

What is the name of the variable that was added to the data frame by the merge() operation?

summary(CPS)
##  MetroAreaCode   PeopleInHousehold       Region               State            Age                 Married          Sex                          Education    
##  Min.   :10420   Min.   : 1.000    Midwest  :30684   California  :11570   Min.   : 0.00   Divorced     :11151   Female:67481   High school            :30906  
##  1st Qu.:21780   1st Qu.: 2.000    Northeast:25939   Texas       : 7077   1st Qu.:19.00   Married      :55509   Male  :63821   Bachelor's degree      :19443  
##  Median :34740   Median : 3.000    South    :41502   New York    : 5595   Median :39.00   Never Married:30772                  Some college, no degree:18863  
##  Mean   :35075   Mean   : 3.284    West     :33177   Florida     : 5149   Mean   :38.83   Separated    : 2027                  No high school diploma :16095  
##  3rd Qu.:41860   3rd Qu.: 4.000                      Pennsylvania: 3930   3rd Qu.:57.00   Widowed      : 6505                  Associate degree       : 9913  
##  Max.   :79600   Max.   :15.000                      Illinois    : 3912   Max.   :85.00   NA's         :25338                  (Other)                :10744  
##  NA's   :34238                                       (Other)     :94069                                                        NA's                   :25338  
##                Race           Hispanic      CountryOfBirthCode               Citizenship               EmploymentStatus
##  American Indian :  1433   Min.   :0.0000   Min.   : 57.00     Citizen, Native     :116639   Disabled          : 5712  
##  Asian           :  6520   1st Qu.:0.0000   1st Qu.: 57.00     Citizen, Naturalized:  7073   Employed          :61733  
##  Black           : 13913   Median :0.0000   Median : 57.00     Non-Citizen         :  7590   Not in Labor Force:15246  
##  Multiracial     :  2897   Mean   :0.1393   Mean   : 82.68                                   Retired           :18619  
##  Pacific Islander:   618   3rd Qu.:0.0000   3rd Qu.: 57.00                                   Unemployed        : 4203  
##  White           :105921   Max.   :1.0000   Max.   :555.00                                   NA's              :25789  
##                                                                                                                        
##                                Industry                                                  MetroArea    
##  Educational and health services   :15017   New York-Northern New Jersey-Long Island, NY-NJ-PA: 5409  
##  Trade                             : 8933   Washington-Arlington-Alexandria, DC-VA-MD-WV      : 4177  
##  Professional and business services: 7519   Los Angeles-Long Beach-Santa Ana, CA              : 4102  
##  Manufacturing                     : 6791   Philadelphia-Camden-Wilmington, PA-NJ-DE          : 2855  
##  Leisure and hospitality           : 6364   Chicago-Naperville-Joliet, IN-IN-WI               : 2772  
##  (Other)                           :21618   (Other)                                           :77749  
##  NA's                              :65060   NA's                                              :34238

MetroArea

How many interviewees have a missing value for the new metropolitan area variable?

summary(CPS)
##  MetroAreaCode   PeopleInHousehold       Region               State            Age                 Married          Sex                          Education    
##  Min.   :10420   Min.   : 1.000    Midwest  :30684   California  :11570   Min.   : 0.00   Divorced     :11151   Female:67481   High school            :30906  
##  1st Qu.:21780   1st Qu.: 2.000    Northeast:25939   Texas       : 7077   1st Qu.:19.00   Married      :55509   Male  :63821   Bachelor's degree      :19443  
##  Median :34740   Median : 3.000    South    :41502   New York    : 5595   Median :39.00   Never Married:30772                  Some college, no degree:18863  
##  Mean   :35075   Mean   : 3.284    West     :33177   Florida     : 5149   Mean   :38.83   Separated    : 2027                  No high school diploma :16095  
##  3rd Qu.:41860   3rd Qu.: 4.000                      Pennsylvania: 3930   3rd Qu.:57.00   Widowed      : 6505                  Associate degree       : 9913  
##  Max.   :79600   Max.   :15.000                      Illinois    : 3912   Max.   :85.00   NA's         :25338                  (Other)                :10744  
##  NA's   :34238                                       (Other)     :94069                                                        NA's                   :25338  
##                Race           Hispanic      CountryOfBirthCode               Citizenship               EmploymentStatus
##  American Indian :  1433   Min.   :0.0000   Min.   : 57.00     Citizen, Native     :116639   Disabled          : 5712  
##  Asian           :  6520   1st Qu.:0.0000   1st Qu.: 57.00     Citizen, Naturalized:  7073   Employed          :61733  
##  Black           : 13913   Median :0.0000   Median : 57.00     Non-Citizen         :  7590   Not in Labor Force:15246  
##  Multiracial     :  2897   Mean   :0.1393   Mean   : 82.68                                   Retired           :18619  
##  Pacific Islander:   618   3rd Qu.:0.0000   3rd Qu.: 57.00                                   Unemployed        : 4203  
##  White           :105921   Max.   :1.0000   Max.   :555.00                                   NA's              :25789  
##                                                                                                                        
##                                Industry                                                  MetroArea    
##  Educational and health services   :15017   New York-Northern New Jersey-Long Island, NY-NJ-PA: 5409  
##  Trade                             : 8933   Washington-Arlington-Alexandria, DC-VA-MD-WV      : 4177  
##  Professional and business services: 7519   Los Angeles-Long Beach-Santa Ana, CA              : 4102  
##  Manufacturing                     : 6791   Philadelphia-Camden-Wilmington, PA-NJ-DE          : 2855  
##  Leisure and hospitality           : 6364   Chicago-Naperville-Joliet, IN-IN-WI               : 2772  
##  (Other)                           :21618   (Other)                                           :77749  
##  NA's                              :65060   NA's                                              :34238

Which of the following metropolitan areas has the largest number of interviewees?

sort(table(CPS$MetroArea))
## 
##                        Appleton-Oshkosh-Neenah, WI                  Grand Rapids-Muskegon-Holland, MI                Greenville-Spartanburg-Anderson, SC 
##                                                  0                                                  0                                                  0 
##                        Hinesville-Fort Stewart, GA                                      Jamestown, NY                         Kalamazoo-Battle Creek, MI 
##                                                  0                                                  0                                                  0 
##                        Portsmouth-Rochester, NH-ME                                  Bowling Green, KY                                     Ocean City, NJ 
##                                                  0                                                 29                                                 30 
##                                    Springfield, OH                              Bloomington-Normal IL                                       Valdosta, GA 
##                                                 34                                                 40                                                 42 
##                                  Warner Robins, GA                                    Tallahassee, FL                                       Columbia, MO 
##                                                 42                                                 43                                                 47 
##                                    Punta Gorda, FL                                        Midland, TX                            Niles-Benton Harbor, MI 
##                                                 48                                                 51                                                 51 
##                                   Johnson City, TN                                       Santa Fe, NM                                       Prescott, AZ 
##                                                 52                                                 52                                                 54 
##                   Vineland-Millville-Bridgeton, NJ                      Hickory-Morgantown-Lenoir, NC                                         Madera, CA 
##                                                 54                                                 57                                                 57 
##                                    Columbus, GA-AL                                         Joplin, MO                         Panama City-Lynn Haven, FL 
##                                                 59                                                 59                                                 59 
##                                          Chico, CA                                Anniston-Oxford, AL                                           Napa, CA 
##                                                 60                                                 61                                                 61 
##                                       Anderson, IN                                       Florence, AL                                   Jacksonville, NC 
##                                                 62                                                 63                                                 63 
##                                      Johnstown, PA                                        Lubbock, TX                                         Monroe, MI 
##                                                 63                                                 63                                                 63 
##                                       Anderson, SC                                     Farmington, NM                            Athens-Clark County, GA 
##                                                 64                                                 64                                                 65 
##                                Gulfport-Biloxi, MS                                       Longview, TX                                          Macon, GA 
##                                                 65                                                 65                                                 65 
##                   Leominster-Fitchburg-Gardner, MA                                        Roanoke, VA                         Santa-Cruz-Watsonville, CA 
##                                                 66                                                 66                                                 66 
##                           Kingsport-Bristol, TN-VA                                         Albany, GA                                     Bellingham, WA 
##                                                 67                                                 68                                                 70 
##                                    Gainesville, FL                                        Jackson, MI                                     Binghamton, NY 
##                                                 70                                                 70                                                 73 
##                                      Lynchburg, VA                 Saginaw-Saginaw Township North, MI                                      Salisbury, MD 
##                                                 73                                                 74                                                 74 
##                                Barnstable Town, MA                                          Ocala, FL                                    Springfield, IL 
##                                                 75                                                 76                                                 76 
##                                   Fayetteville, NC                         Michigan City-La Porte, IN                    San Luis Obispo-Paso Robles, CA 
##                                                 77                                                 77                                                 77 
##                            Holland-Grand Haven, MI                                     Tuscaloosa, AL                          Brownsville-Harlingen, TX 
##                                                 78                                                 78                                                 79 
##                                     Vero Beach, FL                                           Waco, TX             Fort Walton Beach-Crestview-Destin, FL 
##                                                 79                                                 79                                                 80 
##                                     Utica-Rome, NY                                        Decatur, IL                                   Lake Charles, LA 
##                                                 80                                                 81                                                 81 
##                        South Bend-Mishawaka, IN-MI                                        Altoona, PA                       Huntington-Ashland, WV-KY-OH 
##                                                 81                                                 82                                                 82 
##                                        Medford, OR                            Naples-Marco Island, FL                                      St. Cloud, MN 
##                                                 82                                                 82                                                 82 
##                                      Ann Arbor, MI                                 Oshkosh-Neenah, WI                      Hagerstown-Martinsburg, MD-WV 
##                                                 85                                                 85                                                 86 
##                           Bremerton-Silverdale, WA                                           Erie, PA                               Kankakee-Bradley, IL 
##                                                 87                                                 87                                                 87 
##                                       Kingston, NY                                       Amarillo, TX                                         Laredo, TX 
##                                                 87                                                 88                                                 89 
##                                   Harrisonburg, VA                         Muskegon-Norton Shores, MI                                  Trenton-Ewing, NJ 
##                                                 90                                                 90                                                 91 
##                                        Decatur, Al                                         Wausau, WI                                         Lawton, OK 
##                                                 96                                                 96                                                 97 
##                                       Lawrence, KS                                      El Centro, CA                                  Evansville, IN-KY 
##                                                 98                                                 99                                                 99 
##                                     Janesville, WI                                        Olympia, WA                                    Spartanburg, SC 
##                                                 99                                                 99                                                 99 
##                       Killeen-Temple-Fort Hood, TX                                          Flint, MI         Myrtle Beach-Conway-North Myrtle Beach, SC 
##                                                101                                                102                                                102 
##                                     Montgomery, AL                                    Bloomington, IN                                        Salinas, CA 
##                                                103                                                104                                                104 
##                                  Fort Smith, AR-OK                                         Merced, CA                                     Las Cruses, NM 
##                                                105                                                106                                                107 
##                     Pensacola-Ferry Pass-Brent, FL                     Port St. Lucie-Fort Pierce, FL                                     Eau Claire, WI 
##                                                107                                                109                                                110 
##                                         Mobile, AL                                  Atlantic City, NJ                                        Danbury, CT 
##                                                110                                                111                                                112 
##                                         Peoria, IL                                         Yakima, WA                                      La Crosse, WI 
##                                                112                                                112                                                114 
##                                       Rockford, IL                                      Asheville, NC                                       Victoria, TX 
##                                                114                                                116                                                116 
##                                  Coeur d'Alene, ID                                     Huntsville, AL                                   York-Hanover, PA 
##                                                117                                                117                                                117 
##                               Canton-Massillon, OH                           Lansing-East Lansing, MI                                         Racine, WI 
##                                                118                                                119                                                119 
##                            Visalia-Porterville, CA                               Champaign-Urbana, IL                           Beaumont-Port Author, TX 
##                                                121                                                122                                                123 
##                                        Appleton,WI                                      Duluth, MN-WI                              Kalamazoo-Portage, MI 
##                                                125                                                126                                                127 
##                                  Winston-Salem, NC                            Santa Rosa-Petaluma, CA                                         Pueblo, CO 
##                                                127                                                129                                                130 
##                                      Iowa City, IA                                 Corpus Christi, TX               Santa Barbara-Santa Maria-Goleta, CA 
##                                                131                                                132                                                132 
##                              Vallejo-Fairfield, CA                                     Fort Wayne, IN                                      Green Bay, WI 
##                                                133                                                136                                                136 
##                                           Bend, OR             Deltona-Daytona Beach-Ormond Beach, FL                                        Reading, PA 
##                                                140                                                140                                                142 
##                                   Worcester, MA-CT                          Cape Coral-Fort Myers, FL                        Shreveport-Bossier City, LA 
##                                                144                                                146                                                146 
##                          Lakeland-Winter Haven, FL                     Youngstown-Warren-Boardman, OH                                 Springfield, MA-CT 
##                                                149                                                153                                                155 
##                                      Lancaster, PA                                        Spokane, WA                           Waterloo-Cedar Falls, IA 
##                                                156                                                156                                                156 
##                                      Waterbury, CT                                        Modesto, CA                     Augusta-Richmond County, GA-SC 
##                                                157                                                158                                                161 
##                                    Springfield, MO                                        Greeley, CO                                 Chattanooga, TN-GA 
##                                                161                                                162                                                167 
##                                      Knoxville, TN                  Palm Bay-Melbourne-Titusville, FL                                          Salem, OR 
##                                                168                                                168                                                170 
##                                        Boulder, CO                            Harrisburg-Carlisle, PA                          Scranton-Wilkes Barre, PA 
##                                                171                                                174                                                176 
##                                         Monroe, LA                                      Lafayette, LA                                         Topeka, KS 
##                                                179                                                181                                                182 
##                                     Greenville, SC                                         Durham, NC                      Sarasota-Bradenton-Venice, FL 
##                                                185                                                189                                                192 
##                                       Stockton, CA                         McAllen-Edinburg-Pharr, TX                                   Cedar Rapids, IA 
##                                                193                                                195                                                196 
##                             Eugene-Springfield, OR                              Lexington-Fayette, KY                                       Billings, MT 
##                                                196                                                198                                                199 
##               Poughkeepsie-Newburgh-Middletown, NY                                       Savannah, GA                          Norwich-New London, CT-RI 
##                                                201                                                202                                                203 
##                          Fort Collins-Loveland, CO                                         Bangor, ME              Fayetteville-Springdale-Rogers, AR-MO 
##                                                206                                                208                                                215 
##                                        Jackson, MS                                       Syracuse, NY                                          Akron, OH 
##                                                222                                                223                                                231 
##                    Charleston-North Charleston, SC                                         Toledo, OH                Davenport-Moline-Rock Island, IA-IL 
##                                                232                                                235                                                240 
##                                        El Paso, TX                                    Bakersfield, CA                          Greensboro-High Point, NC 
##                                                244                                                245                                                251 
##                                    Baton Rouge, LA                                     Charleston, WV                             Rochester-Dover, NH-ME 
##                                                262                                                262                                                262 
##                   Oxnard-Thousand Oaks-Ventura, CA                        Albany-Schenectady-Troy, NY                                         Dayton, OH 
##                                                267                                                268                                                268 
##                                        Madison, WI                                       Columbia, SC                                         Tucson, AZ 
##                                                284                                                291                                                302 
##                                         Fresno, CA                           Grand Rapids-Wyoming, MI                                      Rochester, NY 
##                                                303                                                304                                                307 
##                                     Provo-Orem, UT                                    Reno-Sparks, NV                                          Tulsa, OK 
##                                                309                                                310                                                323 
##                  Allentown-Bethlehem-Easton, PA-NJ                                   Raleigh-Cary, NC                          Buffalo-Niagara Falls, NY 
##                                                334                                                336                                                344 
##                                  Memphis, TN-MS-AR                    New Orleans-Metairie-Kenner, LA                               Colorado Springs, CO 
##                                                348                                                367                                                372 
##                              Birmingham-Hoover, AL                                   Jacksonville, FL                  Little Rock-North Little Rock, AR 
##                                                392                                                393                                                404 
##                               Ogden-Clearfield, UT                                        Wichita, KS                                       Fargo, ND-MN 
##                                                423                                                427                                                432 
##                                          Dover, DE                                       Richmond, VA                                     Des Moines, IA 
##                                                456                                                490                                                501 
##                Nashville-Davidson-Murfreesboro, TN                                      New Haven, CT                              Austin-Round Rock, TX 
##                                                505                                                506                                                516 
##                  Charlotte-Gastonia-Concord, NC-SC                                  Louisville, KY-IN                                       Columbus, OH 
##                                                517                                                519                                                551 
##                                   Indianapolis, IN                                    Sioux Falls, SD         Virginia Beach-Norfolk-Newport News, VA-NC 
##                                                570                                                595                                                597 
##                                  Oklahoma City, OK                                    San Antonio, TX                                    Albuquerque, NM 
##                                                604                                                607                                                609 
##                                        Orlando, FL                               Boise City-Nampa, ID                    Burlington-South Burlington, VT 
##                                                610                                                644                                                657 
##              Sacramento-Arden-Arcade-Roseville, CA                 San Jose-Sunnyvale-Santa Clara, CA                        Cleveland-Elyria-Mentor, OH 
##                                                667                                                670                                                681 
##                        Portland-South Portland, ME                  Milwaukee-Waukesha-West Allis, WI                    Cincinnati-Middletown, OH-KY-IN 
##                                                701                                                714                                                719 
##                                 Salt Lake City, UT                    Bridgeport-Stamford-Norwalk, CT                                     Pittsburgh, PA 
##                                                723                                                730                                                732 
##                Tampa-St. Petersburg-Clearwater, FL           Hartford-West Hartford-East Hartford, CT                  San Diego-Carlsbad-San Marcos, CA 
##                                                842                                                885                                                907 
##                                   St. Louis, MO-IL                        Omaha-Council Bluffs, NE-IA                                 Kansas City, MO-KS 
##                                                956                                                957                                                962 
##                        Phoenix-Mesa-Scottsdale, AZ                Portland-Vancouver-Beaverton, OR-WA                        Seattle-Tacoma-Bellevue, WA 
##                                                971                                               1089                                               1255 
##                       Riverside-San Bernardino, CA                             Las Vegas-Paradise, NV                         Detroit-Warren-Livonia, MI 
##                                               1290                                               1299                                               1354 
##                  San Francisco-Oakland-Fremont, CA                               Baltimore-Towson, MD                                  Denver-Aurora, CO 
##                                               1386                                               1483                                               1504 
##                 Atlanta-Sandy Springs-Marietta, GA              Miami-Fort Lauderdale-Miami Beach, FL                                       Honolulu, HI 
##                                               1552                                               1554                                               1576 
##                     Houston-Baytown-Sugar Land, TX                    Dallas-Fort Worth-Arlington, TX             Minneapolis-St Paul-Bloomington, MN-WI 
##                                               1649                                               1863                                               1942 
##                     Boston-Cambridge-Quincy, MA-NH               Providence-Fall River-Warwick, MA-RI                Chicago-Naperville-Joliet, IN-IN-WI 
##                                               2229                                               2284                                               2772 
##           Philadelphia-Camden-Wilmington, PA-NJ-DE               Los Angeles-Long Beach-Santa Ana, CA       Washington-Arlington-Alexandria, DC-VA-MD-WV 
##                                               2855                                               4102                                               4177 
## New York-Northern New Jersey-Long Island, NY-NJ-PA 
##                                               5409

Explanation: From table(CPS$MetroArea), we can read that Boston-Cambridge-Quincy, MA-NH has the largest number of interviewees of these options, with 2229.

Which metropolitan area has the highest proportion of interviewees of Hispanic ethnicity?

sort(tapply(CPS$Hispanic, CPS$MetroArea, mean))
##                                       Anderson, SC                                      Ann Arbor, MI                                Barnstable Town, MA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                              Bloomington-Normal IL                                    Bloomington, IN                                  Bowling Green, KY 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                        Decatur, IL                                     Eau Claire, WI                                       Florence, AL 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                      Hagerstown-Martinsburg, MD-WV                                   Harrisonburg, VA                       Huntington-Ashland, WV-KY-OH 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Huntsville, AL                                        Jackson, MI                                      Johnstown, PA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                          Macon, GA                                         Mobile, AL                                      Salisbury, MD 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                       Savannah, GA                                  Warner Robins, GA                                         Dayton, OH 
##                                        0.000000000                                        0.000000000                                        0.003731343 
##                                         Monroe, LA                                      Knoxville, TN                                     Charleston, WV 
##                                        0.005586592                                        0.005952381                                        0.007633588 
##                                        Appleton,WI                                        Jackson, MS                    Burlington-South Burlington, VT 
##                                        0.008000000                                        0.009009009                                        0.009132420 
##                                     Montgomery, AL                                         Wausau, WI                        Portland-South Portland, ME 
##                                        0.009708738                                        0.010416667                                        0.011412268 
##                                 Oshkosh-Neenah, WI                                        Altoona, PA                                      St. Cloud, MN 
##                                        0.011764706                                        0.012195122                                        0.012195122 
##                            Holland-Grand Haven, MI                                          Akron, OH                                    Springfield, IL 
##                                        0.012820513                                        0.012987013                                        0.013157895 
##                                     Bellingham, WA                                         Bangor, ME                           Kingsport-Bristol, TN-VA 
##                                        0.014285714                                        0.014423077                                        0.014925373 
##                                   Cedar Rapids, IA                                Gulfport-Biloxi, MS                                      Duluth, MN-WI 
##                                        0.015306122                                        0.015384615                                        0.015873016 
##                                     Pittsburgh, PA                                         Joplin, MO                    Charleston-North Charleston, SC 
##                                        0.016393443                                        0.016949153                                        0.017241379 
##                          Buffalo-Niagara Falls, NY                                      La Crosse, WI                            Niles-Benton Harbor, MI 
##                                        0.017441860                                        0.017543860                                        0.019607843 
##                                  Evansville, IN-KY                                    Spartanburg, SC                                           Bend, OR 
##                                        0.020202020                                        0.020202020                                        0.021428571 
##                         Muskegon-Norton Shores, MI                                           Erie, PA                            Harrisburg-Carlisle, PA 
##                                        0.022222222                                        0.022988506                                        0.022988506 
##                                        Madison, WI                                   Lake Charles, LA                                       Fargo, ND-MN 
##                                        0.024647887                                        0.024691358                                        0.025462963 
##                                  Coeur d'Alene, ID                                        Spokane, WA                 Saginaw-Saginaw Township North, MI 
##                                        0.025641026                                        0.025641026                                        0.027027027 
##                                      Lynchburg, VA                     Pensacola-Ferry Pass-Brent, FL                                  Memphis, TN-MS-AR 
##                                        0.027397260                                        0.028037383                                        0.028735632 
##                                    Springfield, OH                                       Billings, MT                                     Janesville, WI 
##                                        0.029411765                                        0.030150754                                        0.030303030 
##                                        Roanoke, VA                                   St. Louis, MO-IL                                      Iowa City, IA 
##                                        0.030303030                                        0.030334728                                        0.030534351 
##                             Rochester-Dover, NH-ME                              Kalamazoo-Portage, MI                     Youngstown-Warren-Boardman, OH 
##                                        0.030534351                                        0.031496063                                        0.032679739 
##                               Champaign-Urbana, IL                                         Toledo, OH                                     Fort Wayne, IN 
##                                        0.032786885                                        0.034042553                                        0.036764706 
##                  Little Rock-North Little Rock, AR                         Detroit-Warren-Livonia, MI                                     Greenville, SC 
##                                        0.037128713                                        0.037666174                                        0.037837838 
##                                    Baton Rouge, LA                                   Johnson City, TN                                  Louisville, KY-IN 
##                                        0.038167939                                        0.038461538                                        0.038535645 
##                         Michigan City-La Porte, IN                                          Flint, MI                    Cincinnati-Middletown, OH-KY-IN 
##                                        0.038961039                                        0.039215686                                        0.040333797 
##                              Lexington-Fayette, KY                                       Lawrence, KS                        Albany-Schenectady-Troy, NY 
##                                        0.040404040                                        0.040816327                                        0.041044776 
##                                     Binghamton, NY                                    Punta Gorda, FL                                    Sioux Falls, SD 
##                                        0.041095890                                        0.041666667                                        0.042016807 
##                                       Columbia, MO                                   York-Hanover, PA                                    Gainesville, FL 
##                                        0.042553191                                        0.042735043                                        0.042857143 
##                                       Richmond, VA                                    Springfield, MO                                       Columbus, OH 
##                                        0.042857143                                        0.043478261                                        0.043557169 
##                                       Rockford, IL                                         Albany, GA                      Sarasota-Bradenton-Venice, FL 
##                                        0.043859649                                        0.044117647                                        0.046875000 
##                                       Valdosta, GA                                Anniston-Oxford, AL                        South Bend-Mishawaka, IN-MI 
##                                        0.047619048                                        0.049180328                                        0.049382716 
##         Virginia Beach-Norfolk-Newport News, VA-NC             Minneapolis-St Paul-Bloomington, MN-WI                                        Decatur, Al 
##                                        0.050251256                                        0.052008239                                        0.052083333 
##                              Birmingham-Hoover, AL                  Palm Bay-Melbourne-Titusville, FL                                  Winston-Salem, NC 
##                                        0.053571429                                        0.053571429                                        0.055118110 
##                                          Dover, DE                           Bremerton-Silverdale, WA                                      Rochester, NY 
##                                        0.057017544                                        0.057471264                                        0.058631922 
##         Myrtle Beach-Conway-North Myrtle Beach, SC                                         Racine, WI                                       Honolulu, HI 
##                                        0.058823529                                        0.058823529                                        0.059644670 
##                        Cleveland-Elyria-Mentor, OH                                      Asheville, NC                                      Lafayette, LA 
##                                        0.060205580                                        0.060344828                                        0.060773481 
##                                         Peoria, IL                                         Monroe, MI                                       Anderson, IN 
##                                        0.062500000                                        0.063492063                                        0.064516129 
##                                     Provo-Orem, UT                                     Ocean City, NJ                         Panama City-Lynn Haven, FL 
##                                        0.064724919                                        0.066666667                                        0.067796610 
##                                       Kingston, NY                Nashville-Davidson-Murfreesboro, TN                     Boston-Cambridge-Quincy, MA-NH 
##                                        0.068965517                                        0.069306931                                        0.069537909 
##                                    Tallahassee, FL                        Omaha-Council Bluffs, NE-IA                                   Indianapolis, IN 
##                                        0.069767442                                        0.070010449                                        0.071929825 
##                                      New Haven, CT                                     Des Moines, IA                                     Utica-Rome, NY 
##                                        0.073122530                                        0.073852295                                        0.075000000 
##                          Greensboro-High Point, NC                                     Vero Beach, FL                               Canton-Massillon, OH 
##                                        0.075697211                                        0.075949367                                        0.076271186 
##                             Eugene-Springfield, OR                                 Chattanooga, TN-GA           Philadelphia-Camden-Wilmington, PA-NJ-DE 
##                                        0.076530612                                        0.077844311                                        0.078458844 
##                                       Columbia, SC                                       Syracuse, NY                        Shreveport-Bossier City, LA 
##                                        0.079037801                                        0.080717489                                        0.082191781 
##                               Baltimore-Towson, MD                                   Worcester, MA-CT                           Lansing-East Lansing, MI 
##                                        0.082265678                                        0.083333333                                        0.084033613 
##                                        Medford, OR                  Milwaukee-Waukesha-West Allis, WI                 Atlanta-Sandy Springs-Marietta, GA 
##                                        0.085365854                                        0.085434174                                        0.085695876 
##                                  Fort Smith, AR-OK                  Allentown-Bethlehem-Easton, PA-NJ                      Hickory-Morgantown-Lenoir, NC 
##                                        0.085714286                                        0.086826347                                        0.087719298 
##                        Seattle-Tacoma-Bellevue, WA                                  Atlantic City, NJ                   Leominster-Fitchburg-Gardner, MA 
##                                        0.088446215                                        0.090090090                                        0.090909091 
##                                   Jacksonville, FL                Davenport-Moline-Rock Island, IA-IL                     Augusta-Richmond County, GA-SC 
##                                        0.091603053                                        0.091666667                                        0.093167702 
##                               Boise City-Nampa, ID                                         Topeka, KS                Portland-Vancouver-Beaverton, OR-WA 
##                                        0.093167702                                        0.093406593                                        0.094582185 
##             Deltona-Daytona Beach-Ormond Beach, FL                     Port St. Lucie-Fort Pierce, FL                                      Lancaster, PA 
##                                        0.100000000                                        0.100917431                                        0.102564103 
##                                     Tuscaloosa, AL                          Norwich-New London, CT-RI           Hartford-West Hartford-East Hartford, CT 
##                                        0.102564103                                        0.103448276                                        0.105084746 
##                                  Oklahoma City, OK                           Waterloo-Cedar Falls, IA                                         Durham, NC 
##                                        0.107615894                                        0.108974359                                        0.111111111 
##                    New Orleans-Metairie-Kenner, LA                    Bridgeport-Stamford-Norwalk, CT             Fort Walton Beach-Crestview-Destin, FL 
##                                        0.111716621                                        0.112328767                                        0.112500000 
##               Providence-Fall River-Warwick, MA-RI                                          Tulsa, OK                               Kankakee-Bradley, IL 
##                                        0.114273205                                        0.114551084                                        0.114942529 
##                                          Chico, CA                  Charlotte-Gastonia-Concord, NC-SC                                   Raleigh-Cary, NC 
##                                        0.116666667                                        0.117988395                                        0.119047619 
##                               Colorado Springs, CO                                        Olympia, WA                          Fort Collins-Loveland, CO 
##                                        0.120967742                                        0.121212121                                        0.121359223 
##       Washington-Arlington-Alexandria, DC-VA-MD-WV                                 Kansas City, MO-KS                            Athens-Clark County, GA 
##                                        0.121378980                                        0.121621622                                        0.123076923 
##                                         Lawton, OK                                      Green Bay, WI                                   Jacksonville, NC 
##                                        0.123711340                                        0.125000000                                        0.126984127 
##                                       Prescott, AZ                                  Trenton-Ewing, NJ                                        Wichita, KS 
##                                        0.129629630                                        0.131868132                                        0.133489461 
##                          Lakeland-Winter Haven, FL                          Scranton-Wilkes Barre, PA                           Grand Rapids-Wyoming, MI 
##                                        0.134228188                                        0.136363636                                        0.138157895 
##                               Ogden-Clearfield, UT                                        Boulder, CO              Fayetteville-Springdale-Rogers, AR-MO 
##                                        0.144208038                                        0.146198830                                        0.148837209 
##                         Santa-Cruz-Watsonville, CA                                 Salt Lake City, UT                                   Fayetteville, NC 
##                                        0.151515152                                        0.154910097                                        0.155844156 
##                                          Ocala, FL                Tampa-St. Petersburg-Clearwater, FL                                        Greeley, CO 
##                                        0.157894737                                        0.159144893                                        0.160493827 
##                Chicago-Naperville-Joliet, IN-IN-WI                            Naples-Marco Island, FL                                    Reno-Sparks, NV 
##                                        0.167388167                                        0.182926829                                        0.196774194 
##                  San Francisco-Oakland-Fremont, CA                                    Columbus, GA-AL                              Vallejo-Fairfield, CA 
##                                        0.199855700                                        0.203389831                                        0.210526316 
##                                        Reading, PA                                          Salem, OR                                        Orlando, FL 
##                                        0.211267606                                        0.211764706                                        0.213114754 
##                                 Springfield, MA-CT                           Beaumont-Port Author, TX New York-Northern New Jersey-Long Island, NY-NJ-PA 
##                                        0.219354839                                        0.227642276                                        0.228508042 
##                                           Napa, CA                                  Denver-Aurora, CO                            Santa Rosa-Petaluma, CA 
##                                        0.229508197                                        0.232047872                                        0.232558140 
##                                     Farmington, NM                    San Luis Obispo-Paso Robles, CA                                      Waterbury, CT 
##                                        0.234375000                                        0.246753247                                        0.248407643 
##                             Las Vegas-Paradise, NV                        Phoenix-Mesa-Scottsdale, AZ                                       Amarillo, TX 
##                                        0.251732102                                        0.254376931                                        0.261363636 
##              Sacramento-Arden-Arcade-Roseville, CA                  San Diego-Carlsbad-San Marcos, CA               Poughkeepsie-Newburgh-Middletown, NY 
##                                        0.263868066                                        0.269018743                                        0.273631841 
##                    Dallas-Fort Worth-Arlington, TX                                        Lubbock, TX                                       Longview, TX 
##                                        0.283950617                                        0.285714286                                        0.292307692 
##                                         Pueblo, CO                              Austin-Round Rock, TX                 San Jose-Sunnyvale-Santa Clara, CA 
##                                        0.307692308                                        0.310077519                                        0.316417910 
##                                       Stockton, CA                                           Waco, TX                                        Danbury, CT 
##                                        0.321243523                                        0.329113924                                        0.339285714 
##                                        Modesto, CA                                        Midland, TX                                         Yakima, WA 
##                                        0.341772152                                        0.352941176                                        0.357142857 
##                     Houston-Baytown-Sugar Land, TX                   Oxnard-Thousand Oaks-Ventura, CA                       Killeen-Temple-Fort Hood, TX 
##                                        0.359005458                                        0.359550562                                        0.386138614 
##               Santa Barbara-Santa Maria-Goleta, CA                   Vineland-Millville-Bridgeton, NJ                                         Fresno, CA 
##                                        0.401515152                                        0.407407407                                        0.409240924 
##                            Visalia-Porterville, CA                          Cape Coral-Fort Myers, FL                                    Albuquerque, NM 
##                                        0.438016529                                        0.438356164                                        0.441707718 
##               Los Angeles-Long Beach-Santa Ana, CA                                       Santa Fe, NM                                       Victoria, TX 
##                                        0.460263286                                        0.461538462                                        0.465517241 
##              Miami-Fort Lauderdale-Miami Beach, FL                                    Bakersfield, CA                       Riverside-San Bernardino, CA 
##                                        0.467824968                                        0.489795918                                        0.502325581 
##                                         Tucson, AZ                                     Las Cruses, NM                                        Salinas, CA 
##                                        0.506622517                                        0.542056075                                        0.557692308 
##                                         Merced, CA                                 Corpus Christi, TX                                         Madera, CA 
##                                        0.566037736                                        0.606060606                                        0.614035088 
##                                    San Antonio, TX                                      El Centro, CA                                        El Paso, TX 
##                                        0.644151565                                        0.686868687                                        0.790983607 
##                          Brownsville-Harlingen, TX                         McAllen-Edinburg-Pharr, TX                                         Laredo, TX 
##                                        0.797468354                                        0.948717949                                        0.966292135

Explanation: 96.6% of the interviewees from Laredo, TX, are of Hispanic ethnicity, the highest proportion among metropolitan areas in the United States.

Determine the number of metropolitan areas in the United States from which at least 20% of interviewees are Asian?

sort(tapply(CPS$Race == "Asian", CPS$MetroArea, mean))
##                                         Albany, GA                                        Altoona, PA                                       Amarillo, TX 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                       Anderson, IN                                        Appleton,WI                                      Asheville, NC 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                Barnstable Town, MA                           Beaumont-Port Author, TX                                       Billings, MT 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Binghamton, NY                                    Bloomington, IN                                  Bowling Green, KY 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                               Canton-Massillon, OH                                     Charleston, WV                                          Chico, CA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                    Columbus, GA-AL                                        Decatur, IL                                         Durham, NC 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Eau Claire, WI                                        El Paso, TX                                           Erie, PA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Farmington, NM                                       Florence, AL                      Hagerstown-Martinsburg, MD-WV 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Huntsville, AL                                        Jackson, MI                                        Jackson, MS 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                     Janesville, WI                                   Johnson City, TN                                         Joplin, MO 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                               Kankakee-Bradley, IL                       Killeen-Temple-Fort Hood, TX                           Kingsport-Bristol, TN-VA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                      Knoxville, TN                                      Lafayette, LA                           Lansing-East Lansing, MI 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                         Laredo, TX                   Leominster-Fitchburg-Gardner, MA                                       Longview, TX 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                        Lubbock, TX                                      Lynchburg, VA                                          Macon, GA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                         Madera, CA                         McAllen-Edinburg-Pharr, TX                         Michigan City-La Porte, IN 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                        Midland, TX                                         Monroe, MI                         Muskegon-Norton Shores, MI 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##         Myrtle Beach-Conway-North Myrtle Beach, SC                            Niles-Benton Harbor, MI                                     Ocean City, NJ 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                 Oshkosh-Neenah, WI                     Port St. Lucie-Fort Pierce, FL               Poughkeepsie-Newburgh-Middletown, NY 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                         Pueblo, CO                                    Punta Gorda, FL                                         Racine, WI 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                        Reading, PA                                        Roanoke, VA                                       Rockford, IL 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                 Saginaw-Saginaw Township North, MI                                          Salem, OR                                      Salisbury, MD 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                         Santa-Cruz-Watsonville, CA                                       Santa Fe, NM                          Scranton-Wilkes Barre, PA 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                        Shreveport-Bossier City, LA                        South Bend-Mishawaka, IN-MI                                    Spartanburg, SC 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                 Springfield, MA-CT                                    Springfield, OH                                      St. Cloud, MN 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                    Tallahassee, FL                                     Tuscaloosa, AL                                     Utica-Rome, NY 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                       Valdosta, GA                                     Vero Beach, FL                                       Victoria, TX 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                   Vineland-Millville-Bridgeton, NJ                                           Waco, TX                                      Waterbury, CT 
##                                        0.000000000                                        0.000000000                                        0.000000000 
##                                         Wausau, WI                                   St. Louis, MO-IL                    New Orleans-Metairie-Kenner, LA 
##                                        0.000000000                                        0.002092050                                        0.002724796 
##                                    San Antonio, TX                    Charleston-North Charleston, SC                                         Monroe, LA 
##                                        0.003294893                                        0.004310345                                        0.005586592 
##                                 Chattanooga, TN-GA                                        Modesto, CA                                           Bend, OR 
##                                        0.005988024                                        0.006329114                                        0.007142857 
##                                         Dayton, OH               Santa Barbara-Santa Maria-Goleta, CA                            Santa Rosa-Petaluma, CA 
##                                        0.007462687                                        0.007575758                                        0.007751938 
##                                         Toledo, OH                                  Coeur d'Alene, ID                                   York-Hanover, PA 
##                                        0.008510638                                        0.008547009                                        0.008547009 
##                                         Yakima, WA                           Grand Rapids-Wyoming, MI                                    Sioux Falls, SD 
##                                        0.008928571                                        0.009868421                                        0.010084034 
##                                  Evansville, IN-KY                                       Lawrence, KS                        Cleveland-Elyria-Mentor, OH 
##                                        0.010101010                                        0.010204082                                        0.010279001 
##                                         Lawton, OK                               Boise City-Nampa, ID                            Harrisburg-Carlisle, PA 
##                                        0.010309278                                        0.010869565                                        0.011494253 
##                                       Kingston, NY                                  Louisville, KY-IN                                        Medford, OR 
##                                        0.011494253                                        0.011560694                                        0.012195122 
##                                        Greeley, CO                                    Springfield, MO                              Birmingham-Hoover, AL 
##                                        0.012345679                                        0.012422360                                        0.012755102 
##                           Waterloo-Cedar Falls, IA                                     Provo-Orem, UT                     Youngstown-Warren-Boardman, OH 
##                                        0.012820513                                        0.012944984                                        0.013071895 
##                                          Ocala, FL                  Allentown-Bethlehem-Easton, PA-NJ                                 Corpus Christi, TX 
##                                        0.013157895                                        0.014970060                                        0.015151515 
##                                          Dover, DE                  Charlotte-Gastonia-Concord, NC-SC                      Sarasota-Bradenton-Venice, FL 
##                                        0.015350877                                        0.015473888                                        0.015625000 
##                              Kalamazoo-Portage, MI                                  Winston-Salem, NC                                      Johnstown, PA 
##                                        0.015748031                                        0.015748031                                        0.015873016 
##                               Colorado Springs, CO                               Champaign-Urbana, IL                                           Napa, CA 
##                                        0.016129032                                        0.016393443                                        0.016393443 
##                         Panama City-Lynn Haven, FL                                  Memphis, TN-MS-AR                                       Columbus, OH 
##                                        0.016949153                                        0.017241379                                        0.018148820 
##                                       Prescott, AZ                                     Las Cruses, NM                     Pensacola-Ferry Pass-Brent, FL 
##                                        0.018518519                                        0.018691589                                        0.018691589 
##                                        Spokane, WA                          Fort Collins-Loveland, CO                                          Flint, MI 
##                                        0.019230769                                        0.019417476                                        0.019607843 
##                                       Savannah, GA                                         Tucson, AZ                                      El Centro, CA 
##                                        0.019801980                                        0.019867550                                        0.020202020 
##                             Eugene-Springfield, OR                Davenport-Moline-Rock Island, IA-IL             Deltona-Daytona Beach-Ormond Beach, FL 
##                                        0.020408163                                        0.020833333                                        0.021428571 
##                                         Topeka, KS                    Cincinnati-Middletown, OH-KY-IN                  Little Rock-North Little Rock, AR 
##                                        0.021978022                                        0.022253129                                        0.022277228 
##                        Albany-Schenectady-Troy, NY                                    Baton Rouge, LA                           Bremerton-Silverdale, WA 
##                                        0.022388060                                        0.022900763                                        0.022988506 
##                                         Bangor, ME                            Naples-Marco Island, FL                                   Indianapolis, IN 
##                                        0.024038462                                        0.024390244                                        0.024561404 
##                     Augusta-Richmond County, GA-SC                            Holland-Grand Haven, MI                                   Fayetteville, NC 
##                                        0.024844720                                        0.025641026                                        0.025974026 
##                               Ogden-Clearfield, UT                             Rochester-Dover, NH-ME         Virginia Beach-Norfolk-Newport News, VA-NC 
##                                        0.026004728                                        0.026717557                                        0.026800670 
##                          Lakeland-Winter Haven, FL                                       Columbia, SC                                       Fargo, ND-MN 
##                                        0.026845638                                        0.027491409                                        0.027777778 
##                                     Bellingham, WA                                     Montgomery, AL                        Omaha-Council Bluffs, NE-IA 
##                                        0.028571429                                        0.029126214                                        0.029258098 
##                                          Akron, OH                                        Wichita, KS                            Athens-Clark County, GA 
##                                        0.030303030                                        0.030444965                                        0.030769231 
##                                Gulfport-Biloxi, MS                                       Anderson, SC                                  Denver-Aurora, CO 
##                                        0.030769231                                        0.031250000                                        0.031914894 
##                                     Greenville, SC           Philadelphia-Camden-Wilmington, PA-NJ-DE                                   Harrisonburg, VA 
##                                        0.032432432                                        0.032924694                                        0.033333333 
##                          Cape Coral-Fort Myers, FL                                 Kansas City, MO-KS                                   Worcester, MA-CT 
##                                        0.034246575                                        0.034303534                                        0.034722222 
##                                  Oklahoma City, OK                      Hickory-Morgantown-Lenoir, NC                              Lexington-Fayette, KY 
##                                        0.034768212                                        0.035087719                                        0.035353535 
##              Miami-Fort Lauderdale-Miami Beach, FL                  Palm Bay-Melbourne-Titusville, FL                                 Salt Lake City, UT 
##                                        0.035392535                                        0.035714286                                        0.035961272 
##                                         Mobile, AL                       Huntington-Ashland, WV-KY-OH                                       Richmond, VA 
##                                        0.036363636                                        0.036585366                                        0.036734694 
##                                     Fort Wayne, IN             Fort Walton Beach-Crestview-Destin, FL                                     Des Moines, IA 
##                                        0.036764706                                        0.037500000                                        0.037924152 
##                        Phoenix-Mesa-Scottsdale, AZ                                     Pittsburgh, PA                    Bridgeport-Stamford-Norwalk, CT 
##                                        0.038105046                                        0.038251366                                        0.038356164 
##               Providence-Fall River-Warwick, MA-RI                Tampa-St. Petersburg-Clearwater, FL                                      Duluth, MN-WI 
##                                        0.038966725                                        0.039192399                                        0.039682540 
##                                       Syracuse, NY                                    Albuquerque, NM                                        Decatur, Al 
##                                        0.040358744                                        0.041050903                                        0.041666667 
##                        Portland-South Portland, ME                                    Gainesville, FL                         Detroit-Warren-Livonia, MI 
##                                        0.042796006                                        0.042857143                                        0.043574594 
##                                  Trenton-Ewing, NJ                                      New Haven, CT                                   Jacksonville, NC 
##                                        0.043956044                                        0.047430830                                        0.047619048 
##                  Milwaukee-Waukesha-West Allis, WI                                   Jacksonville, FL                    Burlington-South Burlington, VT 
##                                        0.047619048                                        0.048346056                                        0.048706240 
##                                Anniston-Oxford, AL                                          Tulsa, OK                                   Raleigh-Cary, NC 
##                                        0.049180328                                        0.049535604                                        0.050595238 
##                                        Orlando, FL              Fayetteville-Springdale-Rogers, AR-MO                    San Luis Obispo-Paso Robles, CA 
##                                        0.050819672                                        0.051162791                                        0.051948052 
##                     Boston-Cambridge-Quincy, MA-NH                              Austin-Round Rock, TX                          Buffalo-Niagara Falls, NY 
##                                        0.052041274                                        0.052325581                                        0.052325581 
##                                    Springfield, IL                                      Iowa City, IA                                         Peoria, IL 
##                                        0.052631579                                        0.053435115                                        0.053571429 
##                                        Madison, WI                                         Merced, CA                                  Fort Smith, AR-OK 
##                                        0.056338028                                        0.056603774                                        0.057142857 
##                Nashville-Davidson-Murfreesboro, TN                                      Lancaster, PA                               Baltimore-Towson, MD 
##                                        0.057425743                                        0.057692308                                        0.057990560 
##                                    Reno-Sparks, NV                Chicago-Naperville-Joliet, IN-IN-WI                                        Boulder, CO 
##                                        0.058064516                                        0.058441558                                        0.058479532 
##                     Houston-Baytown-Sugar Land, TX                       Riverside-San Bernardino, CA                                        Danbury, CT 
##                                        0.061249242                                        0.062015504                                        0.062500000 
##                    Dallas-Fort Worth-Arlington, TX                                       Columbia, MO                                      Rochester, NY 
##                                        0.062801932                                        0.063829787                                        0.065146580 
##                                   Cedar Rapids, IA           Hartford-West Hartford-East Hartford, CT                Portland-Vancouver-Beaverton, OR-WA 
##                                        0.066326531                                        0.066666667                                        0.069788797 
##       Washington-Arlington-Alexandria, DC-VA-MD-WV                 Atlanta-Sandy Springs-Marietta, GA                          Norwich-New London, CT-RI 
##                                        0.070624850                                        0.072809278                                        0.073891626 
##                                   Lake Charles, LA                   Oxnard-Thousand Oaks-Ventura, CA                              Bloomington-Normal IL 
##                                        0.074074074                                        0.074906367                                        0.075000000 
##                          Brownsville-Harlingen, TX             Minneapolis-St Paul-Bloomington, MN-WI                             Las Vegas-Paradise, NV 
##                                        0.075949367                                        0.076725026                                        0.078521940 
##                          Greensboro-High Point, NC                                    Bakersfield, CA                                      Ann Arbor, MI 
##                                        0.079681275                                        0.081632653                                        0.082352941 
##                                      La Crosse, WI                                      Green Bay, WI                            Visalia-Porterville, CA 
##                                        0.087719298                                        0.088235294                                        0.090909091 
##                        Seattle-Tacoma-Bellevue, WA New York-Northern New Jersey-Long Island, NY-NJ-PA                                        Salinas, CA 
##                                        0.099601594                                        0.104270660                                        0.125000000 
##                                        Olympia, WA               Los Angeles-Long Beach-Santa Ana, CA                  San Diego-Carlsbad-San Marcos, CA 
##                                        0.131313131                                        0.135056070                                        0.142227122 
##              Sacramento-Arden-Arcade-Roseville, CA                                  Atlantic City, NJ                                       Stockton, CA 
##                                        0.142428786                                        0.144144144                                        0.155440415 
##                                  Warner Robins, GA                                         Fresno, CA                              Vallejo-Fairfield, CA 
##                                        0.166666667                                        0.184818482                                        0.203007519 
##                 San Jose-Sunnyvale-Santa Clara, CA                  San Francisco-Oakland-Fremont, CA                                       Honolulu, HI 
##                                        0.241791045                                        0.246753247                                        0.501903553

Explanation: We can read from the sorted output that Honolulu, HI; San Francisco-Oakland-Fremont, CA; San Jose-Sunnyvale-Santa Clara, CA; and Vallejo-Fairfield, CA had at least 20% of their interviewees of the Asian race.

Normally, we would look at the sorted proportion of interviewees from each metropolitan area who have not received a high school diploma with the command:

sort(tapply(CPS$Education == "No high school diploma", CPS$MetroArea, mean))
## named numeric(0)

Determine which metropolitan area has the smallest proportion of interviewees who have received no high school diploma?

sort(tapply(CPS$Education == "No high school diploma", CPS$MetroArea, mean, na.rm=TRUE))
##                                      Iowa City, IA                                  Bowling Green, KY                              Kalamazoo-Portage, MI 
##                                         0.02912621                                         0.03703704                                         0.05050505 
##                               Champaign-Urbana, IL                           Bremerton-Silverdale, WA                                       Lawrence, KS 
##                                         0.05154639                                         0.05405405                                         0.05952381 
##                              Bloomington-Normal IL                                   Jacksonville, NC                                     Eau Claire, WI 
##                                         0.06060606                                         0.06122449                                         0.06250000 
##                  Palm Bay-Melbourne-Titusville, FL                                      Salisbury, MD                                    Gainesville, FL 
##                                         0.06666667                                         0.06779661                                         0.06896552 
##                          Fort Collins-Loveland, CO                                        Altoona, PA                                        Madison, WI 
##                                         0.06936416                                         0.07142857                                         0.07423581 
##                                    Tallahassee, FL                                       Fargo, ND-MN                        Albany-Schenectady-Troy, NY 
##                                         0.07500000                                         0.07902736                                         0.07929515 
##                                     Ocean City, NJ                          Lakeland-Winter Haven, FL                                       Billings, MT 
##                                         0.08000000                                         0.08130081                                         0.08280255 
##                                  Coeur d'Alene, ID                    Burlington-South Burlington, VT                                          Akron, OH 
##                                         0.08333333                                         0.08394161                                         0.08421053 
##                                      Ann Arbor, MI                                      Asheville, NC                     Pensacola-Ferry Pass-Brent, FL 
##                                         0.08695652                                         0.08695652                                         0.08695652 
##                                 Oshkosh-Neenah, WI                             Rochester-Dover, NH-ME                                      Knoxville, TN 
##                                         0.08823529                                         0.08928571                                         0.08965517 
##                                     Pittsburgh, PA                                Barnstable Town, MA                    Bridgeport-Stamford-Norwalk, CT 
##                                         0.09060403                                         0.09090909                                         0.09563758 
##                                      Johnstown, PA                              Austin-Round Rock, TX                                      La Crosse, WI 
##                                         0.09615385                                         0.09629630                                         0.09677419 
##                                        Boulder, CO                    Charleston-North Charleston, SC                                     Fort Wayne, IN 
##                                         0.09701493                                         0.09890110                                         0.09900990 
##                                        Roanoke, VA                                       Prescott, AZ                            Santa Rosa-Petaluma, CA 
##                                         0.10169492                                         0.10204082                                         0.10280374 
##                                  Evansville, IN-KY                                        Spokane, WA               Poughkeepsie-Newburgh-Middletown, NY 
##                                         0.10389610                                         0.10434783                                         0.10559006 
##                Tampa-St. Petersburg-Clearwater, FL                           Grand Rapids-Wyoming, MI                        Portland-South Portland, ME 
##                                         0.10579710                                         0.10612245                                         0.10638298 
##                                       Honolulu, HI                         Michigan City-La Porte, IN                             Eugene-Springfield, OR 
##                                         0.10739300                                         0.10769231                                         0.11038961 
##                     Boston-Cambridge-Quincy, MA-NH                                           Bend, OR                                     Vero Beach, FL 
##                                         0.11080485                                         0.11111111                                         0.11428571 
##                      Sarasota-Bradenton-Venice, FL             Fort Walton Beach-Crestview-Destin, FL                                          Flint, MI 
##                                         0.11464968                                         0.11475410                                         0.11538462 
##                                   Cedar Rapids, IA             Minneapolis-St Paul-Bloomington, MN-WI                Portland-Vancouver-Beaverton, OR-WA 
##                                         0.11564626                                         0.11638204                                         0.11657143 
##       Washington-Arlington-Alexandria, DC-VA-MD-WV                                         Mobile, AL                          Scranton-Wilkes Barre, PA 
##                                         0.11683748                                         0.11702128                                         0.11724138 
##                                         Topeka, KS                               Colorado Springs, CO                                        Olympia, WA 
##                                         0.11724138                                         0.11764706                                         0.11764706 
##                                    Reno-Sparks, NV                                        Appleton,WI                                       Santa Fe, NM 
##                                         0.11764706                                         0.11827957                                         0.11904762 
##         Virginia Beach-Norfolk-Newport News, VA-NC                  Allentown-Bethlehem-Easton, PA-NJ                                      Rochester, NY 
##                                         0.11909651                                         0.11929825                                         0.12132353 
##                        Seattle-Tacoma-Bellevue, WA                                 Kansas City, MO-KS                                           Napa, CA 
##                                         0.12168793                                         0.12172775                                         0.12244898 
##                                      Duluth, MN-WI                                      New Haven, CT                               Canton-Massillon, OH 
##                                         0.12264151                                         0.12354312                                         0.12371134 
##                                   Fayetteville, NC                    San Luis Obispo-Paso Robles, CA                                   Worcester, MA-CT 
##                                         0.12500000                                         0.12500000                                         0.12605042 
##           Philadelphia-Camden-Wilmington, PA-NJ-DE                Davenport-Moline-Rock Island, IA-IL                           Waterloo-Cedar Falls, IA 
##                                         0.12717253                                         0.12727273                                         0.12800000 
##                                         Pueblo, CO                                    Baton Rouge, LA                                         Racine, WI 
##                                         0.12844037                                         0.12871287                                         0.12903226 
##                                     Des Moines, IA                         Detroit-Warren-Livonia, MI                        Omaha-Council Bluffs, NE-IA 
##                                         0.12944162                                         0.12964642                                         0.12972973 
##                                       Richmond, VA                                       Savannah, GA                                        Danbury, CT 
##                                         0.12990196                                         0.13013699                                         0.13043478 
##                                    Bloomington, IN                                       Valdosta, GA                                         Wausau, WI 
##                                         0.13095238                                         0.13157895                                         0.13157895 
##             Deltona-Daytona Beach-Ormond Beach, FL                                          Tulsa, OK                            Harrisburg-Carlisle, PA 
##                                         0.13178295                                         0.13178295                                         0.13286713 
##                             Las Vegas-Paradise, NV         Myrtle Beach-Conway-North Myrtle Beach, SC                                     Provo-Orem, UT 
##                                         0.13307985                                         0.13333333                                         0.13366337 
##                                       Anderson, IN                                          Chico, CA                                   St. Louis, MO-IL 
##                                         0.13461538                                         0.13461538                                         0.13461538 
##                            Niles-Benton Harbor, MI                               Ogden-Clearfield, UT                               Baltimore-Towson, MD 
##                                         0.13513514                                         0.13571429                                         0.13583333 
##                          Buffalo-Niagara Falls, NY                  Milwaukee-Waukesha-West Allis, WI                Chicago-Naperville-Joliet, IN-IN-WI 
##                                         0.13684211                                         0.13693694                                         0.13737734 
##                                  Louisville, KY-IN                                      Lynchburg, VA                                         Peoria, IL 
##                                         0.13785047                                         0.13793103                                         0.13829787 
##                                    Sioux Falls, SD                                          Ocala, FL                   Leominster-Fitchburg-Gardner, MA 
##                                         0.13832200                                         0.13888889                                         0.14035088 
##                                  Oklahoma City, OK                  San Diego-Carlsbad-San Marcos, CA                                   Jacksonville, FL 
##                                         0.14137214                                         0.14188267                                         0.14244186 
##                                  Atlantic City, NJ                            Holland-Grand Haven, MI                                        Medford, OR 
##                                         0.14285714                                         0.14285714                                         0.14285714 
##                            Naples-Marco Island, FL                                    Punta Gorda, FL                                       Victoria, TX 
##                                         0.14285714                                         0.14285714                                         0.14285714 
##                                  Winston-Salem, NC                                 Salt Lake City, UT                 Atlanta-Sandy Springs-Marietta, GA 
##                                         0.14285714                                         0.14338235                                         0.14421553 
##                                        Decatur, IL                                    Springfield, IL                                         Monroe, MI 
##                                         0.14516129                                         0.14516129                                         0.14545455 
##                                  Denver-Aurora, CO           Hartford-West Hartford-East Hartford, CT                                        Greeley, CO 
##                                         0.14574558                                         0.14574899                                         0.14615385 
##                  San Francisco-Oakland-Fremont, CA                               Boise City-Nampa, ID                                     Greenville, SC 
##                                         0.14651368                                         0.14653465                                         0.14666667 
##                              Birmingham-Hoover, AL                 Saginaw-Saginaw Township North, MI                         Santa-Cruz-Watsonville, CA 
##                                         0.14678899                                         0.14754098                                         0.14814815 
##                                  Trenton-Ewing, NJ                              Lexington-Fayette, KY                 San Jose-Sunnyvale-Santa Clara, CA 
##                                         0.14814815                                         0.14838710                                         0.14922481 
##                                     Bellingham, WA                          Norwich-New London, CT-RI                                        Lubbock, TX 
##                                         0.15000000                                         0.15060241                                         0.15094340 
##                       Huntington-Ashland, WV-KY-OH                                      St. Cloud, MN                                        Jackson, MS 
##                                         0.15151515                                         0.15151515                                         0.15168539 
##                                         Dayton, OH                                 Chattanooga, TN-GA                                       Syracuse, NY 
##                                         0.15207373                                         0.15217391                                         0.15428571 
## New York-Northern New Jersey-Long Island, NY-NJ-PA                                       Columbia, SC                                       Columbus, OH 
##                                         0.15573586                                         0.15600000                                         0.15617716 
##                                  Memphis, TN-MS-AR                                        Orlando, FL                                  Warner Robins, GA 
##                                         0.15714286                                         0.16108787                                         0.16216216 
##                        Cleveland-Elyria-Mentor, OH                                       Columbia, MO                                         Durham, NC 
##                                         0.16250000                                         0.16279070                                         0.16326531 
##              Miami-Fort Lauderdale-Miami Beach, FL                                   Indianapolis, IN                                    Albuquerque, NM 
##                                         0.16356589                                         0.16371681                                         0.16424116 
##                          Cape Coral-Fort Myers, FL                                       Amarillo, TX                                Anniston-Oxford, AL 
##                                         0.16528926                                         0.16666667                                         0.16666667 
##                            Athens-Clark County, GA                                     Binghamton, NY                        Phoenix-Mesa-Scottsdale, AZ 
##                                         0.16666667                                         0.16666667                                         0.16687737 
##                                      Green Bay, WI                                         Bangor, ME               Providence-Fall River-Warwick, MA-RI 
##                                         0.16831683                                         0.16860465                                         0.16915688 
##                         Muskegon-Norton Shores, MI                                     Tuscaloosa, AL                                       Rockford, IL 
##                                         0.16923077                                         0.16949153                                         0.17021277 
##                                     Las Cruses, NM                                Gulfport-Biloxi, MS                                     Huntsville, AL 
##                                         0.17283951                                         0.17307692                                         0.17391304 
##                                     Utica-Rome, NY                                  Fort Smith, AR-OK                  Charlotte-Gastonia-Concord, NC-SC 
##                                         0.17391304                                         0.17441860                                         0.17444717 
##                                      El Centro, CA                                           Erie, PA                                        Jackson, MI 
##                                         0.17567568                                         0.17567568                                         0.17741935 
##                    Cincinnati-Middletown, OH-KY-IN                                 Springfield, MA-CT                                        Reading, PA 
##                                         0.17773788                                         0.17829457                                         0.17857143 
##                              Vallejo-Fairfield, CA                                          Salem, OR                Nashville-Davidson-Murfreesboro, TN 
##                                         0.17924528                                         0.17985612                                         0.18112245 
##                                   Johnson City, TN                                        Wichita, KS                                   York-Hanover, PA 
##                                         0.18181818                                         0.18181818                                         0.18181818 
##                                     Janesville, WI                           Lansing-East Lansing, MI                          Greensboro-High Point, NC 
##                                         0.18292683                                         0.18348624                                         0.18357488 
##                                        Decatur, Al                                         Albany, GA                     Augusta-Richmond County, GA-SC 
##                                         0.18421053                                         0.18604651                                         0.18796992 
##                                     Charleston, WV                        Shreveport-Bossier City, LA                                   Raleigh-Cary, NC 
##                                         0.18834081                                         0.18918919                                         0.18959108 
##                                         Toledo, OH                                    Spartanburg, SC                    Dallas-Fort Worth-Arlington, TX 
##                                         0.18965517                                         0.18987342                                         0.19077135 
##              Sacramento-Arden-Arcade-Roseville, CA               Santa Barbara-Santa Maria-Goleta, CA                                         Monroe, LA 
##                                         0.19136961                                         0.19191919                                         0.19205298 
##                                          Dover, DE                        South Bend-Mishawaka, IN-MI              Fayetteville-Springdale-Rogers, AR-MO 
##                                         0.19220056                                         0.19354839                                         0.19393939 
##                                    Columbus, GA-AL                                       Kingston, NY                     Port St. Lucie-Fort Pierce, FL 
##                                         0.19607843                                         0.19696970                                         0.19767442 
##                                      Waterbury, CT                  Little Rock-North Little Rock, AR                                    Springfield, MO 
##                                         0.19852941                                         0.19939577                                         0.20000000 
##                                        Modesto, CA                     Houston-Baytown-Sugar Land, TX                   Oxnard-Thousand Oaks-Ventura, CA 
##                                         0.20325203                                         0.20439739                                         0.20657277 
##                                       Anderson, SC                                        Midland, TX                    New Orleans-Metairie-Kenner, LA 
##                                         0.20689655                                         0.21052632                                         0.21088435 
##                                         Fresno, CA                                   Lake Charles, LA                            Visalia-Porterville, CA 
##                                         0.21120690                                         0.21739130                                         0.21782178 
##                                    San Antonio, TX                      Hagerstown-Martinsburg, MD-WV                                         Yakima, WA 
##                                         0.22004357                                         0.22222222                                         0.22222222 
##                      Hickory-Morgantown-Lenoir, NC               Los Angeles-Long Beach-Santa Ana, CA                         Panama City-Lynn Haven, FL 
##                                         0.22448980                                         0.22882883                                         0.22916667 
##                                   Harrisonburg, VA                               Kankakee-Bradley, IL                           Beaumont-Port Author, TX 
##                                         0.23287671                                         0.23437500                                         0.23469388 
##                     Youngstown-Warren-Boardman, OH                       Riverside-San Bernardino, CA                                     Farmington, NM 
##                                         0.23622047                                         0.23780488                                         0.23913043 
##                       Killeen-Temple-Fort Hood, TX                                           Waco, TX                                     Montgomery, AL 
##                                         0.24050633                                         0.24074074                                         0.24137931 
##                                         Tucson, AZ                                      Lafayette, LA                                         Joplin, MO 
##                                         0.24603175                                         0.24822695                                         0.25000000 
##                                       Stockton, CA                          Brownsville-Harlingen, TX                                      Lancaster, PA 
##                                         0.25333333                                         0.25396825                                         0.26771654 
##                                    Bakersfield, CA                   Vineland-Millville-Bridgeton, NJ                                         Lawton, OK 
##                                         0.27218935                                         0.27500000                                         0.28000000 
##                                         Merced, CA                                 Corpus Christi, TX                                        El Paso, TX 
##                                         0.28358209                                         0.29702970                                         0.30219780 
##                                    Springfield, OH                                       Florence, AL                                         Madera, CA 
##                                         0.31034483                                         0.32075472                                         0.33333333 
##                                        Salinas, CA                                         Laredo, TX                           Kingsport-Bristol, TN-VA 
##                                         0.34090909                                         0.34426230                                         0.36363636 
##                                       Longview, TX                         McAllen-Edinburg-Pharr, TX                                          Macon, GA 
##                                         0.38297872                                         0.38297872                                         0.40816327

Explanation: We can see that Iowa City, IA had 2.9% of interviewees not finish high school, the smallest value of any metropolitan area.

Integrating Country of Birth Data

CPS = merge(CPS, CountryMap, by.x="CountryOfBirthCode", by.y="Code", all.x=TRUE)

What is the name of the variable added to the CPS data frame by this merge operation? How many interviewees have a missing value for the new country of birth variable?

summary(CPS)
##  CountryOfBirthCode MetroAreaCode   PeopleInHousehold       Region               State            Age                 Married          Sex       
##  Min.   : 57.00     Min.   :10420   Min.   : 1.000    Midwest  :30684   California  :11570   Min.   : 0.00   Divorced     :11151   Female:67481  
##  1st Qu.: 57.00     1st Qu.:21780   1st Qu.: 2.000    Northeast:25939   Texas       : 7077   1st Qu.:19.00   Married      :55509   Male  :63821  
##  Median : 57.00     Median :34740   Median : 3.000    South    :41502   New York    : 5595   Median :39.00   Never Married:30772                 
##  Mean   : 82.68     Mean   :35075   Mean   : 3.284    West     :33177   Florida     : 5149   Mean   :38.83   Separated    : 2027                 
##  3rd Qu.: 57.00     3rd Qu.:41860   3rd Qu.: 4.000                      Pennsylvania: 3930   3rd Qu.:57.00   Widowed      : 6505                 
##  Max.   :555.00     Max.   :79600   Max.   :15.000                      Illinois    : 3912   Max.   :85.00   NA's         :25338                 
##                     NA's   :34238                                       (Other)     :94069                                                       
##                    Education                   Race           Hispanic                    Citizenship               EmploymentStatus
##  High school            :30906   American Indian :  1433   Min.   :0.0000   Citizen, Native     :116639   Disabled          : 5712  
##  Bachelor's degree      :19443   Asian           :  6520   1st Qu.:0.0000   Citizen, Naturalized:  7073   Employed          :61733  
##  Some college, no degree:18863   Black           : 13913   Median :0.0000   Non-Citizen         :  7590   Not in Labor Force:15246  
##  No high school diploma :16095   Multiracial     :  2897   Mean   :0.1393                                 Retired           :18619  
##  Associate degree       : 9913   Pacific Islander:   618   3rd Qu.:0.0000                                 Unemployed        : 4203  
##  (Other)                :10744   White           :105921   Max.   :1.0000                                 NA's              :25789  
##  NA's                   :25338                                                                                                      
##                                Industry                                                  MetroArea              Country      
##  Educational and health services   :15017   New York-Northern New Jersey-Long Island, NY-NJ-PA: 5409   United States:115063  
##  Trade                             : 8933   Washington-Arlington-Alexandria, DC-VA-MD-WV      : 4177   Mexico       :  3921  
##  Professional and business services: 7519   Los Angeles-Long Beach-Santa Ana, CA              : 4102   Philippines  :   839  
##  Manufacturing                     : 6791   Philadelphia-Camden-Wilmington, PA-NJ-DE          : 2855   India        :   770  
##  Leisure and hospitality           : 6364   Chicago-Naperville-Joliet, IN-IN-WI               : 2772   China        :   581  
##  (Other)                           :21618   (Other)                                           :77749   (Other)      :  9952  
##  NA's                              :65060   NA's                                              :34238   NA's         :   176

Explanation: From summary(CPS), we can read that Country is the name of the added variable, and that it has 176 missing values.

Among all interviewees born outside of North America, which country was the most common place of birth?

 sort(table(CPS$Country))
## 
##                         Cyprus                         Kosovo         Oceania, not specified       Other U. S. Island Areas                          Wales 
##                              0                              0                              0                              0                              0 
##               Northern Ireland                       Tanzania                     Azerbaijan                 Czechoslovakia               St. Kitts--Nevis 
##                              2                              2                              3                              3                              3 
##                        Georgia                       Barbados                        Denmark                         Latvia                          Samoa 
##                              5                              6                              6                              6                              6 
##                        Senegal                      Singapore                       Slovakia                          Tonga                       Zimbabwe 
##                              6                              6                              6                              6                              6 
##   South America, not specified                      St. Lucia                        Algeria        Americas, not specified                         Belize 
##                              7                              7                              9                              9                              9 
##                           Fiji St. Vincent and the Grenadines                        Bahamas                        Finland                         Kuwait 
##                              9                              9                             10                             10                             10 
##                      Lithuania                 Czech Republic                       Dominica                       Paraguay                        Croatia 
##                             10                             11                             11                             11                             12 
##                      Macedonia                        Moldova            Antigua and Barbuda                        Belgium                        Bermuda 
##                             12                             12                             13                             13                             13 
##                        Bolivia                        Grenada                          Sudan                     Cape Verde                        Eritrea 
##                             13                             13                             13                             15                             15 
##                   Sierra Leone                         Uganda                        Austria                        Morocco                      Sri Lanka 
##                             15                             15                             17                             17                             17 
##           U. S. Virgin Islands                        Uruguay                        Albania                         Norway          Europe, not specified 
##                             17                             17                             18                             18                             19 
##                     Uzbekistan     West Indies, not specified                       Malaysia                         Serbia                         Azores 
##                             19                             19                             20                             20                             22 
##                           USSR                    New Zealand                    Switzerland                          Yemen                        Belarus 
##                             22                             23                             23                             23                             24 
##                       Scotland                     Yugoslavia                        Hungary                    Afghanistan                      Indonesia 
##                             24                             24                             25                             26                             26 
##                    Netherlands                         Sweden                       Bulgaria                     Costa Rica                   Saudi Arabia 
##                             28                             28                             29                             29                             29 
##                           Guam                       Cameroon                          Syria                        Armenia                         Jordan 
##                             31                             32                             32                             35                             36 
##                          Chile            Asia, not specified                        Ireland                          Spain                     Bangladesh 
##                             37                             39                             39                             41                             42 
##                      Australia                          Nepal                         Panama                        Lebanon                Myanmar (Burma) 
##                             43                             44                             44                             45                             45 
##                   South Africa                         Turkey                       Cambodia                        Liberia                          Kenya 
##                             48                             48                             49                             52                             55 
##                        Romania                         Greece                         Israel            Trinidad and Tobago           Bosnia & Herzegovina 
##                             55                             56                             57                             60                             61 
##                      Venezuela                      Argentina                      Hong Kong                       Portugal                          Egypt 
##                             61                             64                             64                             64                             65 
##                        Somalia                         France                    South Korea                          Ghana                      Nicaragua 
##                             72                             73                             73                             76                             76 
##                       Ethiopia                      Elsewhere                        Nigeria                           Iraq                           Laos 
##                             80                             81                             85                             97                             98 
##                         Taiwan                        Ukraine                         Guyana                       Pakistan                 United Kingdom 
##                            102                            104                            109                            109                            111 
##                       Thailand          Africa, not specified                        Ecuador                           Peru                           Iran 
##                            128                            129                            136                            136                            144 
##                          Italy                         Brazil                         Poland                          Haiti                         Russia 
##                            149                            159                            162                            167                            173 
##                        England                          Japan                       Honduras                       Columbia                        Jamaica 
##                            179                            187                            189                            206                            217 
##                      Guatemala             Dominican Republic                          Korea                         Canada                           Cuba 
##                            309                            330                            334                            410                            426 
##                        Germany                        Vietnam                    El Salvador                    Puerto Rico                          China 
##                            438                            458                            477                            518                            581 
##                          India                    Philippines                         Mexico                  United States 
##                            770                            839                           3921                         115063

Explanation: From the summary(CPS) output, or alternately sort(table(CPS$Country)), we see that the top two countries of birth were United States and Mexico, both of which are in North America. The third highest value, 839, was for the Philippines.

What proportion of the interviewees from the “New York-Northern New Jersey-Long Island, NY-NJ-PA” metropolitan area have a country of birth that is not the United States?

m = table(CPS$MetroArea == "New York-Northern New Jersey-Long Island, NY-NJ-PA", CPS$Country != "United States")

prop.table(m,1)
##        
##             FALSE      TRUE
##   FALSE 0.8607228 0.1392772
##   TRUE  0.6913397 0.3086603

Explanation: From table(CPS$MetroArea == “New York-Northern New Jersey-Long Island, NY-NJ-PA”, CPS$Country != “United States”), we can see that 1668 of interviewees from this metropolitan area were born outside the United States and 3736 were born in the United States (it turns out an additional 5 have a missing country of origin). Therefore, the proportion is 1668/(1668+3736)=0.309.

Which metropolitan area has the largest number (note – not proportion) of interviewees with a country of birth in India? In Brazil? In Somalia?

sort(tapply(CPS$Country == "India", CPS$MetroArea, sum, na.rm=TRUE))
##                                          Akron, OH                        Albany-Schenectady-Troy, NY                                         Albany, GA 
##                                                  0                                                  0                                                  0 
##                  Allentown-Bethlehem-Easton, PA-NJ                                        Altoona, PA                                       Amarillo, TX 
##                                                  0                                                  0                                                  0 
##                                       Anderson, IN                                      Ann Arbor, MI                                Anniston-Oxford, AL 
##                                                  0                                                  0                                                  0 
##                                        Appleton,WI                                      Asheville, NC                            Athens-Clark County, GA 
##                                                  0                                                  0                                                  0 
##                     Augusta-Richmond County, GA-SC                                         Bangor, ME                                Barnstable Town, MA 
##                                                  0                                                  0                                                  0 
##                                    Baton Rouge, LA                           Beaumont-Port Author, TX                                     Bellingham, WA 
##                                                  0                                                  0                                                  0 
##                                           Bend, OR                                       Billings, MT                                     Binghamton, NY 
##                                                  0                                                  0                                                  0 
##                                    Bloomington, IN                                        Boulder, CO                                  Bowling Green, KY 
##                                                  0                                                  0                                                  0 
##                           Bremerton-Silverdale, WA                          Buffalo-Niagara Falls, NY                               Canton-Massillon, OH 
##                                                  0                                                  0                                                  0 
##                          Cape Coral-Fort Myers, FL                                   Cedar Rapids, IA                               Champaign-Urbana, IL 
##                                                  0                                                  0                                                  0 
##                                     Charleston, WV                                 Chattanooga, TN-GA                                          Chico, CA 
##                                                  0                                                  0                                                  0 
##                                  Coeur d'Alene, ID                               Colorado Springs, CO                                       Columbia, MO 
##                                                  0                                                  0                                                  0 
##                                    Columbus, GA-AL                                       Columbus, OH                                 Corpus Christi, TX 
##                                                  0                                                  0                                                  0 
##                                        Danbury, CT                Davenport-Moline-Rock Island, IA-IL                                         Dayton, OH 
##                                                  0                                                  0                                                  0 
##                                        Decatur, Al                                        Decatur, IL                                  Denver-Aurora, CO 
##                                                  0                                                  0                                                  0 
##                                          Dover, DE                                      Duluth, MN-WI                                         Durham, NC 
##                                                  0                                                  0                                                  0 
##                                     Eau Claire, WI                                      El Centro, CA                                        El Paso, TX 
##                                                  0                                                  0                                                  0 
##                                           Erie, PA                             Eugene-Springfield, OR                                  Evansville, IN-KY 
##                                                  0                                                  0                                                  0 
##                                       Fargo, ND-MN                                     Farmington, NM                                   Fayetteville, NC 
##                                                  0                                                  0                                                  0 
##                                          Flint, MI                                       Florence, AL                          Fort Collins-Loveland, CO 
##                                                  0                                                  0                                                  0 
##                                  Fort Smith, AR-OK             Fort Walton Beach-Crestview-Destin, FL                                    Gainesville, FL 
##                                                  0                                                  0                                                  0 
##                           Grand Rapids-Wyoming, MI                                        Greeley, CO                                      Green Bay, WI 
##                                                  0                                                  0                                                  0 
##                          Greensboro-High Point, NC                                Gulfport-Biloxi, MS                      Hagerstown-Martinsburg, MD-WV 
##                                                  0                                                  0                                                  0 
##                                   Harrisonburg, VA                      Hickory-Morgantown-Lenoir, NC                            Holland-Grand Haven, MI 
##                                                  0                                                  0                                                  0 
##                       Huntington-Ashland, WV-KY-OH                                     Huntsville, AL                                        Jackson, MI 
##                                                  0                                                  0                                                  0 
##                                        Jackson, MS                                   Jacksonville, NC                                     Janesville, WI 
##                                                  0                                                  0                                                  0 
##                                   Johnson City, TN                                      Johnstown, PA                                         Joplin, MO 
##                                                  0                                                  0                                                  0 
##                              Kalamazoo-Portage, MI                               Kankakee-Bradley, IL                       Killeen-Temple-Fort Hood, TX 
##                                                  0                                                  0                                                  0 
##                           Kingsport-Bristol, TN-VA                                       Kingston, NY                                      Knoxville, TN 
##                                                  0                                                  0                                                  0 
##                                      La Crosse, WI                                      Lafayette, LA                                   Lake Charles, LA 
##                                                  0                                                  0                                                  0 
##                          Lakeland-Winter Haven, FL                                      Lancaster, PA                           Lansing-East Lansing, MI 
##                                                  0                                                  0                                                  0 
##                                         Laredo, TX                                     Las Cruses, NM                                         Lawton, OK 
##                                                  0                                                  0                                                  0 
##                   Leominster-Fitchburg-Gardner, MA                              Lexington-Fayette, KY                                       Longview, TX 
##                                                  0                                                  0                                                  0 
##                                  Louisville, KY-IN                                        Lubbock, TX                                      Lynchburg, VA 
##                                                  0                                                  0                                                  0 
##                                          Macon, GA                                         Madera, CA                         McAllen-Edinburg-Pharr, TX 
##                                                  0                                                  0                                                  0 
##                                        Medford, OR                                         Merced, CA                         Michigan City-La Porte, IN 
##                                                  0                                                  0                                                  0 
##                                        Midland, TX                                         Mobile, AL                                        Modesto, CA 
##                                                  0                                                  0                                                  0 
##                                         Monroe, LA                                         Monroe, MI                                     Montgomery, AL 
##                                                  0                                                  0                                                  0 
##                         Muskegon-Norton Shores, MI         Myrtle Beach-Conway-North Myrtle Beach, SC                                           Napa, CA 
##                                                  0                                                  0                                                  0 
##                            Niles-Benton Harbor, MI                                          Ocala, FL                                     Ocean City, NJ 
##                                                  0                                                  0                                                  0 
##                                 Oshkosh-Neenah, WI                  Palm Bay-Melbourne-Titusville, FL                         Panama City-Lynn Haven, FL 
##                                                  0                                                  0                                                  0 
##                     Pensacola-Ferry Pass-Brent, FL                     Port St. Lucie-Fort Pierce, FL                        Portland-South Portland, ME 
##                                                  0                                                  0                                                  0 
##               Poughkeepsie-Newburgh-Middletown, NY                                       Prescott, AZ                                         Pueblo, CO 
##                                                  0                                                  0                                                  0 
##                                    Punta Gorda, FL                                         Racine, WI                                   Raleigh-Cary, NC 
##                                                  0                                                  0                                                  0 
##                                        Reading, PA                                       Richmond, VA                       Riverside-San Bernardino, CA 
##                                                  0                                                  0                                                  0 
##                                        Roanoke, VA                                       Rockford, IL                 Saginaw-Saginaw Township North, MI 
##                                                  0                                                  0                                                  0 
##                                          Salem, OR                                        Salinas, CA                                      Salisbury, MD 
##                                                  0                                                  0                                                  0 
##                                    San Antonio, TX                    San Luis Obispo-Paso Robles, CA                         Santa-Cruz-Watsonville, CA 
##                                                  0                                                  0                                                  0 
##               Santa Barbara-Santa Maria-Goleta, CA                                       Santa Fe, NM                            Santa Rosa-Petaluma, CA 
##                                                  0                                                  0                                                  0 
##                      Sarasota-Bradenton-Venice, FL                                       Savannah, GA                          Scranton-Wilkes Barre, PA 
##                                                  0                                                  0                                                  0 
##                        Shreveport-Bossier City, LA                                    Sioux Falls, SD                        South Bend-Mishawaka, IN-MI 
##                                                  0                                                  0                                                  0 
##                                    Spartanburg, SC                                        Spokane, WA                                 Springfield, MA-CT 
##                                                  0                                                  0                                                  0 
##                                    Springfield, MO                                    Springfield, OH                                      St. Cloud, MN 
##                                                  0                                                  0                                                  0 
##                                   St. Louis, MO-IL                                       Stockton, CA                                    Tallahassee, FL 
##                                                  0                                                  0                                                  0 
##                                         Toledo, OH                                         Topeka, KS                                     Tuscaloosa, AL 
##                                                  0                                                  0                                                  0 
##                                     Utica-Rome, NY                                       Valdosta, GA                              Vallejo-Fairfield, CA 
##                                                  0                                                  0                                                  0 
##                                     Vero Beach, FL                                       Victoria, TX                   Vineland-Millville-Bridgeton, NJ 
##                                                  0                                                  0                                                  0 
##         Virginia Beach-Norfolk-Newport News, VA-NC                                           Waco, TX                                      Waterbury, CT 
##                                                  0                                                  0                                                  0 
##                           Waterloo-Cedar Falls, IA                                         Wausau, WI                                        Wichita, KS 
##                                                  0                                                  0                                                  0 
##                                   Worcester, MA-CT                                         Yakima, WA                                   York-Hanover, PA 
##                                                  0                                                  0                                                  0 
##                     Youngstown-Warren-Boardman, OH                                       Anderson, SC                              Bloomington-Normal IL 
##                                                  0                                                  1                                                  1 
##                               Boise City-Nampa, ID                    Cincinnati-Middletown, OH-KY-IN                                       Columbia, SC 
##                                                  1                                                  1                                                  1 
##                                     Greenville, SC                            Harrisburg-Carlisle, PA                                   Jacksonville, FL 
##                                                  1                                                  1                                                  1 
##                                       Lawrence, KS                            Naples-Marco Island, FL                    New Orleans-Metairie-Kenner, LA 
##                                                  1                                                  1                                                  1 
##                                        Olympia, WA                                     Provo-Orem, UT                                       Syracuse, NY 
##                                                  1                                                  1                                                  1 
##                                         Tucson, AZ                                  Atlantic City, NJ                                    Bakersfield, CA 
##                                                  1                                                  2                                                  2 
##                              Birmingham-Hoover, AL                    Burlington-South Burlington, VT                    Charleston-North Charleston, SC 
##                                                  2                                                  2                                                  2 
##                        Cleveland-Elyria-Mentor, OH             Deltona-Daytona Beach-Ormond Beach, FL                                     Fort Wayne, IN 
##                                                  2                                                  2                                                  2 
##                             Las Vegas-Paradise, NV                                  Memphis, TN-MS-AR              Miami-Fort Lauderdale-Miami Beach, FL 
##                                                  2                                                  2                                                  2 
##                Nashville-Davidson-Murfreesboro, TN                               Ogden-Clearfield, UT                                  Oklahoma City, OK 
##                                                  2                                                  2                                                  2 
##                   Oxnard-Thousand Oaks-Ventura, CA                        Phoenix-Mesa-Scottsdale, AZ                                      Rochester, NY 
##                                                  2                                                  2                                                  2 
##                                 Salt Lake City, UT                                    Springfield, IL                                  Winston-Salem, NC 
##                                                  2                                                  2                                                  2 
##                                    Albuquerque, NM                                      Iowa City, IA                                        Madison, WI 
##                                                  3                                                  3                                                  3 
##                          Norwich-New London, CT-RI                                    Reno-Sparks, NV                            Visalia-Porterville, CA 
##                                                  3                                                  3                                                  3 
##                  Charlotte-Gastonia-Concord, NC-SC                                   Indianapolis, IN                        Omaha-Council Bluffs, NE-IA 
##                                                  4                                                  4                                                  4 
##                                         Peoria, IL                             Rochester-Dover, NH-ME                  San Diego-Carlsbad-San Marcos, CA 
##                                                  4                                                  4                                                  4 
##                                  Trenton-Ewing, NJ                                          Tulsa, OK                                        Orlando, FL 
##                                                  4                                                  4                                                  5 
##                        Seattle-Tacoma-Bellevue, WA                              Austin-Round Rock, TX                          Brownsville-Harlingen, TX 
##                                                  5                                                  6                                                  6 
##                                     Des Moines, IA                  Little Rock-North Little Rock, AR                                      New Haven, CT 
##                                                  6                                                  6                                                  6 
##                Portland-Vancouver-Beaverton, OR-WA                                  Warner Robins, GA                Tampa-St. Petersburg-Clearwater, FL 
##                                                  6                                                  6                                                  7 
##              Fayetteville-Springdale-Rogers, AR-MO              Sacramento-Arden-Arcade-Roseville, CA                                       Honolulu, HI 
##                                                  8                                                  8                                                  9 
##                     Boston-Cambridge-Quincy, MA-NH                                 Kansas City, MO-KS                    Bridgeport-Stamford-Norwalk, CT 
##                                                 11                                                 11                                                 12 
##                  Milwaukee-Waukesha-West Allis, WI               Providence-Fall River-Warwick, MA-RI                     Houston-Baytown-Sugar Land, TX 
##                                                 12                                                 14                                                 15 
##                               Baltimore-Towson, MD                                         Fresno, CA                                     Pittsburgh, PA 
##                                                 16                                                 16                                                 16 
##                    Dallas-Fort Worth-Arlington, TX               Los Angeles-Long Beach-Santa Ana, CA                 San Jose-Sunnyvale-Santa Clara, CA 
##                                                 18                                                 19                                                 19 
##             Minneapolis-St Paul-Bloomington, MN-WI           Hartford-West Hartford-East Hartford, CT                 Atlanta-Sandy Springs-Marietta, GA 
##                                                 23                                                 26                                                 27 
##                  San Francisco-Oakland-Fremont, CA                         Detroit-Warren-Livonia, MI                Chicago-Naperville-Joliet, IN-IN-WI 
##                                                 27                                                 30                                                 31 
##           Philadelphia-Camden-Wilmington, PA-NJ-DE       Washington-Arlington-Alexandria, DC-VA-MD-WV New York-Northern New Jersey-Long Island, NY-NJ-PA 
##                                                 32                                                 50                                                 96


sort(tapply(CPS$Country == "Brazil", CPS$MetroArea, sum, na.rm=TRUE))
##                        Albany-Schenectady-Troy, NY                                         Albany, GA                  Allentown-Bethlehem-Easton, PA-NJ 
##                                                  0                                                  0                                                  0 
##                                        Altoona, PA                                       Amarillo, TX                                       Anderson, IN 
##                                                  0                                                  0                                                  0 
##                                       Anderson, SC                                      Ann Arbor, MI                                Anniston-Oxford, AL 
##                                                  0                                                  0                                                  0 
##                                        Appleton,WI                                      Asheville, NC                            Athens-Clark County, GA 
##                                                  0                                                  0                                                  0 
##                                  Atlantic City, NJ                     Augusta-Richmond County, GA-SC                              Austin-Round Rock, TX 
##                                                  0                                                  0                                                  0 
##                                    Bakersfield, CA                               Baltimore-Towson, MD                                         Bangor, ME 
##                                                  0                                                  0                                                  0 
##                                    Baton Rouge, LA                           Beaumont-Port Author, TX                                     Bellingham, WA 
##                                                  0                                                  0                                                  0 
##                                           Bend, OR                                       Billings, MT                                     Binghamton, NY 
##                                                  0                                                  0                                                  0 
##                              Birmingham-Hoover, AL                              Bloomington-Normal IL                                    Bloomington, IN 
##                                                  0                                                  0                                                  0 
##                               Boise City-Nampa, ID                                        Boulder, CO                                  Bowling Green, KY 
##                                                  0                                                  0                                                  0 
##                          Brownsville-Harlingen, TX                          Buffalo-Niagara Falls, NY                    Burlington-South Burlington, VT 
##                                                  0                                                  0                                                  0 
##                                   Cedar Rapids, IA                               Champaign-Urbana, IL                    Charleston-North Charleston, SC 
##                                                  0                                                  0                                                  0 
##                                     Charleston, WV                                 Chattanooga, TN-GA                        Cleveland-Elyria-Mentor, OH 
##                                                  0                                                  0                                                  0 
##                                  Coeur d'Alene, ID                               Colorado Springs, CO                                       Columbia, MO 
##                                                  0                                                  0                                                  0 
##                                    Columbus, GA-AL                                       Columbus, OH                                 Corpus Christi, TX 
##                                                  0                                                  0                                                  0 
##                                         Dayton, OH                                        Decatur, Al                                        Decatur, IL 
##                                                  0                                                  0                                                  0 
##             Deltona-Daytona Beach-Ormond Beach, FL                                     Des Moines, IA                         Detroit-Warren-Livonia, MI 
##                                                  0                                                  0                                                  0 
##                                          Dover, DE                                      Duluth, MN-WI                                         Durham, NC 
##                                                  0                                                  0                                                  0 
##                                     Eau Claire, WI                                      El Centro, CA                                        El Paso, TX 
##                                                  0                                                  0                                                  0 
##                                           Erie, PA                             Eugene-Springfield, OR                                  Evansville, IN-KY 
##                                                  0                                                  0                                                  0 
##                                       Fargo, ND-MN                                     Farmington, NM              Fayetteville-Springdale-Rogers, AR-MO 
##                                                  0                                                  0                                                  0 
##                                   Fayetteville, NC                                          Flint, MI                                       Florence, AL 
##                                                  0                                                  0                                                  0 
##                          Fort Collins-Loveland, CO                                  Fort Smith, AR-OK             Fort Walton Beach-Crestview-Destin, FL 
##                                                  0                                                  0                                                  0 
##                                     Fort Wayne, IN                                         Fresno, CA                                    Gainesville, FL 
##                                                  0                                                  0                                                  0 
##                           Grand Rapids-Wyoming, MI                                        Greeley, CO                                      Green Bay, WI 
##                                                  0                                                  0                                                  0 
##                          Greensboro-High Point, NC                                     Greenville, SC                                Gulfport-Biloxi, MS 
##                                                  0                                                  0                                                  0 
##                      Hagerstown-Martinsburg, MD-WV                            Harrisburg-Carlisle, PA                                   Harrisonburg, VA 
##                                                  0                                                  0                                                  0 
##                      Hickory-Morgantown-Lenoir, NC                            Holland-Grand Haven, MI                                       Honolulu, HI 
##                                                  0                                                  0                                                  0 
##                     Houston-Baytown-Sugar Land, TX                       Huntington-Ashland, WV-KY-OH                                     Huntsville, AL 
##                                                  0                                                  0                                                  0 
##                                   Indianapolis, IN                                      Iowa City, IA                                        Jackson, MI 
##                                                  0                                                  0                                                  0 
##                                        Jackson, MS                                   Jacksonville, NC                                     Janesville, WI 
##                                                  0                                                  0                                                  0 
##                                   Johnson City, TN                                      Johnstown, PA                                         Joplin, MO 
##                                                  0                                                  0                                                  0 
##                              Kalamazoo-Portage, MI                               Kankakee-Bradley, IL                       Killeen-Temple-Fort Hood, TX 
##                                                  0                                                  0                                                  0 
##                           Kingsport-Bristol, TN-VA                                       Kingston, NY                                      Knoxville, TN 
##                                                  0                                                  0                                                  0 
##                                      La Crosse, WI                                      Lafayette, LA                                   Lake Charles, LA 
##                                                  0                                                  0                                                  0 
##                          Lakeland-Winter Haven, FL                                      Lancaster, PA                           Lansing-East Lansing, MI 
##                                                  0                                                  0                                                  0 
##                                         Laredo, TX                                     Las Cruses, NM                             Las Vegas-Paradise, NV 
##                                                  0                                                  0                                                  0 
##                                       Lawrence, KS                                         Lawton, OK                              Lexington-Fayette, KY 
##                                                  0                                                  0                                                  0 
##                  Little Rock-North Little Rock, AR                                       Longview, TX                                        Lubbock, TX 
##                                                  0                                                  0                                                  0 
##                                      Lynchburg, VA                                          Macon, GA                                         Madera, CA 
##                                                  0                                                  0                                                  0 
##                                        Madison, WI                         McAllen-Edinburg-Pharr, TX                                        Medford, OR 
##                                                  0                                                  0                                                  0 
##                                  Memphis, TN-MS-AR                                         Merced, CA                         Michigan City-La Porte, IN 
##                                                  0                                                  0                                                  0 
##                                        Midland, TX                  Milwaukee-Waukesha-West Allis, WI                                         Mobile, AL 
##                                                  0                                                  0                                                  0 
##                                        Modesto, CA                                         Monroe, MI                         Muskegon-Norton Shores, MI 
##                                                  0                                                  0                                                  0 
##         Myrtle Beach-Conway-North Myrtle Beach, SC                                           Napa, CA                            Naples-Marco Island, FL 
##                                                  0                                                  0                                                  0 
##                Nashville-Davidson-Murfreesboro, TN                                      New Haven, CT                    New Orleans-Metairie-Kenner, LA 
##                                                  0                                                  0                                                  0 
##                            Niles-Benton Harbor, MI                          Norwich-New London, CT-RI                                          Ocala, FL 
##                                                  0                                                  0                                                  0 
##                                     Ocean City, NJ                               Ogden-Clearfield, UT                                  Oklahoma City, OK 
##                                                  0                                                  0                                                  0 
##                                        Olympia, WA                        Omaha-Council Bluffs, NE-IA                                 Oshkosh-Neenah, WI 
##                                                  0                                                  0                                                  0 
##                  Palm Bay-Melbourne-Titusville, FL                         Panama City-Lynn Haven, FL                                         Peoria, IL 
##                                                  0                                                  0                                                  0 
##                                     Pittsburgh, PA                     Port St. Lucie-Fort Pierce, FL                        Portland-South Portland, ME 
##                                                  0                                                  0                                                  0 
##                Portland-Vancouver-Beaverton, OR-WA               Poughkeepsie-Newburgh-Middletown, NY                                       Prescott, AZ 
##                                                  0                                                  0                                                  0 
##                                     Provo-Orem, UT                                         Pueblo, CO                                    Punta Gorda, FL 
##                                                  0                                                  0                                                  0 
##                                   Raleigh-Cary, NC                                        Reading, PA                                    Reno-Sparks, NV 
##                                                  0                                                  0                                                  0 
##                                       Richmond, VA                       Riverside-San Bernardino, CA                                        Roanoke, VA 
##                                                  0                                                  0                                                  0 
##                             Rochester-Dover, NH-ME                                       Rockford, IL                 Saginaw-Saginaw Township North, MI 
##                                                  0                                                  0                                                  0 
##                                        Salinas, CA                                      Salisbury, MD                                    San Antonio, TX 
##                                                  0                                                  0                                                  0 
##                  San Diego-Carlsbad-San Marcos, CA                    San Luis Obispo-Paso Robles, CA                         Santa-Cruz-Watsonville, CA 
##                                                  0                                                  0                                                  0 
##               Santa Barbara-Santa Maria-Goleta, CA                                       Santa Fe, NM                            Santa Rosa-Petaluma, CA 
##                                                  0                                                  0                                                  0 
##                      Sarasota-Bradenton-Venice, FL                                       Savannah, GA                          Scranton-Wilkes Barre, PA 
##                                                  0                                                  0                                                  0 
##                        Shreveport-Bossier City, LA                                    Sioux Falls, SD                        South Bend-Mishawaka, IN-MI 
##                                                  0                                                  0                                                  0 
##                                    Spartanburg, SC                                        Spokane, WA                                    Springfield, IL 
##                                                  0                                                  0                                                  0 
##                                 Springfield, MA-CT                                    Springfield, MO                                    Springfield, OH 
##                                                  0                                                  0                                                  0 
##                                      St. Cloud, MN                                   St. Louis, MO-IL                                       Stockton, CA 
##                                                  0                                                  0                                                  0 
##                                       Syracuse, NY                                    Tallahassee, FL                                         Toledo, OH 
##                                                  0                                                  0                                                  0 
##                                         Topeka, KS                                         Tucson, AZ                                          Tulsa, OK 
##                                                  0                                                  0                                                  0 
##                                     Tuscaloosa, AL                                     Utica-Rome, NY                                       Valdosta, GA 
##                                                  0                                                  0                                                  0 
##                              Vallejo-Fairfield, CA                                     Vero Beach, FL                                       Victoria, TX 
##                                                  0                                                  0                                                  0 
##                   Vineland-Millville-Bridgeton, NJ                            Visalia-Porterville, CA                                           Waco, TX 
##                                                  0                                                  0                                                  0 
##                                  Warner Robins, GA                           Waterloo-Cedar Falls, IA                                         Wausau, WI 
##                                                  0                                                  0                                                  0 
##                                  Winston-Salem, NC                                   Worcester, MA-CT                                         Yakima, WA 
##                                                  0                                                  0                                                  0 
##                                   York-Hanover, PA                     Youngstown-Warren-Boardman, OH                                          Akron, OH 
##                                                  0                                                  0                                                  1 
##                                    Albuquerque, NM                 Atlanta-Sandy Springs-Marietta, GA                           Bremerton-Silverdale, WA 
##                                                  1                                                  1                                                  1 
##                          Cape Coral-Fort Myers, FL                                          Chico, CA                    Cincinnati-Middletown, OH-KY-IN 
##                                                  1                                                  1                                                  1 
##                                  Denver-Aurora, CO           Hartford-West Hartford-East Hartford, CT                                 Kansas City, MO-KS 
##                                                  1                                                  1                                                  1 
##                   Leominster-Fitchburg-Gardner, MA                                  Louisville, KY-IN             Minneapolis-St Paul-Bloomington, MN-WI 
##                                                  1                                                  1                                                  1 
##                                         Monroe, LA                                     Montgomery, AL                   Oxnard-Thousand Oaks-Ventura, CA 
##                                                  1                                                  1                                                  1 
##                     Pensacola-Ferry Pass-Brent, FL                                         Racine, WI                                      Rochester, NY 
##                                                  1                                                  1                                                  1 
##                                          Salem, OR                 San Jose-Sunnyvale-Santa Clara, CA                        Seattle-Tacoma-Bellevue, WA 
##                                                  1                                                  1                                                  1 
##                Tampa-St. Petersburg-Clearwater, FL                                  Trenton-Ewing, NJ         Virginia Beach-Norfolk-Newport News, VA-NC 
##                                                  1                                                  1                                                  1 
##                                      Waterbury, CT                                        Wichita, KS                                Barnstable Town, MA 
##                                                  1                                                  1                                                  2 
##                  Charlotte-Gastonia-Concord, NC-SC                Chicago-Naperville-Joliet, IN-IN-WI                                       Columbia, SC 
##                                                  2                                                  2                                                  2 
##                    Dallas-Fort Worth-Arlington, TX                                   Jacksonville, FL                                        Orlando, FL 
##                                                  2                                                  2                                                  2 
##              Sacramento-Arden-Arcade-Roseville, CA                               Canton-Massillon, OH                        Phoenix-Mesa-Scottsdale, AZ 
##                                                  2                                                  3                                                  3 
##               Providence-Fall River-Warwick, MA-RI                                 Salt Lake City, UT                Davenport-Moline-Rock Island, IA-IL 
##                                                  3                                                  3                                                  4 
##           Philadelphia-Camden-Wilmington, PA-NJ-DE                                        Danbury, CT                  San Francisco-Oakland-Fremont, CA 
##                                                  4                                                  5                                                  6 
##                    Bridgeport-Stamford-Norwalk, CT New York-Northern New Jersey-Long Island, NY-NJ-PA       Washington-Arlington-Alexandria, DC-VA-MD-WV 
##                                                  7                                                  7                                                  8 
##               Los Angeles-Long Beach-Santa Ana, CA              Miami-Fort Lauderdale-Miami Beach, FL                     Boston-Cambridge-Quincy, MA-NH 
##                                                  9                                                 16                                                 18


sort(tapply(CPS$Country == "Somalia", CPS$MetroArea, sum, na.rm=TRUE))
##                                          Akron, OH                        Albany-Schenectady-Troy, NY                                         Albany, GA 
##                                                  0                                                  0                                                  0 
##                                    Albuquerque, NM                  Allentown-Bethlehem-Easton, PA-NJ                                        Altoona, PA 
##                                                  0                                                  0                                                  0 
##                                       Amarillo, TX                                       Anderson, IN                                       Anderson, SC 
##                                                  0                                                  0                                                  0 
##                                      Ann Arbor, MI                                Anniston-Oxford, AL                                        Appleton,WI 
##                                                  0                                                  0                                                  0 
##                                      Asheville, NC                            Athens-Clark County, GA                 Atlanta-Sandy Springs-Marietta, GA 
##                                                  0                                                  0                                                  0 
##                                  Atlantic City, NJ                     Augusta-Richmond County, GA-SC                              Austin-Round Rock, TX 
##                                                  0                                                  0                                                  0 
##                                    Bakersfield, CA                               Baltimore-Towson, MD                                         Bangor, ME 
##                                                  0                                                  0                                                  0 
##                                Barnstable Town, MA                                    Baton Rouge, LA                           Beaumont-Port Author, TX 
##                                                  0                                                  0                                                  0 
##                                     Bellingham, WA                                           Bend, OR                                       Billings, MT 
##                                                  0                                                  0                                                  0 
##                                     Binghamton, NY                              Birmingham-Hoover, AL                              Bloomington-Normal IL 
##                                                  0                                                  0                                                  0 
##                                    Bloomington, IN                               Boise City-Nampa, ID                     Boston-Cambridge-Quincy, MA-NH 
##                                                  0                                                  0                                                  0 
##                                        Boulder, CO                                  Bowling Green, KY                           Bremerton-Silverdale, WA 
##                                                  0                                                  0                                                  0 
##                    Bridgeport-Stamford-Norwalk, CT                          Brownsville-Harlingen, TX                          Buffalo-Niagara Falls, NY 
##                                                  0                                                  0                                                  0 
##                               Canton-Massillon, OH                          Cape Coral-Fort Myers, FL                                   Cedar Rapids, IA 
##                                                  0                                                  0                                                  0 
##                               Champaign-Urbana, IL                    Charleston-North Charleston, SC                                     Charleston, WV 
##                                                  0                                                  0                                                  0 
##                  Charlotte-Gastonia-Concord, NC-SC                                 Chattanooga, TN-GA                Chicago-Naperville-Joliet, IN-IN-WI 
##                                                  0                                                  0                                                  0 
##                                          Chico, CA                    Cincinnati-Middletown, OH-KY-IN                        Cleveland-Elyria-Mentor, OH 
##                                                  0                                                  0                                                  0 
##                                  Coeur d'Alene, ID                               Colorado Springs, CO                                       Columbia, MO 
##                                                  0                                                  0                                                  0 
##                                       Columbia, SC                                    Columbus, GA-AL                                 Corpus Christi, TX 
##                                                  0                                                  0                                                  0 
##                    Dallas-Fort Worth-Arlington, TX                                        Danbury, CT                Davenport-Moline-Rock Island, IA-IL 
##                                                  0                                                  0                                                  0 
##                                        Decatur, Al                                        Decatur, IL             Deltona-Daytona Beach-Ormond Beach, FL 
##                                                  0                                                  0                                                  0 
##                                  Denver-Aurora, CO                                     Des Moines, IA                         Detroit-Warren-Livonia, MI 
##                                                  0                                                  0                                                  0 
##                                          Dover, DE                                      Duluth, MN-WI                                         Durham, NC 
##                                                  0                                                  0                                                  0 
##                                     Eau Claire, WI                                      El Centro, CA                                        El Paso, TX 
##                                                  0                                                  0                                                  0 
##                                           Erie, PA                             Eugene-Springfield, OR                                  Evansville, IN-KY 
##                                                  0                                                  0                                                  0 
##                                     Farmington, NM              Fayetteville-Springdale-Rogers, AR-MO                                   Fayetteville, NC 
##                                                  0                                                  0                                                  0 
##                                          Flint, MI                                       Florence, AL                          Fort Collins-Loveland, CO 
##                                                  0                                                  0                                                  0 
##                                  Fort Smith, AR-OK             Fort Walton Beach-Crestview-Destin, FL                                     Fort Wayne, IN 
##                                                  0                                                  0                                                  0 
##                                         Fresno, CA                                    Gainesville, FL                           Grand Rapids-Wyoming, MI 
##                                                  0                                                  0                                                  0 
##                                        Greeley, CO                                      Green Bay, WI                          Greensboro-High Point, NC 
##                                                  0                                                  0                                                  0 
##                                     Greenville, SC                                Gulfport-Biloxi, MS                      Hagerstown-Martinsburg, MD-WV 
##                                                  0                                                  0                                                  0 
##                            Harrisburg-Carlisle, PA                                   Harrisonburg, VA           Hartford-West Hartford-East Hartford, CT 
##                                                  0                                                  0                                                  0 
##                      Hickory-Morgantown-Lenoir, NC                            Holland-Grand Haven, MI                                       Honolulu, HI 
##                                                  0                                                  0                                                  0 
##                       Huntington-Ashland, WV-KY-OH                                     Huntsville, AL                                   Indianapolis, IN 
##                                                  0                                                  0                                                  0 
##                                      Iowa City, IA                                        Jackson, MI                                        Jackson, MS 
##                                                  0                                                  0                                                  0 
##                                   Jacksonville, FL                                   Jacksonville, NC                                     Janesville, WI 
##                                                  0                                                  0                                                  0 
##                                   Johnson City, TN                                      Johnstown, PA                                         Joplin, MO 
##                                                  0                                                  0                                                  0 
##                              Kalamazoo-Portage, MI                               Kankakee-Bradley, IL                                 Kansas City, MO-KS 
##                                                  0                                                  0                                                  0 
##                       Killeen-Temple-Fort Hood, TX                           Kingsport-Bristol, TN-VA                                       Kingston, NY 
##                                                  0                                                  0                                                  0 
##                                      Knoxville, TN                                      La Crosse, WI                                      Lafayette, LA 
##                                                  0                                                  0                                                  0 
##                                   Lake Charles, LA                          Lakeland-Winter Haven, FL                                      Lancaster, PA 
##                                                  0                                                  0                                                  0 
##                           Lansing-East Lansing, MI                                         Laredo, TX                                     Las Cruses, NM 
##                                                  0                                                  0                                                  0 
##                             Las Vegas-Paradise, NV                                       Lawrence, KS                                         Lawton, OK 
##                                                  0                                                  0                                                  0 
##                   Leominster-Fitchburg-Gardner, MA                              Lexington-Fayette, KY                  Little Rock-North Little Rock, AR 
##                                                  0                                                  0                                                  0 
##                                       Longview, TX               Los Angeles-Long Beach-Santa Ana, CA                                  Louisville, KY-IN 
##                                                  0                                                  0                                                  0 
##                                        Lubbock, TX                                      Lynchburg, VA                                          Macon, GA 
##                                                  0                                                  0                                                  0 
##                                         Madera, CA                                        Madison, WI                         McAllen-Edinburg-Pharr, TX 
##                                                  0                                                  0                                                  0 
##                                        Medford, OR                                  Memphis, TN-MS-AR                                         Merced, CA 
##                                                  0                                                  0                                                  0 
##              Miami-Fort Lauderdale-Miami Beach, FL                         Michigan City-La Porte, IN                                        Midland, TX 
##                                                  0                                                  0                                                  0 
##                  Milwaukee-Waukesha-West Allis, WI                                         Mobile, AL                                        Modesto, CA 
##                                                  0                                                  0                                                  0 
##                                         Monroe, LA                                         Monroe, MI                                     Montgomery, AL 
##                                                  0                                                  0                                                  0 
##                         Muskegon-Norton Shores, MI         Myrtle Beach-Conway-North Myrtle Beach, SC                                           Napa, CA 
##                                                  0                                                  0                                                  0 
##                            Naples-Marco Island, FL                Nashville-Davidson-Murfreesboro, TN                                      New Haven, CT 
##                                                  0                                                  0                                                  0 
##                    New Orleans-Metairie-Kenner, LA New York-Northern New Jersey-Long Island, NY-NJ-PA                            Niles-Benton Harbor, MI 
##                                                  0                                                  0                                                  0 
##                          Norwich-New London, CT-RI                                          Ocala, FL                                     Ocean City, NJ 
##                                                  0                                                  0                                                  0 
##                               Ogden-Clearfield, UT                                  Oklahoma City, OK                                        Olympia, WA 
##                                                  0                                                  0                                                  0 
##                        Omaha-Council Bluffs, NE-IA                                        Orlando, FL                                 Oshkosh-Neenah, WI 
##                                                  0                                                  0                                                  0 
##                   Oxnard-Thousand Oaks-Ventura, CA                  Palm Bay-Melbourne-Titusville, FL                         Panama City-Lynn Haven, FL 
##                                                  0                                                  0                                                  0 
##                     Pensacola-Ferry Pass-Brent, FL                                         Peoria, IL           Philadelphia-Camden-Wilmington, PA-NJ-DE 
##                                                  0                                                  0                                                  0 
##                                     Pittsburgh, PA                     Port St. Lucie-Fort Pierce, FL               Poughkeepsie-Newburgh-Middletown, NY 
##                                                  0                                                  0                                                  0 
##                                       Prescott, AZ               Providence-Fall River-Warwick, MA-RI                                     Provo-Orem, UT 
##                                                  0                                                  0                                                  0 
##                                         Pueblo, CO                                    Punta Gorda, FL                                         Racine, WI 
##                                                  0                                                  0                                                  0 
##                                   Raleigh-Cary, NC                                        Reading, PA                                    Reno-Sparks, NV 
##                                                  0                                                  0                                                  0 
##                       Riverside-San Bernardino, CA                                        Roanoke, VA                             Rochester-Dover, NH-ME 
##                                                  0                                                  0                                                  0 
##                                      Rochester, NY                                       Rockford, IL              Sacramento-Arden-Arcade-Roseville, CA 
##                                                  0                                                  0                                                  0 
##                 Saginaw-Saginaw Township North, MI                                          Salem, OR                                        Salinas, CA 
##                                                  0                                                  0                                                  0 
##                                      Salisbury, MD                                 Salt Lake City, UT                                    San Antonio, TX 
##                                                  0                                                  0                                                  0 
##                  San Diego-Carlsbad-San Marcos, CA                  San Francisco-Oakland-Fremont, CA                 San Jose-Sunnyvale-Santa Clara, CA 
##                                                  0                                                  0                                                  0 
##                    San Luis Obispo-Paso Robles, CA                         Santa-Cruz-Watsonville, CA               Santa Barbara-Santa Maria-Goleta, CA 
##                                                  0                                                  0                                                  0 
##                                       Santa Fe, NM                            Santa Rosa-Petaluma, CA                      Sarasota-Bradenton-Venice, FL 
##                                                  0                                                  0                                                  0 
##                                       Savannah, GA                          Scranton-Wilkes Barre, PA                        Shreveport-Bossier City, LA 
##                                                  0                                                  0                                                  0 
##                        South Bend-Mishawaka, IN-MI                                    Spartanburg, SC                                        Spokane, WA 
##                                                  0                                                  0                                                  0 
##                                    Springfield, IL                                 Springfield, MA-CT                                    Springfield, MO 
##                                                  0                                                  0                                                  0 
##                                    Springfield, OH                                   St. Louis, MO-IL                                       Stockton, CA 
##                                                  0                                                  0                                                  0 
##                                       Syracuse, NY                                    Tallahassee, FL                Tampa-St. Petersburg-Clearwater, FL 
##                                                  0                                                  0                                                  0 
##                                         Toledo, OH                                         Topeka, KS                                  Trenton-Ewing, NJ 
##                                                  0                                                  0                                                  0 
##                                         Tucson, AZ                                          Tulsa, OK                                     Tuscaloosa, AL 
##                                                  0                                                  0                                                  0 
##                                     Utica-Rome, NY                                       Valdosta, GA                              Vallejo-Fairfield, CA 
##                                                  0                                                  0                                                  0 
##                                     Vero Beach, FL                                       Victoria, TX                   Vineland-Millville-Bridgeton, NJ 
##                                                  0                                                  0                                                  0 
##         Virginia Beach-Norfolk-Newport News, VA-NC                            Visalia-Porterville, CA                                           Waco, TX 
##                                                  0                                                  0                                                  0 
##                                  Warner Robins, GA       Washington-Arlington-Alexandria, DC-VA-MD-WV                                      Waterbury, CT 
##                                                  0                                                  0                                                  0 
##                           Waterloo-Cedar Falls, IA                                         Wausau, WI                                        Wichita, KS 
##                                                  0                                                  0                                                  0 
##                                  Winston-Salem, NC                                   Worcester, MA-CT                                         Yakima, WA 
##                                                  0                                                  0                                                  0 
##                                   York-Hanover, PA                     Youngstown-Warren-Boardman, OH                                         Dayton, OH 
##                                                  0                                                  0                                                  1 
##                                       Richmond, VA                     Houston-Baytown-Sugar Land, TX                                    Sioux Falls, SD 
##                                                  1                                                  2                                                  2 
##                    Burlington-South Burlington, VT                        Portland-South Portland, ME                Portland-Vancouver-Beaverton, OR-WA 
##                                                  3                                                  3                                                  3 
##                                       Columbus, OH                                       Fargo, ND-MN                        Phoenix-Mesa-Scottsdale, AZ 
##                                                  5                                                  5                                                  7 
##                        Seattle-Tacoma-Bellevue, WA                                      St. Cloud, MN             Minneapolis-St Paul-Bloomington, MN-WI 
##                                                  7                                                  7                                                 17

Explanation: We see that New York has the most interviewees born in India (96), Boston has the most born in Brazil (18), and Minneapolis has the most born in Somalia (17).