tapply error: arguments must have the same length

CountryOfBirthCode MetroAreaCode PeopleInHousehold Min. : 57.00 Min. :10420 Min. : 1.000
1st Qu.: 57.00 1st Qu.:21780 1st Qu.: 2.000
Median : 57.00 Median :34740 Median : 3.000
Mean : 82.68 Mean :35075 Mean : 3.284
3rd Qu.: 57.00 3rd Qu.:41860 3rd Qu.: 4.000
Max. :555.00 Max. :79600 Max. :15.000
NA's :34238
Not exactly sure what you're looking for, but here is the summary of the DataSet that I'm working with currently. My issue is trying to use the tapply function to determine what metroareacode has the most (total value) interviewees from India/Brazil/Somalia. Both are integers, however each variable has a different amount of sub variables (probably not the right name for it... still learning here).

  Region               State            Age       

Midwest :30684 California :11570 Min. : 0.00
Northeast:25939 Texas : 7077 1st Qu.:19.00
South :41502 New York : 5595 Median :39.00
West :33177 Florida : 5149 Mean :38.83
Pennsylvania: 3930 3rd Qu.:57.00
Illinois : 3912 Max. :85.00
(Other) :94069
Married Sex Education
Divorced :11151 Female:67481 High school :30906
Married :55509 Male :63821 Bachelor's degree :19443
Never Married:30772 Some college, no degree:18863
Separated : 2027 No high school diploma :16095
Widowed : 6505 Associate degree : 9913
NA's :25338 (Other) :10744
NA's :25338
Race Hispanic
American Indian : 1433 Min. :0.0000
Asian : 6520 1st Qu.:0.0000
Black : 13913 Median :0.0000
Multiracial : 2897 Mean :0.1393
Pacific Islander: 618 3rd Qu.:0.0000
White :105921 Max. :1.0000

           Citizenship               EmploymentStatus

Citizen, Native :116639 Disabled : 5712
Citizen, Naturalized: 7073 Employed :61733
Non-Citizen : 7590 Not in Labor Force:15246
Retired :18619
Unemployed : 4203
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
MetroArea.x
New York-Northern New Jersey-Long Island, NY-NJ-PA: 5409
Washington-Arlington-Alexandria, DC-VA-MD-WV : 4177
Los Angeles-Long Beach-Santa Ana, CA : 4102
Philadelphia-Camden-Wilmington, PA-NJ-DE : 2855
Chicago-Naperville-Joliet, IN-IN-WI : 2772
(Other) :77749
NA's :34238
MetroArea.y
New York-Northern New Jersey-Long Island, NY-NJ-PA: 5409
Washington-Arlington-Alexandria, DC-VA-MD-WV : 4177
Los Angeles-Long Beach-Santa Ana, CA : 4102
Philadelphia-Camden-Wilmington, PA-NJ-DE : 2855
Chicago-Naperville-Joliet, IN-IN-WI : 2772
(Other) :77749
NA's :34238
Country
United States:115063
Mexico : 3921
Philippines : 839
India : 770
China : 581
(Other) : 9952
NA's : 176

/r/RStudio Thread