myDF <- read.delim("/data/public/election2016/itcont.txt", sep="|", header=F)

Question 1

The average donations were the largest on September 16, 2014.

sort(tapply(myDF$V15, myDF$V14, mean))
##     6212012    10142014     5022160     6302106     5282018     5212106 
##     0.00000    11.00000    20.00000    20.00000    23.00000    25.00000 
##     8292016     7022016     4263016     6019206     6032160     8302016 
##    25.00000    27.85250    35.00000    35.00000    42.50000    44.54024 
##     6281016     6303016    11262015     7042016     8052025     5292016 
##    50.00000    50.00000    55.29659    57.61359    60.00000    62.07491 
##     7172016     4172016    12252015     5222016     5082016     5212016 
##    63.23645    64.00293    65.60571    66.20839    67.50515    68.66098 
##    11272015    11282015     5142016     4162016     4092016     5302016 
##    68.82564    69.55341    69.82448    69.91035    69.97834    70.79904 
##     4232016     7102016     7162016     8302015     5282016     6082018 
##    70.80984    71.03864    71.61176    72.07610    74.85274    75.00000 
##    11292015     1032015     6042016     7032015     4032016    12202015 
##    75.73775    76.48920    77.51168    78.73831    78.91840    79.69406 
##     7262015     4242016     5152016     8312016    10312015     1172016 
##    80.51256    80.76827    81.52566    83.15241    83.53001    85.54322 
##     7232016    12272015     4102016     7242016     7092016     5072016 
##    86.16528    86.47930    87.35731    87.91622    88.52983    88.56354 
##     6052016     9132015     1042015     7042015    11152015     7052015 
##    90.55923    91.51437    92.23695    92.56945    93.03699    95.46578 
##     7032016     7302016     8152015     4302016     2282016     7252015 
##    96.29045    96.70266    97.20357    97.83430    98.66412    99.44911 
##     4212013     5102010     6072160     2272016     8022015     3272016 
##   100.00000   100.00000   100.00000   101.03807   102.23680   103.29752 
##     6192016     5032016     1162016     8282016     6182016     6112016 
##   103.76375   104.28983   104.55862   105.20000   105.89729   106.49357 
##     2142016     3062016    12132015     1302016    10042015    11212015 
##   106.55978   106.94908   107.39762   108.39329   109.89850   110.10565 
##     2202016    12052015     8072016     7312015    11132015     8292015 
##   110.25915   111.85992   112.03879   112.21645   112.32514   113.34181 
##     1102016     2132016    11072015     7122015     3132016    12262015 
##   113.62583   114.07099   114.11450   114.78925   114.79377   115.01887 
##    10032015     9072015     7192016     2212016     9202015    11202015 
##   115.05797   115.60778   116.28136   116.99244   117.82358   118.81103 
##    11082015     1032016     7192015     1022016    11142015    10252015 
##   119.10659   119.47464   119.68097   120.94467   121.19994   121.24581 
##    11222015     8222015     8162015     1232016     3052016     2072016 
##   121.50811   121.86129   122.15714   122.18120   122.53794   122.73499 
##    12192015     5012016     9052015    12242015     8232015     7212016 
##   123.17386   124.13370   124.41007   125.59837   126.04845   126.06278 
##     4292016     1112015     8312015    10102015     4052015     7182016 
##   127.07871   128.55130   128.79063   129.02200   130.11893   130.48076 
##     9062015     7012016    10182015     2062016     6122016    11302015 
##   130.75994   130.89763   131.18864   131.70594   132.31603   134.00496 
##    10302015     4082016     8142015     3122016    12062015     5312015 
##   134.21293   134.38828   135.73393   136.13642   136.38158   136.81799 
##    11012015     3262016     8092015     8252016     1242015     4062016 
##   137.03455   137.52289   138.31775   138.50000   139.82572   140.40590 
##     7312016     8012015     2152015    10112015     6082016     4022016 
##   140.49207   140.62030   141.08604   141.43237   141.62735   142.54600 
##     7222016     9262015    12122015     2222015     7102015     1252015 
##   142.94783   143.45498   143.62394   144.61119   145.40924   146.11840 
##     7182015    10242015    10022015     3202016     5032015     6212015 
##   146.26110   146.28738   146.53016   148.50174   148.65611   148.74690 
##     7052016     5272016     6302013     1242016     7272016     5202016 
##   149.23741   149.25348   150.00000   150.08748   151.72728   152.38945 
##     4052016     7302015     7122016    10152015     9122015     7242015 
##   152.82027   153.22064   155.18828   155.78815   156.01102   157.24128 
##    10172015     1012015     1172015     8132016     7152016     7112015 
##   157.72669   157.95727   158.00617   158.21053   158.98307   159.13983 
##     2102016     6202015     8172016    10162015     1092016     7292016 
##   159.63376   160.73747   162.69942   162.70304   163.60874   164.50343 
##     2152016     9272015     4262016     1282014     1182015     4152016 
##   165.22332   165.98058   166.29520   166.66667   166.88977   167.40577 
##     4202016     7152015     7172015    10092015     7062016     7262016 
##   168.89835   172.21127   173.25680   173.61153   174.33712   174.65084 
##    10232015     3192016     8132015     2292016     7022015     2012015 
##   175.16784   175.81531   175.88054   176.26321   176.80801   177.31798 
##     6262016     8082015     8262016     6282015     5112016     8212015 
##   177.62210   178.20620   178.33333   179.19684   179.50604   180.59700 
##     7082016     8282015     3312014    12152015     4072016     7282016 
##   180.59827   181.14004   181.66667   181.70097   181.92715   182.10847 
##    10292015     5312016     7142016     2082015     1182016     5232015 
##   182.14574   182.80856   184.22454   184.81105   185.65877   187.98272 
##     6142015     5252015     9042015     5062016     7072016    10122015 
##   190.36347   190.98267   192.02023   193.11180   194.51952   194.82145 
##    11062015     5162015     2142015     9192015     4222016     4132016 
##   194.82848   194.83545   195.62079   197.13323   197.24780   199.08928 
##    10082015     2102012     2122014     3052014     4222106     7072014 
##   199.17240   200.00000   200.00000   200.00000   200.00000   200.00000 
##     7222014     7232014     9272016    10092014     7252016    12182015 
##   200.00000   200.00000   200.00000   200.00000   201.03747   201.14394 
##     3152015     4182016     8052015     2022016     5102016    10142015 
##   201.18525   203.26230   203.43385   204.76194   204.86210   207.91345 
##     6132015     4262015     4032015     5292015    10222015     8212016 
##   208.55291   208.60028   208.62790   210.63248   211.07724   211.32353 
##     6102016    10132015     4042016     2282015     6072015     4282016 
##   211.75320   212.21845   213.62332   213.74998   214.59894   214.65035 
##     4192016     7282015     1252016     9112015    12012015     5182016 
##   214.97475   215.20892   217.21538   217.43817   219.11427   219.68719 
##     6122014     5092016     4192015    12042015     6152016     3012015 
##   220.00000   220.06205   220.80698   221.50191   222.08425   222.55291 
##     8262015    11192015     2212015     4272016    12312015     6072016 
##   222.73082   223.16066   223.26404   225.45929   225.55618   226.97106 
##     7132016     5152015     5302015     6022016     5102015    12032015 
##   228.93584   230.38831   232.01206   233.40519   234.68019   235.67772 
##     7112016     1192015     3282015     3292015     8032015     6092016 
##   235.79146   237.64403   239.99324   240.99956   241.13489   241.79113 
##     5242015     8062016     9302015     8072015     3082015     4012016 
##   241.85464   242.14008   242.25972   244.11387   244.32687   245.55545 
##     2182016     3222015     5192016     8122015     5052016    11112015 
##   246.04086   246.23784   246.26763   246.61552   247.92074   249.46845 
##     2022012     2112012     2182012     2212012     2222012     2272012 
##   250.00000   250.00000   250.00000   250.00000   250.00000   250.00000 
##     3312018     4182014     4282006     7292014     7312014     8012160 
##   250.00000   250.00000   250.00000   250.00000   250.00000   250.00000 
##    10022014    10032014    10222000    10282014    11012011    11292016 
##   250.00000   250.00000   250.00000   250.00000   250.00000   250.00000 
##    11302014    11302016    12122016    12272014     8062015     4242015 
##   250.00000   250.00000   250.00000   250.00000   250.03980   250.30132 
##     1022015     8202016     7012015     4042015     5232016    12112014 
##   250.61695   251.34375   252.18944   253.38008   254.67271   255.00000 
##     2032016     4252016     6272015     9022015     4112015     7202015 
##   255.17804   256.27309   256.36785   256.41211   257.50355   257.81000 
##     1312016     2092016     6122015     9242015     6242016     3212015 
##   259.59321   260.06834   260.17633   260.42663   261.26971   262.58022 
##     8152016     5022015     7092015    12292014     3252016    12052014 
##   263.50000   263.74466   263.79673   264.28571   264.95963   265.00000 
##     7272015    10012015     4212016     8172015     8272015     9252015 
##   265.74779   266.08601   267.06405   269.62501   270.30884   271.60150 
##     1012016    11052015     5092015    10282015    12182014    12292015 
##   272.58031   273.41930   273.81250   274.62030   276.00000   277.08202 
##     7212015     4252015     2072015     1132016     6252016    11042015 
##   277.17491   277.85240   278.69121   278.73196   279.99280   280.52701 
##     2172016     1142014     2142014     4122016     9252014     5222015 
##   281.20831   282.00000   282.00000   283.04012   285.00000   285.37007 
##    10272015     4112016     9162015     8112015     5042016    10202015 
##   287.61513   287.93155   288.34938   288.73614   289.46728   289.61828 
##     5162016    12112015     2082016     6062015     3142015     2012016 
##   289.91514   290.06788   290.51637   292.67589   292.95342   293.84047 
##     2262016    11102015    11092015    11172015     3022016     4122015 
##   293.85949   295.14582   295.45595   297.76020   298.69360   298.76523 
##    11232015    10292016    12302016     9012015     5122016    12162015 
##   299.91560   300.00000   300.00000   301.39831   305.77067   305.80613 
##     3162016     1102015    11122015     4302015     3082016     7222015 
##   306.61309   307.89936   308.10112   308.15189   308.58610   309.34833 
##    12072015     3142016    10192015     2232016     8192015     2272015 
##   310.64088   312.77944   313.48578   313.89007   314.46241   314.76416 
##     1042016     6172016     8232016     3292016     7082015     9082015 
##   315.52659   317.93269   318.60204   320.40417   320.45124   320.50100 
##     7142015    11162015     3232016     9152015     7292015     7132015 
##   321.02992   321.05367   321.65248   321.81957   322.08672   323.20458 
##     2192016     2112016     6062016     7162015     8102015     6042015 
##   324.27666   324.56558   326.08217   326.77796   327.13242   328.01748 
##     8012016     7232015     8142016     4142016     1212016     2132015 
##   329.39493   330.20173   331.02703   331.76786   332.44155   333.19881 
##     1282016     5132016    12282015     9172015     1052016    11022015 
##   334.59848   335.06685   335.59605   336.59105   336.67250   336.68100 
##     8202015     1122016     3302016    10062015    10252016     1292016 
##   338.69437   339.52239   339.55248   339.62684   340.00000   340.21413 
##     8192016     8092016     6032016     6232016     9032015    12302015 
##   340.94624   341.06864   341.68706   342.80224   344.20415   345.17084 
##     8052016     9212015     8242015     5022016     6302016     9182015 
##   345.67178   347.24812   347.90660   348.20671   348.92189   349.01511 
##    12222015     1272016     3282014     5012015     2052016     7202016 
##   349.37687   349.39055   350.00000   350.21560   350.74451   350.76393 
##    11252015     1262016     6192015     4152015     7072015     3182016 
##   350.83104   351.50953   351.68257   352.09852   355.23134   356.13433 
##     1152015     9232015     1162015     5172016     8252015     7062015 
##   357.80910   358.82100   359.39609   361.88299   363.55390   366.57857 
##     6052015     3132015     2162015     3102016     6202016    10152014 
##   368.05367   368.66034   368.78373   370.05631   372.96738   375.00000 
##    12242014     9092015     3152016    10052015     3092016     5082015 
##   375.00000   375.27416   376.58677   377.28622   379.43739   380.83950 
##     9222015     1212015    10072015     9142015     5242016    12102015 
##   381.47191   381.53087   384.01506   384.33694   384.85435   387.69989 
##     8162016     3072015     4022015     5252016     6132016     6152015 
##   387.81395   389.97366   391.98807   392.65867   393.94114   394.52271 
##     8032016     1302015    12142015     5262016     2202015     1052015 
##   394.69474   397.08336   397.10679   398.70029   399.09021   399.69828 
##     8182015    11242015     1222015     3312016    12212015     1312015 
##   402.30801   403.06831   403.61695   405.73199   407.32501   408.08274 
##     3282016     8242016    12232015     6292016    12032014     9102015 
##   408.48747   409.33333   411.84948   413.88346   416.66667   416.86583 
##     2022015     6222016     2122016     1222016     3112016     1062015 
##   418.50234   418.92242   420.23347   420.31788   420.55496   427.75307 
##     6142016     2162016     2242016     6282016     8042015     6212016 
##   428.25570   429.79031   429.88810   430.60628   435.30586   436.92461 
##     3032015     1092015     6162015     1142016     9282015    11182015 
##   439.89043   440.37912   440.51361   441.70069   442.95609   445.22588 
##     3062015     5262015     5222014     1282015     6012015     2042016 
##   446.94874   449.45458   450.00000   450.86634   452.99075   454.19004 
##     4232015    12082015     3102015     6032015     3072016     4012015 
##   454.92315   455.52969   458.06119   459.31605   462.30276   465.05287 
##     1152016     2032015     6022015     6272016     6182015     1062016 
##   465.85286   468.43868   470.08981   471.20470   471.97378   474.21566 
##     4292015     2252016     9292015     1132015     5052015     1192016 
##   476.27550   480.98122   485.99425   487.18577   489.52911   489.95891 
##     3122015     8222016     2062015     5132015       41031     2082018 
##   490.94377   497.80899   499.50312   499.66348   500.00000   500.00000 
##     2122012     2172012     2272014     8212014     9122014    11102016 
##   500.00000   500.00000   500.00000   500.00000   500.00000   500.00000 
##    11222013    12022014    12062014    12232016    12252016     3052015 
##   500.00000   500.00000   500.00000   500.00000   500.00000   500.32369 
##     1082015     3042015     5062015     8112016     8082016     1072016 
##   500.65284   507.29329   507.93447   508.51020   511.12071   511.79639 
##     4182015     5172015     3272015     5212015     1262015    12092015 
##   513.09199   515.90322   517.15149   518.43236   519.29671   520.46452 
##     3172016     6262015     3222016     5192015     2232015     6172015 
##   522.56389   529.36170   529.40960   532.06855   535.17333   541.07474 
##     3202015     3012016     4282015     4072015     4202015     4222015 
##   541.44375   541.60340   544.30500   544.91897   548.61411   550.57474 
##     3212016     6112015     5072015     7032014     2242015     6102015 
##   551.94759   553.54561   554.72733   555.00000   556.13530   557.58349 
##     1232015     4172015     5202015     4272015     5122015     2262015 
##   563.07920   565.35942   565.98637   566.95372   566.98720   568.80808 
##     4212015     5272015     8192014     2222016     3252015     3032016 
##   570.66064   571.29848   575.00000   575.32794   575.64589   577.45560 
##     2252015     3242015     4062015     6302015    12172015     3172014 
##   577.47482   581.25097   582.91432   595.41795   598.48945   600.00000 
##     8122016     3242016     2052015     2112015     3022015     5112015 
##   601.14815   602.18287   602.49699   602.92573   603.13056   605.28166 
##     2092015     1202015     2122015     6012016     3312015    11222014 
##   608.37100   608.74989   614.13579   614.31006   621.98858   625.00000 
##    11252014    11292014     5182015     3042016     5042015    12122014 
##   625.00000   625.00000   626.69025   629.29548   630.31013   633.50000 
##     3262015     7172014     1112016     8102016     4142015    12022015 
##   640.31937   650.00000   651.51334   652.68362   658.62016   673.05728 
##     1082016     3302012     4282014     3112015     1202016     2192015 
##   676.37520   683.33333   690.00000   696.18524   697.17775   701.51587 
##     3192015     5282015     1272015    10262015     2042015     4082015 
##   712.07675   723.44703   732.96251   733.13572   733.78451   734.96737 
##     6092015    12012014    11262014    12262014     5142015     8022016 
##   746.93589   747.00000   750.00000   750.00000   775.50109   787.78538 
##     6222015    11212014     1122015     3182015     3302015    10212015 
##   796.07849   810.00000   824.99800   833.78634   844.60529   870.63185 
##     3092015     2182015     3162015     6252015    12092014     8182016 
##   874.09783   874.52181   884.12439   907.61084   908.33333   915.36585 
##     6242015    11242014    11232014    11032015     4162015    12042014 
##   918.72446   950.00000   970.00000   986.79389   988.47348   997.33333 
##     1231916     6132013     6172916     6222014    10272014    10312014 
##  1000.00000  1000.00000  1000.00000  1000.00000  1000.00000  1000.00000 
##    11132016     6082015    12142016    11202014     6232015     2102015 
##  1000.00000  1007.79232  1054.00000  1073.21429  1076.67863  1098.32665 
##     3172015     4102015     8042016     3232015    12232014    12172014 
##  1102.75841  1184.23713  1212.08978  1265.44962  1283.33333  1322.22222 
##    12222014     3272011     6132106    12282014    12312014    11272016 
##  1482.33333  1500.00000  1500.00000  1550.00000  1557.82353  1600.00000 
##     4092015    12302014     6292015     3182014    12312011     6162016 
##  1605.49497  1677.00000  1758.42242  1800.00000  1800.00000  1870.19226 
##     4132015     1012014     4112014     6022201     6242014    12082014 
##  1899.19713  1942.50000  2000.00000  2000.00000  2000.00000  2040.00000 
##    10012014     8152014     5312006    11272014     1292015    11192014 
##  2366.66667  2400.00000  2500.00000  2500.00000  2517.75142  2596.00000 
##    12162014     3092000    12092016     1072015    11202016     1142015 
##  2670.00000  2700.00000  2700.00000  2735.17096  2750.00000  3103.24577 
##     3072014    12012013     1042014    12192014     2172015     3112006 
##  3205.00000  3300.00000  5000.00000  5050.00000  5281.63768  5400.00000 
##     9032014    12312016     3042014     3272014     9162014 
##  5500.00000  5974.00000 10000.00000 10000.00000 15000.00000

Question 2

2a. The largest number of donations were made on these 10 days, e.g., the most donations were made on December 31, 2015

tail(sort(table(myDF$V14)), 10)
## 
##  7312015  3312016  6302015  4302016  2292016 11302015  5312016  9302015 
##   100809   106715   109476   125790   129824   139073   147768   152212 
##  6302016 12312015 
##   181479   198283

2b. The largest dollar amounts of donations were made on these 10 days, e.g., the most donations were made on June 30, 2015

tail(sort(tapply(myDF$V15, myDF$V14, sum)), 10)
##  6292016  5312016  3312015  9302015  6292015  3312016 12312015  6162016 
## 26262975 27013255 33326148 36874836 37885211 43297689 44723957 62430758 
##  6302016  6302015 
## 63321995 65183975

Question 3

3a. There were 1277 donations by people at Purdue.

length(grep("PURDUE", myDF$V12))
## [1] 1277

3b. Among those donations, 599 of them were made by residents of West Lafayette.

v <- myDF$V9[grep("PURDUE", myDF$V12)]
v1 <- grep("WEST LAFAYETTE", v)
v2 <- grep("W LAFAYETTE", v)
v3 <- grep("W. LAFAYETTE", v)
length(v1) + length(v2) + length(v3)
## [1] 599

3c. Among the donations by people at Purdue, the campaign C00401224 (ACTBLUE) received the largest number of donations.

tail(sort(table(myDF$V1[grep("PURDUE", myDF$V12)])))
## 
## C00000935 C00010603 C00370643 C00575795 C00577130 C00401224 
##        45        45       102       163       247       428

Question 4

We search for the cities from Indiana that contain Lafayette in the name, because this will also get cities with West Lafayette in the name too. Then we look at all such donation amounts, and take the average. The average size of such a donation is 121.8081 dollars.

mean(myDF$V15[grepl("LAFAYETTE", myDF$V9) & grepl("IN", myDF$V10)])
## [1] 121.8081

Question 5

5a. The largest number of donations were made from these 10 professions:

tail(sort(tapply(myDF$V15, myDF$V13, length)), 11)
##    HOMEMAKER   CONSULTANT     ENGINEER    PROFESSOR   UNEMPLOYED 
##       100251       101454       128415       131053       135172 
##      TEACHER    PHYSICIAN     ATTORNEY              NOT EMPLOYED 
##       135585       175882       292282       486078      1627681 
##      RETIRED 
##      1669912

5b. The largest dollar amount of donations were made from these 10 professions:

tail(sort(tapply(myDF$V15, myDF$V13, sum)), 11)
##     INVESTOR        OWNER     CHAIRMAN    EXECUTIVE    HOMEMAKER 
##     55655444     67703952     97069508     98262822    103255610 
## NOT EMPLOYED          CEO    PRESIDENT     ATTORNEY      RETIRED 
##    109089395    121593216    131069250    145975818    341684261 
##              
##    460083296

Question 6

The total dollar amount of donations in the local zip codes are:

tapply(myDF$V15,strtrim(myDF$V11,5),sum)[c("47901","47902","47903","47904","47905","47906","47907","47909","47996")]
##  47901  47902  47903  47904  47905  47906  47907  47909  47996 
##  18232  17116  16712  22740 116823 207699   5910  84355     70

Question 7

7a. The top 15 cities in Indiana, according to the amount donated, are

tail(sort(tapply(myDF$V15[myDF$V10 == "IN"],myDF$V9[myDF$V10 == "IN"],sum)),15)
##      LAFAYETTE JEFFERSONVILLE       COLUMBUS     VALPARAISO        GRANGER 
##         276236         283306         320807         339999         362430 
##      MISHAWAKA      GREENWOOD        FISHERS     ZIONSVILLE     SOUTH BEND 
##         376463         391854         407783         594682         613114 
##     EVANSVILLE    BLOOMINGTON     FORT WAYNE         CARMEL   INDIANAPOLIS 
##         715520        1106125        1625149        2090512        7138254

7b. The top 15 cities in the whole country, according to the amount donated, are

tail(sort(tapply(myDF$V15,myDF$V9,sum)),15)
##       POTOMAC         CISCO   LAKE FOREST     LAS VEGAS       ATLANTA 
##      22891238      23660751      25591164      26246949      28038012 
##         MIAMI   LITTLE ROCK    CENTERBOOK       HOUSTON        DALLAS 
##      29811784      31452907      50006000      65873981      74682450 
##   LOS ANGELES       CHICAGO SAN FRANCISCO    WASHINGTON      NEW YORK 
##      78362275      82804829      97298200     150438869     289761590

Question 8

8a. Hillary Clinton received the largest amount of money on July 29, 2016.

tail(sort(tapply(myDF$V15[myDF$V1 == "C00575795"],myDF$V14[myDF$V1 == "C00575795"],sum)))
## 7262016 6302015 6082016 7312016 7282016 7292016 
## 1433047 1459562 1473796 1569475 2059280 2142567

8b. Donald Trump received the largest amount of money on June 22, 2016.

tail(sort(tapply(myDF$V15[myDF$V1 == "C00580100"],myDF$V14[myDF$V1 == "C00580100"],sum)))
## 7212016 7222016 6302016 6212016 7282016 6222016 
##  802931  905337 1031298 1046260 2330263 3354893

Question 9

9a. A vector of the donor information can be formed in this way:

donorvec <- paste(myDF$V8, myDF$V9, myDF$V10, myDF$V11)

9b. The donor who donated the most times to the Clinton campaign was MITCHELL, MARCIA LOS ANGELES CA 900363146

tail(sort(tapply( myDF$V1 == "C00575795", donorvec, sum)))
##    WHITE, MICHELLE LAS VEGAS NV 891022133 
##                                       154 
##    SHARA HALL, LISA PORTLAND OR 972213230 
##                                       162 
##     SMITH, CHERYL SUN VALLEY CA 913523014 
##                                       163 
##       SCOTT, MELVIN BENBROOK TX 761266442 
##                                       170 
##           PHAN, JULIE IRVING TX 750604638 
##                                       181 
## MITCHELL, MARCIA LOS ANGELES CA 900363146 
##                                       220

9c. The donor who donated the most times to the Trump campaign was Trump himself: TRUMP, DONALD J. NEW YORK NY 10022

tail(sort(tapply( myDF$V1 == "C00580100", donorvec, sum)))
##  TEDDER, PHILLIP HARTSVILLE SC 29550         MOFFITT, LARRY RENO NV 89509 
##                                   34                                   35 
##      TREIBEL, RANDY REDMOND WA 98053       ELLIS, MARK LAS VEGAS NV 89139 
##                                   36                                   47 
## TAMAYO, DINO EAST NORTHPORT NY 11731   TRUMP, DONALD J. NEW YORK NY 10022 
##                                   68                                  101

9d. To get the counts of the number of times that each person donated to each of the two campains (respectively), we compute these two vectors:

clintoncounts <- tapply( myDF$V1 == "C00575795", donorvec, sum )
trumpcounts <- tapply( myDF$V1 == "C00580100", donorvec, sum )

We can make sure that they came in the same order, by checking the lengths,

length(clintoncounts)
## [1] 2384731
length(trumpcounts)
## [1] 2384731

and moreover by checking to see that the names of the vectors agree:

sum(names(clintoncounts) != names(trumpcounts))
## [1] 0

now we store the names of the donors in this order, and see which donors have a positive donation count for both:

donornames <- names(clintoncounts)
donornames[(clintoncounts > 0) & (trumpcounts > 0)]
## [1] "GINSBERG, MICHAEL TAMPA FL 33626"  
## [2] "REESE, JOHN SAN FRANCISCO CA 94110"
## [3] "SHERMAN, JEFF BOSTON MA 02118"

There are only 3 such people.