##   polarity subjectivity pos_refs_per_ref neg_refs_per_ref
## 1       -1    0.6666667        0.0000000        0.6666667
## 2        1    0.5000000        0.5000000        0.0000000
## 3        0    0.3333333        0.1666667        0.1666667
##   senti_diffs_per_ref
## 1          -0.6666667
## 2           0.5000000
## 3           0.0000000
##   polarity subjectivity pos_refs_per_ref neg_refs_per_ref
## 1       -1          0.5              0.0              0.5
## 2        1          0.5              0.5              0.0
##   senti_diffs_per_ref
## 1                -0.5
## 2                 0.5
##       polarity subjectivity pos_refs_per_ref neg_refs_per_ref
## 1   1.00000000   0.09803922       0.09803922       0.00000000
## 2   0.09090909   0.25581395       0.13953488       0.11627907
## 3   0.50000000   0.12500000       0.09375000       0.03125000
## 4   1.00000000   0.07317073       0.07317073       0.00000000
## 5   1.00000000   0.08333333       0.08333333       0.00000000
## 6   0.60000000   0.07352941       0.05882353       0.01470588
## 7  -0.14285714   0.14893617       0.06382979       0.08510638
## 8  -1.00000000   0.06666667       0.00000000       0.06666667
## 9   1.00000000   0.06122449       0.06122449       0.00000000
## 10  0.25000000   0.23529412       0.14705882       0.08823529
## 11  0.00000000   0.10526316       0.05263158       0.05263158
## 12  0.00000000   0.05555556       0.02777778       0.02777778
## 13  0.60000000   0.09259259       0.07407407       0.01851852
## 14  1.00000000   0.03030303       0.03030303       0.00000000
## 15 -0.33333333   0.09375000       0.03125000       0.06250000
## 16  1.00000000   0.03703704       0.03703704       0.00000000
## 17  0.00000000   0.07547170       0.03773585       0.03773585
## 18  0.60000000   0.17857143       0.14285714       0.03571429
## 19  0.33333333   0.11111111       0.07407407       0.03703704
## 20  0.00000000   0.00000000       0.00000000       0.00000000
## 21  1.00000000   0.06250000       0.06250000       0.00000000
## 22  1.00000000   0.10000000       0.10000000       0.00000000
## 23 -0.60000000   0.19230769       0.03846154       0.15384615
## 24  0.60000000   0.15151515       0.12121212       0.03030303
## 25  1.00000000   0.12500000       0.12500000       0.00000000
## 26  0.00000000   0.07142857       0.03571429       0.03571429
## 27  0.00000000   0.21052632       0.10526316       0.10526316
## 28  0.33333333   0.09090909       0.06060606       0.03030303
## 29  0.00000000   0.06451613       0.03225806       0.03225806
## 30 -0.33333333   0.10714286       0.03571429       0.07142857
##    senti_diffs_per_ref
## 1           0.09803922
## 2           0.02325581
## 3           0.06250000
## 4           0.07317073
## 5           0.08333333
## 6           0.04411765
## 7          -0.02127660
## 8          -0.06666667
## 9           0.06122449
## 10          0.05882353
## 11          0.00000000
## 12          0.00000000
## 13          0.05555556
## 14          0.03030303
## 15         -0.03125000
## 16          0.03703704
## 17          0.00000000
## 18          0.10714286
## 19          0.03703704
## 20          0.00000000
## 21          0.06250000
## 22          0.10000000
## 23         -0.11538462
## 24          0.09090909
## 25          0.12500000
## 26          0.00000000
## 27          0.00000000
## 28          0.03030303
## 29          0.00000000
## 30         -0.03571429
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.0000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.: 0.0000   1st Qu.:0.06786   1st Qu.:0.03604   1st Qu.:0.00000  
##  Median : 0.3333   Median :0.09317   Median :0.06186   Median :0.03078  
##  Mean   : 0.3499   Mean   :0.10588   Mean   :0.06811   Mean   :0.03778  
##  3rd Qu.: 1.0000   3rd Qu.:0.12500   3rd Qu.:0.09697   3rd Qu.:0.06003  
##  Max.   : 1.0000   Max.   :0.25581   Max.   :0.14706   Max.   :0.15385  
##  senti_diffs_per_ref
##  Min.   :-0.11538   
##  1st Qu.: 0.00000   
##  Median : 0.03367   
##  Mean   : 0.03033   
##  3rd Qu.: 0.06250   
##  Max.   : 0.12500
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-0.3333   Min.   :0.03030   Min.   :0.02778   Min.   :0.00000  
##  1st Qu.: 0.0000   1st Qu.:0.06970   1st Qu.:0.03571   1st Qu.:0.00000  
##  Median : 0.3333   Median :0.09175   Median :0.06720   Median :0.03030  
##  Mean   : 0.4296   Mean   :0.10619   Mean   :0.07334   Mean   :0.03285  
##  3rd Qu.: 1.0000   3rd Qu.:0.11458   3rd Qu.:0.10383   3rd Qu.:0.03721  
##  Max.   : 1.0000   Max.   :0.25581   Max.   :0.14706   Max.   :0.11628  
##  senti_diffs_per_ref
##  Min.   :-0.03571   
##  1st Qu.: 0.00000   
##  Median : 0.03367   
##  Mean   : 0.04049   
##  3rd Qu.: 0.06421   
##  Max.   : 0.12500
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.0000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.:-0.1071   1st Qu.:0.06838   1st Qu.:0.03739   1st Qu.:0.00000  
##  Median : 0.2500   Median :0.09688   Median :0.06066   Median :0.03348  
##  Mean   : 0.2588   Mean   :0.10553   Mean   :0.06212   Mean   :0.04341  
##  3rd Qu.: 0.9000   3rd Qu.:0.14295   3rd Qu.:0.09115   3rd Qu.:0.06563  
##  Max.   : 1.0000   Max.   :0.21053   Max.   :0.14286   Max.   :0.15385  
##  senti_diffs_per_ref
##  Min.   :-0.11538   
##  1st Qu.:-0.01596   
##  Median : 0.01852   
##  Mean   : 0.01872   
##  3rd Qu.: 0.06250   
##  Max.   : 0.10714
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :0.00000   Min.   :0.06452   Min.   :0.03226   Min.   :0.03030  
##  1st Qu.:0.08333   1st Qu.:0.07111   1st Qu.:0.03935   1st Qu.:0.03079  
##  Median :0.16667   Median :0.07771   Median :0.04643   Median :0.03128  
##  Mean   :0.16667   Mean   :0.07771   Mean   :0.04643   Mean   :0.03128  
##  3rd Qu.:0.25000   3rd Qu.:0.08431   3rd Qu.:0.05352   3rd Qu.:0.03177  
##  Max.   :0.33333   Max.   :0.09091   Max.   :0.06061   Max.   :0.03226  
##  senti_diffs_per_ref
##  Min.   :0.000000   
##  1st Qu.:0.007576   
##  Median :0.015152   
##  Mean   :0.015152   
##  3rd Qu.:0.022727   
##  Max.   :0.030303
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.0000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.: 0.0000   1st Qu.:0.07186   1st Qu.:0.03792   1st Qu.:0.00000  
##  Median : 0.4167   Median :0.09589   Median :0.06850   Median :0.03078  
##  Mean   : 0.3653   Mean   :0.11065   Mean   :0.07222   Mean   :0.03843  
##  3rd Qu.: 1.0000   3rd Qu.:0.14295   3rd Qu.:0.09951   3rd Qu.:0.06003  
##  Max.   : 1.0000   Max.   :0.25581   Max.   :0.14706   Max.   :0.15385  
##  senti_diffs_per_ref
##  Min.   :-0.11538   
##  1st Qu.: 0.00000   
##  Median : 0.04058   
##  Mean   : 0.03378   
##  3rd Qu.: 0.07050   
##  Max.   : 0.12500
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-0.3333   Min.   :0.03704   Min.   :0.03571   Min.   :0.00000  
##  1st Qu.: 0.0000   1st Qu.:0.05456   1st Qu.:0.03604   1st Qu.:0.01786  
##  Median : 0.3333   Median :0.07209   Median :0.03638   Median :0.03571  
##  Mean   : 0.3333   Mean   :0.07209   Mean   :0.03638   Mean   :0.03571  
##  3rd Qu.: 0.6667   3rd Qu.:0.08962   3rd Qu.:0.03671   3rd Qu.:0.05357  
##  Max.   : 1.0000   Max.   :0.10714   Max.   :0.03704   Max.   :0.07143  
##  senti_diffs_per_ref 
##  Min.   :-0.0357143  
##  1st Qu.:-0.0175265  
##  Median : 0.0006614  
##  Mean   : 0.0006614  
##  3rd Qu.: 0.0188492  
##  Max.   : 0.0370370

## [1] "Using direct authentication"
## [1] 1
## [1] "Rate limited .... blocking for a minute and retrying up to 119 times ..."
##     polarity      subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.00   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.: 0.00   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median : 0.00   Median :0.06066   Median :0.00000   Median :0.00000  
##  Mean   : 0.01   Mean   :0.07348   Mean   :0.03633   Mean   :0.03715  
##  3rd Qu.: 0.00   3rd Qu.:0.12500   3rd Qu.:0.07280   3rd Qu.:0.07280  
##  Max.   : 1.00   Max.   :0.33333   Max.   :0.16667   Max.   :0.21429  
##  senti_diffs_per_ref 
##  Min.   :-0.1428571  
##  1st Qu.: 0.0000000  
##  Median : 0.0000000  
##  Mean   :-0.0008273  
##  3rd Qu.: 0.0000000  
##  Max.   : 0.1538461

By comparing the top two Democratic and Republican candidates, I predict that Doanld Trump will win the election because he has the second highest network density, the most mentions on twitter around Washington, realtively equal positive and neutral remarks composing tweets he is mentioned in, and positive mean polarity and mean sentiment.

## [1] "Using direct authentication"
## [1] 1
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref
##  Min.   :-1.0000   Min.   :0.00000   Min.   :0.00000   Min.   :0.0000  
##  1st Qu.: 0.0000   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.0000  
##  Median : 0.0000   Median :0.07143   Median :0.00000   Median :0.0000  
##  Mean   : 0.1144   Mean   :0.07288   Mean   :0.04388   Mean   :0.0290  
##  3rd Qu.: 1.0000   3rd Qu.:0.12500   3rd Qu.:0.07692   3rd Qu.:0.0625  
##  Max.   : 1.0000   Max.   :0.46154   Max.   :0.40000   Max.   :0.2500  
##  senti_diffs_per_ref
##  Min.   :-0.25000   
##  1st Qu.: 0.00000   
##  Median : 0.00000   
##  Mean   : 0.01489   
##  3rd Qu.: 0.06667   
##  Max.   : 0.40000
##     polarity        subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.0000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.: 0.0000   1st Qu.:0.05000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median : 0.3333   Median :0.08333   Median :0.06458   Median :0.00000  
##  Mean   : 0.1801   Mean   :0.10513   Mean   :0.06938   Mean   :0.03575  
##  3rd Qu.: 1.0000   3rd Qu.:0.20000   3rd Qu.:0.13333   3rd Qu.:0.06667  
##  Max.   : 1.0000   Max.   :0.55556   Max.   :0.55556   Max.   :0.20000  
##  senti_diffs_per_ref
##  Min.   :-0.20000   
##  1st Qu.: 0.00000   
##  Median : 0.05556   
##  Mean   : 0.03362   
##  3rd Qu.: 0.06667   
##  Max.   : 0.55556
##     polarity         subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.00000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.:-0.33333   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median : 0.00000   Median :0.07692   Median :0.00000   Median :0.00000  
##  Mean   : 0.02102   Mean   :0.09039   Mean   :0.04466   Mean   :0.04573  
##  3rd Qu.: 0.60000   3rd Qu.:0.13333   3rd Qu.:0.07692   3rd Qu.:0.07692  
##  Max.   : 1.00000   Max.   :0.75000   Max.   :0.50000   Max.   :0.40000  
##  senti_diffs_per_ref
##  Min.   :-0.400000  
##  1st Qu.:-0.052632  
##  Median : 0.000000  
##  Mean   :-0.001066  
##  3rd Qu.: 0.066667  
##  Max.   : 0.400000
##     polarity         subjectivity     pos_refs_per_ref  neg_refs_per_ref 
##  Min.   :-1.00000   Min.   :0.00000   Min.   :0.00000   Min.   :0.00000  
##  1st Qu.: 0.00000   1st Qu.:0.00000   1st Qu.:0.00000   1st Qu.:0.00000  
##  Median : 0.00000   Median :0.08333   Median :0.00000   Median :0.00000  
##  Mean   : 0.03962   Mean   :0.08621   Mean   :0.04855   Mean   :0.03766  
##  3rd Qu.: 0.50000   3rd Qu.:0.12500   3rd Qu.:0.07692   3rd Qu.:0.07692  
##  Max.   : 1.00000   Max.   :0.36364   Max.   :0.28571   Max.   :0.25000  
##  senti_diffs_per_ref
##  Min.   :-0.25000   
##  1st Qu.: 0.00000   
##  Median : 0.00000   
##  Mean   : 0.01089   
##  3rd Qu.: 0.06250   
##  Max.   : 0.28571
polarityMeans = c(-0.08503, 0.337, 0.03197, 0.2528)
barplot(polarityMeans, main="Comparing Mean Polarities of Top Presidential Candidates", names.arg=c("Hillary Clinton", "Bernie Sanders", "Donald Trump", "Ben Carson"))

Bernie Sanders appears to have the most positive remarks made about him, while most remarks about Hillary Clinton seem to lean towards the negative side of things. Ben Carson was also the subject of mostly positive remarks, while thoughts on Donald Trump seem to almost be neutral.

sentimentMeans = c(-0.009639, 0.02218, 0.007444, 0.03925)
barplot(sentimentMeans, main="Comparing Mean Sentiments Towards Top Presidential Candidates", names.arg=c("Hillary Clinton", "Bernie Sanders", "Donald Trump", "Ben Carson"))

In this comparison, Ben Carson had the most positive remarks in relation to negative ones. On the other hand, negative remarks made about Hillary Clinton seem to outnumber the positive ones.

Words Most Commonly Associated with Hillary Clinton

comparison.cloud(ctdm, colors = brewer.pal(3, "Dark2"), scale = c(3,.5),random.order = FALSE)

Hillary’s wordcloud seems to be equal parts positive, negative, and neutral. Just like in Bernie’s below, negative remarks focus around “raise,” while her positive remarks focus around her “strategy.”

Words Most Commonly Associated with Bernie Sanders

comparison.cloud(stdm, colors = brewer.pal(3, "Dark2"), scale = c(3,.5),random.order = FALSE)

In Sanders’ wordcloud, the amount of negative and neutral words seems to be about equal. Remarks focused on topics surrounding the words “raise,” “untold,” and “1987.”

Words Most Commonly Associated with Donald Trump

comparison.cloud(ttdm, colors = brewer.pal(3, "Dark2"), scale = c(3,.5),random.order = FALSE)

As you can see, “hate” is the most commonly used negative word associated with Trump and his campaign. However, it is used significantly less than other positive and neutral words such as “military” and “like.”

Words Most Commonly Associated with Ben Carson

comparison.cloud(btdm, colors = brewer.pal(3, "Dark2"), scale = c(3,.5),random.order = FALSE)

Carson’s wordcloud had the most reused words out of all his competitors. Positive remarks surround topics like “refugees” and “terrorists.” Neutral and negative remarks take a broader view and involve frequently used words including “wellness,” “poll,” and “meek.”

Hillary Clinton’s Support Around Washington, D.C.

qmplot(longitude, latitude, data = cgeoDF_noNA, colour = I('red'),source="google")

Bernie Sanders’ Support Around Washington, D.C.

qmplot(longitude, latitude, data = sgeoDF_noNA, colour = I('red'),source="google")

Donald Trump’s Support Around Washington, D.C.

qmplot(longitude, latitude, data = tgeoDF_noNA, colour = I('red'),source="google")

Ben Carson’s Support Around Washington, D.C.

qmplot(longitude, latitude, data = bgeoDF_noNA, colour = I('red'),source="google")

When looking over all the candidates’geographical support maps, we see that Trump was tweeted about the most around the D.C. area and Sanders was tweeted about the least. Mentions of Clinton seem to focus more on the inner cities of D.C. and Baltimore as opposed to her competitors mentions, whose also include the outlying suburbs.

## [1] "Using direct authentication"
## [1] 1

The Twitter Network of Hillary Clinton

plot(MyGraph,
     layout=layout.fruchterman.reingold,
     main='Twitter Network',
     vertex.color = 'green',
     vertex.label.dist=0.25,
     vertex.frame.color='blue',
     vertex.label.color='black',
     vertex.label.font=0.1,
     vertex.label.cex=0.5,
     vertex.size = 0.5,
     vertex.shape = "circle",
     edge.arrow.size = 0,
     edge.lty = 6,
     edge.curved=0.5
)

The Twitter Network of Bernie Sanders

plot(sMyGraph,
     layout=layout.fruchterman.reingold,
     main='Twitter Network',
     vertex.color = 'green',
     vertex.label.dist=0.25,
     vertex.frame.color='blue',
     vertex.label.color='black',
     vertex.label.font=0.1,
     vertex.label.cex=0.5,
     vertex.size = 0.5,
     vertex.shape = "circle",
     edge.arrow.size = 0,
     edge.lty = 6,
     edge.curved=0.5
)

The Twitter Network of Donald Trump

plot(tMyGraph,
     layout=layout.fruchterman.reingold,
     main='Twitter Network',
     vertex.color = 'green',
     vertex.label.dist=0.25,
     vertex.frame.color='blue',
     vertex.label.color='black',
     vertex.label.font=0.1,
     vertex.label.cex=0.5,
     vertex.size = 0.5,
     vertex.shape = "circle",
     edge.arrow.size = 0,
     edge.lty = 6,
     edge.curved=0.5
)

The Twitter Network of Ben Carson

plot(bMyGraph,
     layout=layout.fruchterman.reingold,
     main='Twitter Network',
     vertex.color = 'green',
     vertex.label.dist=0.25,
     vertex.frame.color='blue',
     vertex.label.color='black',
     vertex.label.font=0.1,
     vertex.label.cex=0.5,
     vertex.size = 0.5,
     vertex.shape = "circle",
     edge.arrow.size = 0,
     edge.lty = 6,
     edge.curved=0.5
)

## [1] 0
## [1] 0.009679371
## [1] 0
## [1] 0.01585624
## [1] 0
## [1] 0.008928571
## [1] 0
## [1] 0.008751903
networkDensities = c(0.01295097, 0.010181, 0.01245791, 0.008249497)
barplot(networkDensities, main="Comparing Network Densities of Top Presidential Candidates", names.arg=c("Hillary Clinton", "Bernie Sanders", "Donald Trump", "Ben Carson"))

When comparing candidates’ twitter networks and the network densities, Hillary Clinton has the most dense network of mentions about her and her campaign, with Donald Trump close behind. *Analysis may be a little off because the tweets change daily and therefore affect what words appear in the word clouds.