Libraries

remove(list = ls())

options(scipen = 99999, digits = 3, knitr.table.format = "rst", length = 120)

pacman::p_load(tidyverse, tidytext, textclean, tokenizers, markovchain)
pacman::p_load(stm, rvest, tm)
pacman::p_load(gutenbergr)
library(tm)

Website 1

url<-"https://www.cnn.com/2021/04/09/politics/white-house-supreme-court-commission/index.html"

#Reading the HTML code from the website
webpage <- read_html(url)
class(webpage)
## [1] "xml_document" "xml_node"
webpage
## {html_document}
## <html class="no-js">
## [1] <head>\n<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">\n< ...
## [2] <body class="pg pg-vertical pg-vertical--politics pg-politics pg-leaf pg- ...
text5 <- webpage %>% html_nodes("#body-text") %>%   html_text()


#Input data


df1 = data.frame(linenumber = 1:length(text5), text= text5)

head(df1)
##   linenumber
## 1          1
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           text
## 1  (CNN)A 36-member commission the White House established to study the US Supreme Court will not make final recommendations for reform, according to details released Friday, a possible letdown for liberals hoping for President Joe Biden to push for more justices on the bench.The long-awaited commission announcement developed from a pledge Biden made as a candidate last October, as liberals were calling for additional seats to be added to America's high court, to try to bring greater balance to a bench dominated 6-3 by conservatives poised to continue its right turn on abortion rights, religious liberty and voting restrictions."The Commission's purpose is to provide an analysis of the principal arguments in the contemporary public debate for and against Supreme Court reform, including an appraisal of the merits and legality of particular reform proposals," the White House announcement said, adding that commissioners would examine such options as term limits for justices; changing the size of the court; and altering its case selection, rules and practices.Last year when Biden offered the commission idea (which then included a plan for recommendations), some progressives derided the idea. The new, open-ended agenda may prove another disappointment. "This White House judicial reform commission has a historic opportunity to both explain the gravity of the threat and to help contain it. But we don't have time to spend six months studying the issue — especially without a promise of real conclusions at the end," Aaron Belkin, director of Take Back the Court said in a statement Friday. "The solution is already clear. Adding seats is the only way to restore balance to the Court, and Congress should get started right away." Read MoreBiden proposed the commission in October 2020 as he was being pressured by fellow Democrats to take a stand on court expansion, or what some critics dub as "court packing," akin to President Franklin D. Roosevelt's (failed) attempt of the 1930s. Biden offered the commission as an alternative, resisting any idea to add more seats to the Supreme Court but asserting the court system was "out of whack." The commission is led by Bob Bauer, a former White House counsel to President Barack Obama and currently New York University law professor, and Yale Law professor Cristina Rodriguez, who once served as a law clerk to former Justice Sandra Day O'Connor.The panel includes two former federal judges (Thomas Griffith of the DC Circuit appeals court and Nancy Gertner, of a Massachusetts US district court) and advocates and academics of a range of ideologies and backgrounds.Stephen Breyer worries about Supreme Court's public standing in current political era Among them are liberal advocates and prominent law professors affiliated with the left and right: NAACP legal defense fund director Sherrilyn Ifill, the Brennan Center for Justice president Michael Waldman, Harvard law professor Laurence Tribe, a liberal stalwart, and Harvard Law Professor Jack Goldsmith, formerly of the George W. Bush administration. Several commission members once worked at the Supreme Court as law clerks, including Walter Dellinger, who served Justice Hugo Black in the late 1960s and became an acting US solicitor general in the Bill Clinton administration; Columbia law professor Olatunde Johnson, who worked for Justice John Paul Stevens, and University of Virginia law professor Caleb Nelson, who clerked for Justice Clarence Thomas, both in the 1990s, and, in more recent service, University of Chicago law professor William Baude, who clerked for Chief Justice John Roberts.The commission is expected to begin holding public hearings in upcoming weeks and report back to the President in six months, after sizing up options.Many progressives chalk up the high court's imbalance to Republican Sen. Mitch McConnell's months long stalling of former President Barack Obama's candidate for the court in 2016 and then swift October 2020 appointment of former President Donald Trump's third appointee, Amy Coney Barrett for Ruth Bader Ginsburg.Those involved with the commission said they want to offer an authoritative assessment of the situation rather than a document that advocates various ideas. That would offer Biden a picture of the historical factors as well as contemporary perspectives before he made any proposal.When Biden first disclosed his commission idea, he said in a CBS interview that he wanted "recommendations as to how to reform the court system because it's getting out of whack."Biden's First 100 DaysBiden announces limited gun restrictions as pressure rises following mass shootingsAnalysis: Only time will tell just how 'big and bold' Biden's infrastructure plan is for Black AmericansBiden admin launches task force to ensure scientific decisions are free from political influence"It's not about court-packing," he said, responding to a question about the topic. "There's a number of other things that our constitutional scholars have debated. ... The last thing we need to do is turn the Supreme Court into just a political football, whoever has the most votes gets whatever they want. Presidents come and go. Supreme Court justices stay for generations."Many progressive voices have since touted proposals for expanding the number of Supreme Court seats, including the Take Back the Court and Demand Justice groups.But Justice Stephen Breyer on Tuesday warned against such expansion proposals, saying they could undermine public trust. "Those whose initial instincts may favor important structural ... changes, such as ... 'court-packing,'" he said, should "think long and hard before embodying those changes in law."Breyer is not alone on the high court in resisting the court expansion idea. It is up to Congress to set the number of seats. Nine has been the number since 1869. Before then, there was more variation, from a low of five seats to high of ten.Any change in the justices' current life tenure would likely require a constitutional amendment. However, some term-limit proponents suggest that life-tenure as set out in the Constitution could be met if a justice were not stripped of his or her appointment after, for example, 18 years, but rather limited in what cases he or she could hear.
df1$text = as.character(df1$text)

#Convert to tidy format: one row, one word
df1 = df1 %>% unnest_tokens(word, text)

#Remove stopwords
(  df1 = df1 %>% anti_join(get_stopwords()) )
## Joining, by = "word"
##     linenumber                word
## 1            1                 cnn
## 2            1                  36
## 3            1              member
## 4            1          commission
## 5            1               white
## 6            1               house
## 7            1         established
## 8            1               study
## 9            1                  us
## 10           1             supreme
## 11           1               court
## 12           1                make
## 13           1               final
## 14           1     recommendations
## 15           1              reform
## 16           1           according
## 17           1             details
## 18           1            released
## 19           1              friday
## 20           1            possible
## 21           1             letdown
## 22           1            liberals
## 23           1              hoping
## 24           1           president
## 25           1                 joe
## 26           1               biden
## 27           1                push
## 28           1            justices
## 29           1           bench.the
## 30           1                long
## 31           1             awaited
## 32           1          commission
## 33           1        announcement
## 34           1           developed
## 35           1              pledge
## 36           1               biden
## 37           1                made
## 38           1           candidate
## 39           1                last
## 40           1             october
## 41           1            liberals
## 42           1             calling
## 43           1          additional
## 44           1               seats
## 45           1               added
## 46           1           america's
## 47           1                high
## 48           1               court
## 49           1                 try
## 50           1               bring
## 51           1             greater
## 52           1             balance
## 53           1               bench
## 54           1           dominated
## 55           1                   6
## 56           1                   3
## 57           1       conservatives
## 58           1              poised
## 59           1            continue
## 60           1               right
## 61           1                turn
## 62           1            abortion
## 63           1              rights
## 64           1           religious
## 65           1             liberty
## 66           1              voting
## 67           1        restrictions
## 68           1        commission's
## 69           1             purpose
## 70           1             provide
## 71           1            analysis
## 72           1           principal
## 73           1           arguments
## 74           1        contemporary
## 75           1              public
## 76           1              debate
## 77           1             supreme
## 78           1               court
## 79           1              reform
## 80           1           including
## 81           1           appraisal
## 82           1              merits
## 83           1            legality
## 84           1          particular
## 85           1              reform
## 86           1           proposals
## 87           1               white
## 88           1               house
## 89           1        announcement
## 90           1                said
## 91           1              adding
## 92           1       commissioners
## 93           1             examine
## 94           1             options
## 95           1                term
## 96           1              limits
## 97           1            justices
## 98           1            changing
## 99           1                size
## 100          1               court
## 101          1            altering
## 102          1                case
## 103          1           selection
## 104          1               rules
## 105          1      practices.last
## 106          1                year
## 107          1               biden
## 108          1             offered
## 109          1          commission
## 110          1                idea
## 111          1            included
## 112          1                plan
## 113          1     recommendations
## 114          1        progressives
## 115          1             derided
## 116          1                idea
## 117          1                 new
## 118          1                open
## 119          1               ended
## 120          1              agenda
## 121          1                 may
## 122          1               prove
## 123          1             another
## 124          1      disappointment
## 125          1               white
## 126          1               house
## 127          1            judicial
## 128          1              reform
## 129          1          commission
## 130          1            historic
## 131          1         opportunity
## 132          1             explain
## 133          1             gravity
## 134          1              threat
## 135          1                help
## 136          1             contain
## 137          1                time
## 138          1               spend
## 139          1                 six
## 140          1              months
## 141          1            studying
## 142          1               issue
## 143          1          especially
## 144          1             without
## 145          1             promise
## 146          1                real
## 147          1         conclusions
## 148          1                 end
## 149          1               aaron
## 150          1              belkin
## 151          1            director
## 152          1                take
## 153          1                back
## 154          1               court
## 155          1                said
## 156          1           statement
## 157          1              friday
## 158          1            solution
## 159          1             already
## 160          1               clear
## 161          1              adding
## 162          1               seats
## 163          1                 way
## 164          1             restore
## 165          1             balance
## 166          1               court
## 167          1            congress
## 168          1                 get
## 169          1             started
## 170          1               right
## 171          1                away
## 172          1                read
## 173          1           morebiden
## 174          1            proposed
## 175          1          commission
## 176          1             october
## 177          1                2020
## 178          1           pressured
## 179          1              fellow
## 180          1           democrats
## 181          1                take
## 182          1               stand
## 183          1               court
## 184          1           expansion
## 185          1             critics
## 186          1                 dub
## 187          1               court
## 188          1             packing
## 189          1                akin
## 190          1           president
## 191          1            franklin
## 192          1                   d
## 193          1         roosevelt's
## 194          1              failed
## 195          1             attempt
## 196          1               1930s
## 197          1               biden
## 198          1             offered
## 199          1          commission
## 200          1         alternative
## 201          1           resisting
## 202          1                idea
## 203          1                 add
## 204          1               seats
## 205          1             supreme
## 206          1               court
## 207          1           asserting
## 208          1               court
## 209          1              system
## 210          1               whack
## 211          1          commission
## 212          1                 led
## 213          1                 bob
## 214          1               bauer
## 215          1              former
## 216          1               white
## 217          1               house
## 218          1             counsel
## 219          1           president
## 220          1              barack
## 221          1               obama
## 222          1           currently
## 223          1                 new
## 224          1                york
## 225          1          university
## 226          1                 law
## 227          1           professor
## 228          1                yale
## 229          1                 law
## 230          1           professor
## 231          1            cristina
## 232          1           rodriguez
## 233          1              served
## 234          1                 law
## 235          1               clerk
## 236          1              former
## 237          1             justice
## 238          1              sandra
## 239          1                 day
## 240          1        o'connor.the
## 241          1               panel
## 242          1            includes
## 243          1                 two
## 244          1              former
## 245          1             federal
## 246          1              judges
## 247          1              thomas
## 248          1            griffith
## 249          1                  dc
## 250          1             circuit
## 251          1             appeals
## 252          1               court
## 253          1               nancy
## 254          1             gertner
## 255          1       massachusetts
## 256          1                  us
## 257          1            district
## 258          1               court
## 259          1           advocates
## 260          1           academics
## 261          1               range
## 262          1          ideologies
## 263          1 backgrounds.stephen
## 264          1              breyer
## 265          1             worries
## 266          1             supreme
## 267          1             court's
## 268          1              public
## 269          1            standing
## 270          1             current
## 271          1           political
## 272          1                 era
## 273          1               among
## 274          1             liberal
## 275          1           advocates
## 276          1           prominent
## 277          1                 law
## 278          1          professors
## 279          1          affiliated
## 280          1                left
## 281          1               right
## 282          1               naacp
## 283          1               legal
## 284          1             defense
## 285          1                fund
## 286          1            director
## 287          1           sherrilyn
## 288          1               ifill
## 289          1             brennan
## 290          1              center
## 291          1             justice
## 292          1           president
## 293          1             michael
## 294          1             waldman
## 295          1             harvard
## 296          1                 law
## 297          1           professor
## 298          1            laurence
## 299          1               tribe
## 300          1             liberal
## 301          1            stalwart
## 302          1             harvard
## 303          1                 law
## 304          1           professor
## 305          1                jack
## 306          1           goldsmith
## 307          1            formerly
## 308          1              george
## 309          1                   w
## 310          1                bush
## 311          1      administration
## 312          1             several
## 313          1          commission
## 314          1             members
## 315          1              worked
## 316          1             supreme
## 317          1               court
## 318          1                 law
## 319          1              clerks
## 320          1           including
## 321          1              walter
## 322          1           dellinger
## 323          1              served
## 324          1             justice
## 325          1                hugo
## 326          1               black
## 327          1                late
## 328          1               1960s
## 329          1              became
## 330          1              acting
## 331          1                  us
## 332          1           solicitor
## 333          1             general
## 334          1                bill
## 335          1             clinton
## 336          1      administration
## 337          1            columbia
## 338          1                 law
## 339          1           professor
## 340          1            olatunde
## 341          1             johnson
## 342          1              worked
## 343          1             justice
## 344          1                john
## 345          1                paul
## 346          1             stevens
## 347          1          university
## 348          1            virginia
## 349          1                 law
## 350          1           professor
## 351          1               caleb
## 352          1              nelson
## 353          1             clerked
## 354          1             justice
## 355          1            clarence
## 356          1              thomas
## 357          1               1990s
## 358          1              recent
## 359          1             service
## 360          1          university
## 361          1             chicago
## 362          1                 law
## 363          1           professor
## 364          1             william
## 365          1               baude
## 366          1             clerked
## 367          1               chief
## 368          1             justice
## 369          1                john
## 370          1         roberts.the
## 371          1          commission
## 372          1            expected
## 373          1               begin
## 374          1             holding
## 375          1              public
## 376          1            hearings
## 377          1            upcoming
## 378          1               weeks
## 379          1              report
## 380          1                back
## 381          1           president
## 382          1                 six
## 383          1              months
## 384          1              sizing
## 385          1        options.many
## 386          1        progressives
## 387          1               chalk
## 388          1                high
## 389          1             court's
## 390          1           imbalance
## 391          1          republican
## 392          1                 sen
## 393          1               mitch
## 394          1         mcconnell's
## 395          1              months
## 396          1                long
## 397          1            stalling
## 398          1              former
## 399          1           president
## 400          1              barack
## 401          1             obama's
## 402          1           candidate
## 403          1               court
## 404          1                2016
## 405          1               swift
## 406          1             october
## 407          1                2020
## 408          1         appointment
## 409          1              former
## 410          1           president
## 411          1              donald
## 412          1             trump's
## 413          1               third
## 414          1           appointee
## 415          1                 amy
## 416          1               coney
## 417          1             barrett
## 418          1                ruth
## 419          1               bader
## 420          1      ginsburg.those
## 421          1            involved
## 422          1          commission
## 423          1                said
## 424          1                want
## 425          1               offer
## 426          1       authoritative
## 427          1          assessment
## 428          1           situation
## 429          1              rather
## 430          1            document
## 431          1           advocates
## 432          1             various
## 433          1               ideas
## 434          1               offer
## 435          1               biden
## 436          1             picture
## 437          1          historical
## 438          1             factors
## 439          1                well
## 440          1        contemporary
## 441          1        perspectives
## 442          1                made
## 443          1       proposal.when
## 444          1               biden
## 445          1               first
## 446          1           disclosed
## 447          1          commission
## 448          1                idea
## 449          1                said
## 450          1                 cbs
## 451          1           interview
## 452          1              wanted
## 453          1     recommendations
## 454          1              reform
## 455          1               court
## 456          1              system
## 457          1             getting
## 458          1               whack
## 459          1             biden's
## 460          1               first
## 461          1                 100
## 462          1           daysbiden
## 463          1           announces
## 464          1             limited
## 465          1                 gun
## 466          1        restrictions
## 467          1            pressure
## 468          1               rises
## 469          1           following
## 470          1                mass
## 471          1   shootingsanalysis
## 472          1                time
## 473          1                tell
## 474          1                just
## 475          1                 big
## 476          1                bold
## 477          1             biden's
## 478          1      infrastructure
## 479          1                plan
## 480          1               black
## 481          1      americansbiden
## 482          1               admin
## 483          1            launches
## 484          1                task
## 485          1               force
## 486          1              ensure
## 487          1          scientific
## 488          1           decisions
## 489          1                free
## 490          1           political
## 491          1           influence
## 492          1               court
## 493          1             packing
## 494          1                said
## 495          1          responding
## 496          1            question
## 497          1               topic
## 498          1              number
## 499          1              things
## 500          1      constitutional
## 501          1            scholars
## 502          1             debated
## 503          1                last
## 504          1               thing
## 505          1                need
## 506          1                turn
## 507          1             supreme
## 508          1               court
## 509          1                just
## 510          1           political
## 511          1            football
## 512          1             whoever
## 513          1               votes
## 514          1                gets
## 515          1            whatever
## 516          1                want
## 517          1          presidents
## 518          1                come
## 519          1                  go
## 520          1             supreme
## 521          1               court
## 522          1            justices
## 523          1                stay
## 524          1         generations
## 525          1                many
## 526          1         progressive
## 527          1              voices
## 528          1               since
## 529          1              touted
## 530          1           proposals
## 531          1           expanding
## 532          1              number
## 533          1             supreme
## 534          1               court
## 535          1               seats
## 536          1           including
## 537          1                take
## 538          1                back
## 539          1               court
## 540          1              demand
## 541          1             justice
## 542          1          groups.but
## 543          1             justice
## 544          1             stephen
## 545          1              breyer
## 546          1             tuesday
## 547          1              warned
## 548          1           expansion
## 549          1           proposals
## 550          1              saying
## 551          1           undermine
## 552          1              public
## 553          1               trust
## 554          1               whose
## 555          1             initial
## 556          1           instincts
## 557          1                 may
## 558          1               favor
## 559          1           important
## 560          1          structural
## 561          1             changes
## 562          1               court
## 563          1             packing
## 564          1                said
## 565          1               think
## 566          1                long
## 567          1                hard
## 568          1           embodying
## 569          1             changes
## 570          1                 law
## 571          1              breyer
## 572          1               alone
## 573          1                high
## 574          1               court
## 575          1           resisting
## 576          1               court
## 577          1           expansion
## 578          1                idea
## 579          1            congress
## 580          1                 set
## 581          1              number
## 582          1               seats
## 583          1                nine
## 584          1              number
## 585          1               since
## 586          1                1869
## 587          1           variation
## 588          1                 low
## 589          1                five
## 590          1               seats
## 591          1                high
## 592          1             ten.any
## 593          1              change
## 594          1            justices
## 595          1             current
## 596          1                life
## 597          1              tenure
## 598          1              likely
## 599          1             require
## 600          1      constitutional
## 601          1           amendment
## 602          1             however
## 603          1                term
## 604          1               limit
## 605          1          proponents
## 606          1             suggest
## 607          1                life
## 608          1              tenure
## 609          1                 set
## 610          1        constitution
## 611          1                 met
## 612          1             justice
## 613          1            stripped
## 614          1         appointment
## 615          1             example
## 616          1                  18
## 617          1               years
## 618          1              rather
## 619          1             limited
## 620          1               cases
## 621          1                hear
#Display top 10 words
df1 %>% 
  count(word, sort = TRUE) %>% 
  top_n(20) %>%
  ggplot(aes(fct_reorder(word,n), n, fill = as.factor(n)))+ 
  geom_col() + 
  coord_flip() +
  theme(legend.position = "none")
## Selecting by n

#########

nrow(df1)
## [1] 621
round(nrow(df1)/100)
## [1] 6
section = rep(c(1,2, 3, 4,5, 6, 7,8, 9, 10,11), each = 10, 
              times = round(nrow(df1)/100))
length(section)
## [1] 660
section = as.data.frame(section)
section2 = slice(section, 1:nrow(df1))

df1 = df1 %>% arrange(linenumber) %>%
  cbind.data.frame(section2)

#==============


df1 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  spread(sentiment, n, fill=0) %>% 
  mutate(sent=positive-negative)  %>%
  ggplot(aes(x = section, y = sent, fill = as.factor(sent))) + 
  geom_col()+
  theme(legend.position = "none")

#how does emotion % sentiment change during the manifesto
df1 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  ggplot(aes(x = section, y = n, fill = as.factor(sentiment))) + 
  geom_col(position = "stack")

Website 2

url2<-"https://www.cnn.com/2021/04/09/politics/joe-manchin-joe-biden-guns-filibuster-voting-rights/index.html"
webpage2 <- read_html(url2)
class(webpage2)
## [1] "xml_document" "xml_node"
text6 <-webpage2 %>% html_nodes("#body-text") %>%   html_text()

#Input data

df2 = data.frame(linenumber = 1:length(text6), text= text6)

head(df2)
##   linenumber
## 1          1
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       text
## 1  (CNN)Joe Manchin says it's no fun being the most powerful man in Washington.The West Virginia Democrat, who sits at the fulcrum of the Senate balance of power, suggested the US Capitol insurrection was a warning for him -- of the divisions tearing America apart and the dangers wrought by politicians who abuse their power."Something told me, 'Wait a minute. Pause. Hit the pause button.' Something's wrong. You can't have this many people split to where they want to go to war with each other," Manchin told CNN's Lauren Fox in an interview on Thursday.It might surprise some of his fellow Democrats, however, to learn that Manchin now appears to believe that the appropriate response to those horrific events is to prevent either side in the Senate from exerting their will over the other. If that means thwarting a bid to overturn supermajority filibuster rules in the Senate that could buckle Democratic dreams of a radical and historic Joe Biden presidency, that appears to be a risk he's willing to take. "I've watched people that had power and abused it," Manchin said. "I've watched people that sought power and destroyed themselves. And I've watched people that had a moment of time to make a difference and change things, and used it -- I would like to be that third."Read MoreBiden's First 100 DaysBiden's planned pick for ATF director a fierce advocate for gun controlWhite House defends hiking taxes on corporations to pay for infrastructure, signals openness to compromiseBiden administration reviewing 5,600 additional files for evidence of family separations under TrumpManchin makes his arguments as a Democrat from a conservative state that Donald Trump overwhelmingly carried twice. He's not just in a delicate personal position. He's the personification of a divided country, and -- as the crucial swing vote in a 50-50 Senate -- he's enormously consequential for Biden's agenda. After laying out a series of limited gun restrictions earlier Thursday, the President pleaded with Congress to pass gun control legislation following a spate of mass shootings. But Manchin wouldn't commit to a House-passed bill that would tighten background checks for firearms purchases. He also said he wanted to speak to Democratic Sens. Jon Ossoff and Raphael Warnock about federal voting rights legislation, following the passage of a sweeping election law in their home state of Georgia that discriminates against minority voters. He suggested he'd get Republicans to sit down with Democrats on an issue on which the two sides could hardly be farther apart.The power of Joe Manchin Asked whether he was enjoying his moment in the spotlight, Manchin said, "No." But the pressure is nothing yet, since he -- and a small group of other more moderate Democratic senators -- could end up as the roadblock to ambitious Democratic plans for sweeping reforms of the electoral system partly designed to counter those Republican voter suppression tactics. The coal-state senator could block Biden's hopes to take the United States towards zero fossil fuel emissions. And if his reluctance to embrace the filibuster-dodging tactic of reconciliation stands, he could kill Biden's $2 trillion infrastructure plan that represents the second leg of the President's ambitious plan to remake the American economy.It is not clear at this point whether Manchin's positions are absolute -- or could be modified by events if, for instance, the Republicans with whom he wants Biden to compromise stonewall the President.Joe Manchin just crushed liberals' dream for Joe Biden's first termManchin also made clear that he's been in frequent and apparently friendly contact with a President who knows something about giving those whose votes he needs the space and respect to reach their final positions. "We've had a good friendship and relationship for a long time. We understand each other," Manchin told CNN. A turbulent and fateful political period is about to ensue during a months-long effort by the President to build public support for his infrastructure plan. How it turns out could shift the ground on which Manchin is assessing his own position. It's unknown whether Manchin's current stance will be sustainable should Biden's future bills prove as popular as the $1.9 trillion Covid-19 relief bill -- for which he voted. Disproportionate largesse sent West Virginia's way in the infrastructure package might offer Manchin a route to approving the legislation. It is too early to rule out the idea that he is maximizing the power that fate has handed him to advantage his constituents.It would also be quite a statement if he were to go down as the Democratic senator who effectively helped Republicans neuter a presidency born in a crisis that led to a sweet spot for fundamental political reform."I'm representing West Virginia to the best of my ability. And I'm trying to speak for my state," Manchin said in the interview.Trust in RepublicansAt times, it seems that Manchin is the most naïve man in Washington. He often appears to be operating in an idealized version of the capital that no longer exists. He is, after all, trying to force cooperation between Biden and Republicans who have clearly signaled -- even in the middle of a pandemic that has killed more than half a million Americans -- that they want nothing to do with anything that could give the President a win. And there appears to be no common ground between Democrats who believe Republicans are already acting to steal the next election with a flurry of state bills that narrow access to voting and Republicans who believe Democratic voter reform efforts in Washington amount to an unconstitutional power grab.But that's not how Manchin sees it, as he explained when justifying his refusal to kill the filibuster. Unless he recants, it would be impossible for federal voting rights legislation to pass over Republican opposition in the Senate.Manchin and the grim reality of Washington's minority rule"I think we can find a pathway forward. I really do. I'm going to be sitting down with both sides in understanding where everybody is coming from," he said. "We should have an open, fair and safe election. If we have to put guard rails on we can put guard rails on so people can't take advantage of people. And I believe there are Republicans that feel exactly like I feel."Again, many Democrats -- keen to take advantage of what could be a fleeting moment of power in Washington with their thin majorities in the House and Senate -- will be infuriated with Manchin's position.Yet he is acting perfectly within his rights. And Democrats in effect handed him that power with what many of them regard as a disappointing performance in congressional elections that fell well short of the standard Biden set when he beat Trump. And if it wasn't for a Democrat from West Virginia, who won reelection in 2018 in a Trump bastion, they'd be in the minority in the Senate.Still, Democrats may find the logic of Manchin's arguments about the Capitol insurrection hard to understand."January 6 changed me ... I never thought in my life, I never read in the history books to where our form of government had been attacked, at our seat of government, which is Washington, DC, at our Capitol, by our own people," Manchin told CNN. But his comment that people went "to war with each other" in January is difficult to parse, since the mob that attacked the Capitol was inspired by Trump's multiple lies about election fraud. There was only one side doing the attacking. As the country moves farther from January 6, Manchin's hot seat is only going to get more uncomfortable -- but for now at least, he's got no intention of vacating it.
df2$text = as.character(df2$text)

#Convert to tidy format: one row, one word
df2 = df2 %>% unnest_tokens(word, text)

#Remove stopwords
(  df2 = df2 %>% anti_join(get_stopwords()) )
## Joining, by = "word"
##     linenumber             word
## 1            1              cnn
## 2            1              joe
## 3            1          manchin
## 4            1             says
## 5            1              fun
## 6            1         powerful
## 7            1              man
## 8            1   washington.the
## 9            1             west
## 10           1         virginia
## 11           1         democrat
## 12           1             sits
## 13           1          fulcrum
## 14           1           senate
## 15           1          balance
## 16           1            power
## 17           1        suggested
## 18           1               us
## 19           1          capitol
## 20           1     insurrection
## 21           1          warning
## 22           1        divisions
## 23           1          tearing
## 24           1          america
## 25           1            apart
## 26           1          dangers
## 27           1          wrought
## 28           1      politicians
## 29           1            abuse
## 30           1            power
## 31           1        something
## 32           1             told
## 33           1             wait
## 34           1           minute
## 35           1            pause
## 36           1              hit
## 37           1            pause
## 38           1           button
## 39           1      something's
## 40           1            wrong
## 41           1             many
## 42           1           people
## 43           1            split
## 44           1             want
## 45           1               go
## 46           1              war
## 47           1          manchin
## 48           1             told
## 49           1            cnn's
## 50           1           lauren
## 51           1              fox
## 52           1        interview
## 53           1      thursday.it
## 54           1            might
## 55           1         surprise
## 56           1           fellow
## 57           1        democrats
## 58           1          however
## 59           1            learn
## 60           1          manchin
## 61           1              now
## 62           1          appears
## 63           1          believe
## 64           1      appropriate
## 65           1         response
## 66           1         horrific
## 67           1           events
## 68           1          prevent
## 69           1           either
## 70           1             side
## 71           1           senate
## 72           1         exerting
## 73           1            means
## 74           1        thwarting
## 75           1              bid
## 76           1         overturn
## 77           1    supermajority
## 78           1       filibuster
## 79           1            rules
## 80           1           senate
## 81           1           buckle
## 82           1       democratic
## 83           1           dreams
## 84           1          radical
## 85           1         historic
## 86           1              joe
## 87           1            biden
## 88           1       presidency
## 89           1          appears
## 90           1             risk
## 91           1          willing
## 92           1             take
## 93           1          watched
## 94           1           people
## 95           1            power
## 96           1           abused
## 97           1          manchin
## 98           1             said
## 99           1          watched
## 100          1           people
## 101          1           sought
## 102          1            power
## 103          1        destroyed
## 104          1          watched
## 105          1           people
## 106          1           moment
## 107          1             time
## 108          1             make
## 109          1       difference
## 110          1           change
## 111          1           things
## 112          1             used
## 113          1             like
## 114          1            third
## 115          1             read
## 116          1      morebiden's
## 117          1            first
## 118          1              100
## 119          1      daysbiden's
## 120          1          planned
## 121          1             pick
## 122          1              atf
## 123          1         director
## 124          1           fierce
## 125          1         advocate
## 126          1              gun
## 127          1     controlwhite
## 128          1            house
## 129          1          defends
## 130          1           hiking
## 131          1            taxes
## 132          1     corporations
## 133          1              pay
## 134          1   infrastructure
## 135          1          signals
## 136          1         openness
## 137          1  compromisebiden
## 138          1   administration
## 139          1        reviewing
## 140          1            5,600
## 141          1       additional
## 142          1            files
## 143          1         evidence
## 144          1           family
## 145          1      separations
## 146          1     trumpmanchin
## 147          1            makes
## 148          1        arguments
## 149          1         democrat
## 150          1     conservative
## 151          1            state
## 152          1           donald
## 153          1            trump
## 154          1   overwhelmingly
## 155          1          carried
## 156          1            twice
## 157          1             just
## 158          1         delicate
## 159          1         personal
## 160          1         position
## 161          1  personification
## 162          1          divided
## 163          1          country
## 164          1          crucial
## 165          1            swing
## 166          1             vote
## 167          1               50
## 168          1               50
## 169          1           senate
## 170          1       enormously
## 171          1    consequential
## 172          1          biden's
## 173          1           agenda
## 174          1           laying
## 175          1           series
## 176          1          limited
## 177          1              gun
## 178          1     restrictions
## 179          1          earlier
## 180          1         thursday
## 181          1        president
## 182          1          pleaded
## 183          1         congress
## 184          1             pass
## 185          1              gun
## 186          1          control
## 187          1      legislation
## 188          1        following
## 189          1            spate
## 190          1             mass
## 191          1        shootings
## 192          1          manchin
## 193          1           commit
## 194          1            house
## 195          1           passed
## 196          1             bill
## 197          1          tighten
## 198          1       background
## 199          1           checks
## 200          1         firearms
## 201          1        purchases
## 202          1             also
## 203          1             said
## 204          1           wanted
## 205          1            speak
## 206          1       democratic
## 207          1             sens
## 208          1              jon
## 209          1           ossoff
## 210          1          raphael
## 211          1          warnock
## 212          1          federal
## 213          1           voting
## 214          1           rights
## 215          1      legislation
## 216          1        following
## 217          1          passage
## 218          1         sweeping
## 219          1         election
## 220          1              law
## 221          1             home
## 222          1            state
## 223          1          georgia
## 224          1    discriminates
## 225          1         minority
## 226          1           voters
## 227          1        suggested
## 228          1              get
## 229          1      republicans
## 230          1              sit
## 231          1        democrats
## 232          1            issue
## 233          1              two
## 234          1            sides
## 235          1           hardly
## 236          1          farther
## 237          1        apart.the
## 238          1            power
## 239          1              joe
## 240          1          manchin
## 241          1            asked
## 242          1          whether
## 243          1         enjoying
## 244          1           moment
## 245          1        spotlight
## 246          1          manchin
## 247          1             said
## 248          1         pressure
## 249          1          nothing
## 250          1              yet
## 251          1            since
## 252          1            small
## 253          1            group
## 254          1         moderate
## 255          1       democratic
## 256          1         senators
## 257          1              end
## 258          1        roadblock
## 259          1        ambitious
## 260          1       democratic
## 261          1            plans
## 262          1         sweeping
## 263          1          reforms
## 264          1        electoral
## 265          1           system
## 266          1           partly
## 267          1         designed
## 268          1          counter
## 269          1       republican
## 270          1            voter
## 271          1      suppression
## 272          1          tactics
## 273          1             coal
## 274          1            state
## 275          1          senator
## 276          1            block
## 277          1          biden's
## 278          1            hopes
## 279          1             take
## 280          1           united
## 281          1           states
## 282          1          towards
## 283          1             zero
## 284          1           fossil
## 285          1             fuel
## 286          1        emissions
## 287          1       reluctance
## 288          1          embrace
## 289          1       filibuster
## 290          1          dodging
## 291          1           tactic
## 292          1   reconciliation
## 293          1           stands
## 294          1             kill
## 295          1          biden's
## 296          1                2
## 297          1         trillion
## 298          1   infrastructure
## 299          1             plan
## 300          1       represents
## 301          1           second
## 302          1              leg
## 303          1      president's
## 304          1        ambitious
## 305          1             plan
## 306          1           remake
## 307          1         american
## 308          1       economy.it
## 309          1            clear
## 310          1            point
## 311          1          whether
## 312          1        manchin's
## 313          1        positions
## 314          1         absolute
## 315          1         modified
## 316          1           events
## 317          1         instance
## 318          1      republicans
## 319          1            wants
## 320          1            biden
## 321          1       compromise
## 322          1        stonewall
## 323          1    president.joe
## 324          1          manchin
## 325          1             just
## 326          1          crushed
## 327          1         liberals
## 328          1            dream
## 329          1              joe
## 330          1          biden's
## 331          1            first
## 332          1      termmanchin
## 333          1             also
## 334          1             made
## 335          1            clear
## 336          1         frequent
## 337          1       apparently
## 338          1         friendly
## 339          1          contact
## 340          1        president
## 341          1            knows
## 342          1        something
## 343          1           giving
## 344          1            whose
## 345          1            votes
## 346          1            needs
## 347          1            space
## 348          1          respect
## 349          1            reach
## 350          1            final
## 351          1        positions
## 352          1             good
## 353          1       friendship
## 354          1     relationship
## 355          1             long
## 356          1             time
## 357          1       understand
## 358          1          manchin
## 359          1             told
## 360          1              cnn
## 361          1        turbulent
## 362          1          fateful
## 363          1        political
## 364          1           period
## 365          1            ensue
## 366          1           months
## 367          1             long
## 368          1           effort
## 369          1        president
## 370          1            build
## 371          1           public
## 372          1          support
## 373          1   infrastructure
## 374          1             plan
## 375          1            turns
## 376          1            shift
## 377          1           ground
## 378          1          manchin
## 379          1        assessing
## 380          1         position
## 381          1          unknown
## 382          1          whether
## 383          1        manchin's
## 384          1          current
## 385          1           stance
## 386          1      sustainable
## 387          1          biden's
## 388          1           future
## 389          1            bills
## 390          1            prove
## 391          1          popular
## 392          1              1.9
## 393          1         trillion
## 394          1            covid
## 395          1               19
## 396          1           relief
## 397          1             bill
## 398          1            voted
## 399          1 disproportionate
## 400          1         largesse
## 401          1             sent
## 402          1             west
## 403          1       virginia's
## 404          1              way
## 405          1   infrastructure
## 406          1          package
## 407          1            might
## 408          1            offer
## 409          1          manchin
## 410          1            route
## 411          1        approving
## 412          1      legislation
## 413          1            early
## 414          1             rule
## 415          1             idea
## 416          1       maximizing
## 417          1            power
## 418          1             fate
## 419          1           handed
## 420          1        advantage
## 421          1  constituents.it
## 422          1             also
## 423          1            quite
## 424          1        statement
## 425          1               go
## 426          1       democratic
## 427          1          senator
## 428          1      effectively
## 429          1           helped
## 430          1      republicans
## 431          1           neuter
## 432          1       presidency
## 433          1             born
## 434          1           crisis
## 435          1              led
## 436          1            sweet
## 437          1             spot
## 438          1      fundamental
## 439          1        political
## 440          1           reform
## 441          1     representing
## 442          1             west
## 443          1         virginia
## 444          1             best
## 445          1          ability
## 446          1           trying
## 447          1            speak
## 448          1            state
## 449          1          manchin
## 450          1             said
## 451          1  interview.trust
## 452          1    republicansat
## 453          1            times
## 454          1            seems
## 455          1          manchin
## 456          1            naïve
## 457          1              man
## 458          1       washington
## 459          1            often
## 460          1          appears
## 461          1        operating
## 462          1        idealized
## 463          1          version
## 464          1          capital
## 465          1           longer
## 466          1           exists
## 467          1           trying
## 468          1            force
## 469          1      cooperation
## 470          1            biden
## 471          1      republicans
## 472          1          clearly
## 473          1         signaled
## 474          1             even
## 475          1           middle
## 476          1         pandemic
## 477          1           killed
## 478          1             half
## 479          1          million
## 480          1        americans
## 481          1             want
## 482          1          nothing
## 483          1         anything
## 484          1             give
## 485          1        president
## 486          1              win
## 487          1          appears
## 488          1           common
## 489          1           ground
## 490          1        democrats
## 491          1          believe
## 492          1      republicans
## 493          1          already
## 494          1           acting
## 495          1            steal
## 496          1             next
## 497          1         election
## 498          1           flurry
## 499          1            state
## 500          1            bills
## 501          1           narrow
## 502          1           access
## 503          1           voting
## 504          1      republicans
## 505          1          believe
## 506          1       democratic
## 507          1            voter
## 508          1           reform
## 509          1          efforts
## 510          1       washington
## 511          1           amount
## 512          1 unconstitutional
## 513          1            power
## 514          1         grab.but
## 515          1          manchin
## 516          1             sees
## 517          1        explained
## 518          1       justifying
## 519          1          refusal
## 520          1             kill
## 521          1       filibuster
## 522          1           unless
## 523          1          recants
## 524          1       impossible
## 525          1          federal
## 526          1           voting
## 527          1           rights
## 528          1      legislation
## 529          1             pass
## 530          1       republican
## 531          1       opposition
## 532          1   senate.manchin
## 533          1             grim
## 534          1          reality
## 535          1     washington's
## 536          1         minority
## 537          1             rule
## 538          1            think
## 539          1              can
## 540          1             find
## 541          1          pathway
## 542          1          forward
## 543          1           really
## 544          1            going
## 545          1          sitting
## 546          1            sides
## 547          1    understanding
## 548          1        everybody
## 549          1           coming
## 550          1             said
## 551          1             open
## 552          1             fair
## 553          1             safe
## 554          1         election
## 555          1              put
## 556          1            guard
## 557          1            rails
## 558          1              can
## 559          1              put
## 560          1            guard
## 561          1            rails
## 562          1           people
## 563          1             take
## 564          1        advantage
## 565          1           people
## 566          1          believe
## 567          1      republicans
## 568          1             feel
## 569          1          exactly
## 570          1             like
## 571          1             feel
## 572          1             many
## 573          1        democrats
## 574          1             keen
## 575          1             take
## 576          1        advantage
## 577          1         fleeting
## 578          1           moment
## 579          1            power
## 580          1       washington
## 581          1             thin
## 582          1       majorities
## 583          1            house
## 584          1           senate
## 585          1       infuriated
## 586          1        manchin's
## 587          1     position.yet
## 588          1           acting
## 589          1        perfectly
## 590          1           within
## 591          1           rights
## 592          1        democrats
## 593          1           effect
## 594          1           handed
## 595          1            power
## 596          1             many
## 597          1           regard
## 598          1    disappointing
## 599          1      performance
## 600          1    congressional
## 601          1        elections
## 602          1             fell
## 603          1             well
## 604          1            short
## 605          1         standard
## 606          1            biden
## 607          1              set
## 608          1             beat
## 609          1            trump
## 610          1         democrat
## 611          1             west
## 612          1         virginia
## 613          1              won
## 614          1       reelection
## 615          1             2018
## 616          1            trump
## 617          1          bastion
## 618          1         minority
## 619          1     senate.still
## 620          1        democrats
## 621          1              may
## 622          1             find
## 623          1            logic
## 624          1        manchin's
## 625          1        arguments
## 626          1          capitol
## 627          1     insurrection
## 628          1             hard
## 629          1       understand
## 630          1          january
## 631          1                6
## 632          1          changed
## 633          1            never
## 634          1          thought
## 635          1             life
## 636          1            never
## 637          1             read
## 638          1          history
## 639          1            books
## 640          1             form
## 641          1       government
## 642          1         attacked
## 643          1             seat
## 644          1       government
## 645          1       washington
## 646          1               dc
## 647          1          capitol
## 648          1           people
## 649          1          manchin
## 650          1             told
## 651          1              cnn
## 652          1          comment
## 653          1           people
## 654          1             went
## 655          1              war
## 656          1          january
## 657          1        difficult
## 658          1            parse
## 659          1            since
## 660          1              mob
## 661          1         attacked
## 662          1          capitol
## 663          1         inspired
## 664          1          trump's
## 665          1         multiple
## 666          1             lies
## 667          1         election
## 668          1            fraud
## 669          1              one
## 670          1             side
## 671          1        attacking
## 672          1          country
## 673          1            moves
## 674          1          farther
## 675          1          january
## 676          1                6
## 677          1        manchin's
## 678          1              hot
## 679          1             seat
## 680          1            going
## 681          1              get
## 682          1    uncomfortable
## 683          1              now
## 684          1            least
## 685          1              got
## 686          1        intention
## 687          1         vacating
#Display top 10 words
df2 %>% 
  count(word, sort = TRUE) %>% 
  top_n(20) %>%
  ggplot(aes(fct_reorder(word,n), n, fill = as.factor(n)))+ 
  geom_col() + 
  coord_flip() +
  theme(legend.position = "none")
## Selecting by n

#########

nrow(df2)
## [1] 687
round(nrow(df2)/100)
## [1] 7
section = rep(c(1,2, 3, 4,5, 6, 7,8, 9, 10,11), each = 10, 
              times = round(nrow(df2)/100))
length(section)
## [1] 770
section = as.data.frame(section)
section2 = slice(section, 1:nrow(df2))

df2 = df2 %>% arrange(linenumber) %>%
  cbind.data.frame(section2)

#==============
# Create bins for the manuscript - linear fashion
# and show the variation in sentiment across the manifesto


df2 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  spread(sentiment, n, fill=0) %>% 
  mutate(sent=positive-negative)  %>%
  ggplot(aes(x = section, y = sent, fill = as.factor(sent))) + 
  geom_col()+
  theme(legend.position = "none")

#how does emotion % sentiment change during the text
df2 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  ggplot(aes(x = section, y = n, fill = as.factor(sentiment))) + 
  geom_col(position = "stack")

Website 3

url3<-"https://www.cnn.com/2021/04/08/politics/environmental-protection-agency-chemical-guidance/index.html"
webpage3 <- read_html(url3)
class(webpage3)
## [1] "xml_document" "xml_node"
text7 <-webpage3 %>% html_nodes("#body-text") %>%   html_text()

#Input data


df3 = data.frame(linenumber = 1:length(text7), text= text7)

head(df3)
##   linenumber
## 1          1
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               text
## 1 Washington (CNN)The Biden-led Environmental Protection Agency says Trump administration political officials "compromised" an assessment of chemical dangers and has replaced it with a new one they say "upholds the tenants of scientific integrity." "The assessment posted today fixes the errors in the version issued earlier this year, was developed by EPA career scientists, and upholds the values of scientific integrity," Dr. Jennifer Orme-Zavaleta, acting assistant administrator for the Office of Research and Development and the agency's science adviser said in a statement. "This PFBS (Perfluorobutane sulfonic acid) assessment reflects the best available science, involved extensive federal, state, and public engagement, and is critical to EPA efforts to help communities impacted by PFAS." PFAS, which stands for per- and polyfluoroalkyl substances, is a family of synthetic chemicals known for links to health complications.Biden administration launches task force to ensure scientific decisions are free from political influenceAfter taking office, President Joe Biden's EPA said that it was removing a toxicity assessment for PFAS due to allegations that Trump administration officials overruled science to make it easier for regulators set their own standards and did not offer clear conclusions. In a statement, the EPA called the new Biden era assessment part of the agency's "commitment to restore scientific integrity."PFBS has been found in drinking water, wastewater and surface water, the EPA said. The new assessment will allow communities to determine when to take action on potential health risks associated with human contact with PFBS.Read MoreThe move comes shortly after the Biden administration announced the creation of a task force to review the federal government's scientific policies to ensure they are free from inappropriate political influence, as several top health officials under former President Donald Trump publicly admit they faced political pressure while doing their jobs amid the coronavirus pandemic.The White House Office of Science and Technology Policy said in a letter to agencies that it would form an interagency task force to review federal government policies and make sure they "prevent improper political interference" from affecting research or data. The letter also says the task force aims to prevent "the suppression or distortion of scientific or technological findings."
df3$text = as.character(df3$text)

#Convert to tidy format: one row, one word
df3 = df3 %>% unnest_tokens(word, text)

#Remove stopwords
(  df3 = df3 %>% anti_join(get_stopwords()) )
## Joining, by = "word"
##     linenumber                word
## 1            1          washington
## 2            1                 cnn
## 3            1               biden
## 4            1                 led
## 5            1       environmental
## 6            1          protection
## 7            1              agency
## 8            1                says
## 9            1               trump
## 10           1      administration
## 11           1           political
## 12           1           officials
## 13           1         compromised
## 14           1          assessment
## 15           1            chemical
## 16           1             dangers
## 17           1            replaced
## 18           1                 new
## 19           1                 one
## 20           1                 say
## 21           1             upholds
## 22           1             tenants
## 23           1          scientific
## 24           1           integrity
## 25           1          assessment
## 26           1              posted
## 27           1               today
## 28           1               fixes
## 29           1              errors
## 30           1             version
## 31           1              issued
## 32           1             earlier
## 33           1                year
## 34           1           developed
## 35           1                 epa
## 36           1              career
## 37           1          scientists
## 38           1             upholds
## 39           1              values
## 40           1          scientific
## 41           1           integrity
## 42           1                  dr
## 43           1            jennifer
## 44           1                orme
## 45           1            zavaleta
## 46           1              acting
## 47           1           assistant
## 48           1       administrator
## 49           1              office
## 50           1            research
## 51           1         development
## 52           1            agency's
## 53           1             science
## 54           1             adviser
## 55           1                said
## 56           1           statement
## 57           1                pfbs
## 58           1     perfluorobutane
## 59           1            sulfonic
## 60           1                acid
## 61           1          assessment
## 62           1            reflects
## 63           1                best
## 64           1           available
## 65           1             science
## 66           1            involved
## 67           1           extensive
## 68           1             federal
## 69           1               state
## 70           1              public
## 71           1          engagement
## 72           1            critical
## 73           1                 epa
## 74           1             efforts
## 75           1                help
## 76           1         communities
## 77           1            impacted
## 78           1                pfas
## 79           1                pfas
## 80           1              stands
## 81           1                 per
## 82           1     polyfluoroalkyl
## 83           1          substances
## 84           1              family
## 85           1           synthetic
## 86           1           chemicals
## 87           1               known
## 88           1               links
## 89           1              health
## 90           1 complications.biden
## 91           1      administration
## 92           1            launches
## 93           1                task
## 94           1               force
## 95           1              ensure
## 96           1          scientific
## 97           1           decisions
## 98           1                free
## 99           1           political
## 100          1      influenceafter
## 101          1              taking
## 102          1              office
## 103          1           president
## 104          1                 joe
## 105          1             biden's
## 106          1                 epa
## 107          1                said
## 108          1            removing
## 109          1            toxicity
## 110          1          assessment
## 111          1                pfas
## 112          1                 due
## 113          1         allegations
## 114          1               trump
## 115          1      administration
## 116          1           officials
## 117          1           overruled
## 118          1             science
## 119          1                make
## 120          1              easier
## 121          1          regulators
## 122          1                 set
## 123          1           standards
## 124          1               offer
## 125          1               clear
## 126          1         conclusions
## 127          1           statement
## 128          1                 epa
## 129          1              called
## 130          1                 new
## 131          1               biden
## 132          1                 era
## 133          1          assessment
## 134          1                part
## 135          1            agency's
## 136          1          commitment
## 137          1             restore
## 138          1          scientific
## 139          1           integrity
## 140          1                pfbs
## 141          1               found
## 142          1            drinking
## 143          1               water
## 144          1          wastewater
## 145          1             surface
## 146          1               water
## 147          1                 epa
## 148          1                said
## 149          1                 new
## 150          1          assessment
## 151          1               allow
## 152          1         communities
## 153          1           determine
## 154          1                take
## 155          1              action
## 156          1           potential
## 157          1              health
## 158          1               risks
## 159          1          associated
## 160          1               human
## 161          1             contact
## 162          1           pfbs.read
## 163          1             morethe
## 164          1                move
## 165          1               comes
## 166          1             shortly
## 167          1               biden
## 168          1      administration
## 169          1           announced
## 170          1            creation
## 171          1                task
## 172          1               force
## 173          1              review
## 174          1             federal
## 175          1        government's
## 176          1          scientific
## 177          1            policies
## 178          1              ensure
## 179          1                free
## 180          1       inappropriate
## 181          1           political
## 182          1           influence
## 183          1             several
## 184          1                 top
## 185          1              health
## 186          1           officials
## 187          1              former
## 188          1           president
## 189          1              donald
## 190          1               trump
## 191          1            publicly
## 192          1               admit
## 193          1               faced
## 194          1           political
## 195          1            pressure
## 196          1                jobs
## 197          1                amid
## 198          1         coronavirus
## 199          1        pandemic.the
## 200          1               white
## 201          1               house
## 202          1              office
## 203          1             science
## 204          1          technology
## 205          1              policy
## 206          1                said
## 207          1              letter
## 208          1            agencies
## 209          1                form
## 210          1         interagency
## 211          1                task
## 212          1               force
## 213          1              review
## 214          1             federal
## 215          1          government
## 216          1            policies
## 217          1                make
## 218          1                sure
## 219          1             prevent
## 220          1            improper
## 221          1           political
## 222          1        interference
## 223          1           affecting
## 224          1            research
## 225          1                data
## 226          1              letter
## 227          1                also
## 228          1                says
## 229          1                task
## 230          1               force
## 231          1                aims
## 232          1             prevent
## 233          1         suppression
## 234          1          distortion
## 235          1          scientific
## 236          1       technological
## 237          1            findings
#Display top 10 words
df3 %>% 
  count(word, sort = TRUE) %>% 
  top_n(20) %>%
  ggplot(aes(fct_reorder(word,n), n, fill = as.factor(n)))+ 
  geom_col() + 
  coord_flip() +
  theme(legend.position = "none")
## Selecting by n

#########

nrow(df3)
## [1] 237
round(nrow(df3)/100)
## [1] 2
section = rep(c(1,2, 3, 4,5, 6, 7,8, 9, 10,11), each = 10, 
              times = round(nrow(df3)/100))
length(section)
## [1] 220
section = as.data.frame(section)
section2 = slice(section, 1:nrow(df3))

df3 = df3 %>% arrange(linenumber) %>%
  merge.data.frame(section2)

#==============
# Create bins for the manuscript - linear fashion
# and show the variation in sentiment across the manifesto


df3 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  spread(sentiment, n, fill=0) %>% 
  mutate(sent=positive-negative)  %>%
  ggplot(aes(x = section, y = sent, fill = as.factor(sent))) + 
  geom_col()+
  theme(legend.position = "none")

#how does emotion % sentiment change during the text
df3 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  ggplot(aes(x = section, y = n, fill = as.factor(sentiment))) + 
  geom_col(position = "stack")

Website 4

url4<-"https://www.cnn.com/2021/04/05/politics/voting-rights-corporate-america-gop-breakup/index.html"
webpage4 <- read_html(url4)
class(webpage4)
## [1] "xml_document" "xml_node"
text8 <-webpage4 %>% html_nodes("#body-text") %>%   html_text()

df4 = data.frame(linenumber = 1:length(text8), text= text8)

head(df4)
##   linenumber
## 1          1
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     text
## 1 A version of this story appeared in CNN's What Matters newsletter. To get it in your inbox, sign up for free here. (CNN)The ever-moving tectonic shift underneath American politics is prime for another quake as civil rights starts to outweigh corporate tax rates in the calculating minds of big American businesses.Corporate America's years-long move toward a political awakening has increasingly put large companies in direct opposition to the GOP, a political party that spent generations crusading as the friend of business and slasher of corporate taxes."Our private sector must stop taking cues from the Outrage-Industrial Complex," Senate Minority Leader Mitch McConnell said Monday in a written statement, in which he also accused companies and Democrats of "disinformation." "Americans do not need or want big business to amplify disinformation or react to every manufactured controversy with frantic left-wing signaling," he said.Related: Fact Check: What the Georgia election law actually doesRead MoreThe decision by Major League Baseball, after President Joe Biden endorsed it, to move its 2021 All-Star Game out of Georgia to protest that state's newly restrictive voting laws is only the newest example.The Trump years accelerated the desire of large companies to at least appear responsive to civil rights.Companies severed ties with the soon-to-be President over his comments about immigrants just as his campaign was gaining steam, a move that seems strange in hindsight since his major legislative accomplishment was a permanent cut in corporate tax rates.Now, the Biden administration is plotting to raise corporate rates without help from Republicans and pay for a massive infrastructure plan. The GOP effort to stop Biden's infrastructure plan is built around making voters see it as a tax hike rather than a necessary upgrade to the country's infrastructure and reliance on carbon-emitting fuels.Whether large companies see the tax hikes or the government spending as a bigger boon will have to wait.What the bottom line saysRight now, big business is most vocal in its disapproval of the GOP's naked effort to cut down on Democratic votes and reclaim the House and Senate in 2022.Let's not assume that public companies, generally, do things because they're the right thing to do, but rather acknowledge they are legally required to be motivated by the bottom line.So it says something about the direction of the company and the importance of perception that a company like Delta would condemn Georgia's new law and, according to the Atlanta Journal-Constitution, tempt Republicans to revoke of a state tax cut related to jet fuel, is notable.Republicans, meanwhile, are pointing out the hypocrisy of companies like Delta and Coca-Cola calling out the Georgia voting rights law, while also, as multi-national corporations do, pursuing business in China.As Sen. Marco Rubio, the Florida Republican, said in a tweet:Dear @Delta: You are business partners with the Communist Party of #China When can we expect your letter saying that their ongoing genocide in #Xinjiang is "unacceptable and does not match Delta's values"??? #WokeCorporateHypocritesThe Wall Street Journal wondered if Biden's endorsement of sports boycotts related to justice will extend from the Georgia law to the upcoming Winter Olympics scheduled to take place in 2022.Looking beyond GeorgiaThe activists pushing for changes in places like Georgia aren't exactly satisfied with the corporate nods, which will have a debatable effect in Georgia, where the law has already been put in effect and now faces a court battle.Republicans in other states, however, have their own plans to make voting more difficult. The Georgia example could certainly have an impact in those places."These companies sell their products across the country, and across the country there are Black and brown voters who need to know they're not being left behind," Stacey Abrams, the voting rights leader, told the Journal-Constitution of the companies who have spoken up more forcefully now that the Georgia law is in place but were "mealy-mouthed" when it was being debated.How the culture wars have changedAnother thing to consider is the evolution of culture wars in the US.While few companies will want to take a stand on a issue like abortion, that is complicated by personal and religious beliefs, it's much easier for companies to take stands on something as simple as voting rights. Of course the government should be making it easier for people to vote.Other companies might be looking for some image rehab of their own. Facebook, Twitter and Google, targets of Democratic frustration about access to misinformation on their sites and Republican allegations they minimize conservative views, have all criticized the Georgia law and some have endorsed Democrats' proposal to create more national voting standards.The journey to corporate wokeness has been a long time in the making.A boycott of Arizona for an law widely perceived as anti-immigrant may have cost the state more than $100 million, but it largely fizzled after courts defanged the state law.North Carolina's anti-transgender "bathroom bill" led to boycotts by sports leagues and other companies in 2016 and cost the state's economy more than $3.75 billion, according to an AP analysis. State leaders, after the Republican governor lost his bid for reelection, rolled back elements of the law.Nike is enough invested in the perception of social justice that it sponsors a quarterback, Colin Kaepernick, who says he's been blackballed by the league.The NFL, while not finding room for Kaepernick on a roster, has pledged to spend $250 million to fight systemic racism.
df2$text = as.character(df4$text)

#Convert to tidy format: one row, one word
df4 = df4 %>% unnest_tokens(word, text)

#Remove stopwords
(  df4 = df4 %>% anti_join(get_stopwords()) )
## Joining, by = "word"
##     linenumber                       word
## 1            1                    version
## 2            1                      story
## 3            1                   appeared
## 4            1                      cnn's
## 5            1                    matters
## 6            1                 newsletter
## 7            1                        get
## 8            1                      inbox
## 9            1                       sign
## 10           1                       free
## 11           1                        cnn
## 12           1                       ever
## 13           1                     moving
## 14           1                   tectonic
## 15           1                      shift
## 16           1                 underneath
## 17           1                   american
## 18           1                   politics
## 19           1                      prime
## 20           1                    another
## 21           1                      quake
## 22           1                      civil
## 23           1                     rights
## 24           1                     starts
## 25           1                   outweigh
## 26           1                  corporate
## 27           1                        tax
## 28           1                      rates
## 29           1                calculating
## 30           1                      minds
## 31           1                        big
## 32           1                   american
## 33           1       businesses.corporate
## 34           1                  america's
## 35           1                      years
## 36           1                       long
## 37           1                       move
## 38           1                     toward
## 39           1                  political
## 40           1                  awakening
## 41           1               increasingly
## 42           1                        put
## 43           1                      large
## 44           1                  companies
## 45           1                     direct
## 46           1                 opposition
## 47           1                        gop
## 48           1                  political
## 49           1                      party
## 50           1                      spent
## 51           1                generations
## 52           1                  crusading
## 53           1                     friend
## 54           1                   business
## 55           1                    slasher
## 56           1                  corporate
## 57           1                      taxes
## 58           1                    private
## 59           1                     sector
## 60           1                       must
## 61           1                       stop
## 62           1                     taking
## 63           1                       cues
## 64           1                    outrage
## 65           1                 industrial
## 66           1                    complex
## 67           1                     senate
## 68           1                   minority
## 69           1                     leader
## 70           1                      mitch
## 71           1                  mcconnell
## 72           1                       said
## 73           1                     monday
## 74           1                    written
## 75           1                  statement
## 76           1                       also
## 77           1                    accused
## 78           1                  companies
## 79           1                  democrats
## 80           1             disinformation
## 81           1                  americans
## 82           1                       need
## 83           1                       want
## 84           1                        big
## 85           1                   business
## 86           1                    amplify
## 87           1             disinformation
## 88           1                      react
## 89           1                      every
## 90           1               manufactured
## 91           1                controversy
## 92           1                    frantic
## 93           1                       left
## 94           1                       wing
## 95           1                  signaling
## 96           1               said.related
## 97           1                       fact
## 98           1                      check
## 99           1                    georgia
## 100          1                   election
## 101          1                        law
## 102          1                   actually
## 103          1                   doesread
## 104          1                    morethe
## 105          1                   decision
## 106          1                      major
## 107          1                     league
## 108          1                   baseball
## 109          1                  president
## 110          1                        joe
## 111          1                      biden
## 112          1                   endorsed
## 113          1                       move
## 114          1                       2021
## 115          1                       star
## 116          1                       game
## 117          1                    georgia
## 118          1                    protest
## 119          1                    state's
## 120          1                      newly
## 121          1                restrictive
## 122          1                     voting
## 123          1                       laws
## 124          1                     newest
## 125          1                example.the
## 126          1                      trump
## 127          1                      years
## 128          1                accelerated
## 129          1                     desire
## 130          1                      large
## 131          1                  companies
## 132          1                      least
## 133          1                     appear
## 134          1                 responsive
## 135          1                      civil
## 136          1           rights.companies
## 137          1                    severed
## 138          1                       ties
## 139          1                       soon
## 140          1                  president
## 141          1                   comments
## 142          1                 immigrants
## 143          1                       just
## 144          1                   campaign
## 145          1                    gaining
## 146          1                      steam
## 147          1                       move
## 148          1                      seems
## 149          1                    strange
## 150          1                  hindsight
## 151          1                      since
## 152          1                      major
## 153          1                legislative
## 154          1             accomplishment
## 155          1                  permanent
## 156          1                        cut
## 157          1                  corporate
## 158          1                        tax
## 159          1                  rates.now
## 160          1                      biden
## 161          1             administration
## 162          1                   plotting
## 163          1                      raise
## 164          1                  corporate
## 165          1                      rates
## 166          1                    without
## 167          1                       help
## 168          1                republicans
## 169          1                        pay
## 170          1                    massive
## 171          1             infrastructure
## 172          1                       plan
## 173          1                        gop
## 174          1                     effort
## 175          1                       stop
## 176          1                    biden's
## 177          1             infrastructure
## 178          1                       plan
## 179          1                      built
## 180          1                     around
## 181          1                     making
## 182          1                     voters
## 183          1                        see
## 184          1                        tax
## 185          1                       hike
## 186          1                     rather
## 187          1                  necessary
## 188          1                    upgrade
## 189          1                  country's
## 190          1             infrastructure
## 191          1                   reliance
## 192          1                     carbon
## 193          1                   emitting
## 194          1              fuels.whether
## 195          1                      large
## 196          1                  companies
## 197          1                        see
## 198          1                        tax
## 199          1                      hikes
## 200          1                 government
## 201          1                   spending
## 202          1                     bigger
## 203          1                       boon
## 204          1                  wait.what
## 205          1                     bottom
## 206          1                       line
## 207          1                  saysright
## 208          1                        now
## 209          1                        big
## 210          1                   business
## 211          1                      vocal
## 212          1                disapproval
## 213          1                      gop's
## 214          1                      naked
## 215          1                     effort
## 216          1                        cut
## 217          1                 democratic
## 218          1                      votes
## 219          1                    reclaim
## 220          1                      house
## 221          1                     senate
## 222          1                       2022
## 223          1                     assume
## 224          1                     public
## 225          1                  companies
## 226          1                  generally
## 227          1                     things
## 228          1                      right
## 229          1                      thing
## 230          1                     rather
## 231          1                acknowledge
## 232          1                    legally
## 233          1                   required
## 234          1                  motivated
## 235          1                     bottom
## 236          1                    line.so
## 237          1                       says
## 238          1                  something
## 239          1                  direction
## 240          1                    company
## 241          1                 importance
## 242          1                 perception
## 243          1                    company
## 244          1                       like
## 245          1                      delta
## 246          1                    condemn
## 247          1                  georgia's
## 248          1                        new
## 249          1                        law
## 250          1                  according
## 251          1                    atlanta
## 252          1                    journal
## 253          1               constitution
## 254          1                      tempt
## 255          1                republicans
## 256          1                     revoke
## 257          1                      state
## 258          1                        tax
## 259          1                        cut
## 260          1                    related
## 261          1                        jet
## 262          1                       fuel
## 263          1        notable.republicans
## 264          1                  meanwhile
## 265          1                   pointing
## 266          1                  hypocrisy
## 267          1                  companies
## 268          1                       like
## 269          1                      delta
## 270          1                       coca
## 271          1                       cola
## 272          1                    calling
## 273          1                    georgia
## 274          1                     voting
## 275          1                     rights
## 276          1                        law
## 277          1                       also
## 278          1                      multi
## 279          1                   national
## 280          1               corporations
## 281          1                   pursuing
## 282          1                   business
## 283          1                   china.as
## 284          1                        sen
## 285          1                      marco
## 286          1                      rubio
## 287          1                    florida
## 288          1                 republican
## 289          1                       said
## 290          1                 tweet:dear
## 291          1                      delta
## 292          1                   business
## 293          1                   partners
## 294          1                  communist
## 295          1                      party
## 296          1                      china
## 297          1                        can
## 298          1                     expect
## 299          1                     letter
## 300          1                     saying
## 301          1                    ongoing
## 302          1                   genocide
## 303          1                   xinjiang
## 304          1               unacceptable
## 305          1                      match
## 306          1                    delta's
## 307          1                     values
## 308          1 wokecorporatehypocritesthe
## 309          1                       wall
## 310          1                     street
## 311          1                    journal
## 312          1                   wondered
## 313          1                    biden's
## 314          1                endorsement
## 315          1                     sports
## 316          1                   boycotts
## 317          1                    related
## 318          1                    justice
## 319          1                     extend
## 320          1                    georgia
## 321          1                        law
## 322          1                   upcoming
## 323          1                     winter
## 324          1                   olympics
## 325          1                  scheduled
## 326          1                       take
## 327          1                      place
## 328          1                       2022
## 329          1                    looking
## 330          1                     beyond
## 331          1                 georgiathe
## 332          1                  activists
## 333          1                    pushing
## 334          1                    changes
## 335          1                     places
## 336          1                       like
## 337          1                    georgia
## 338          1                    exactly
## 339          1                  satisfied
## 340          1                  corporate
## 341          1                       nods
## 342          1                  debatable
## 343          1                     effect
## 344          1                    georgia
## 345          1                        law
## 346          1                    already
## 347          1                        put
## 348          1                     effect
## 349          1                        now
## 350          1                      faces
## 351          1                      court
## 352          1         battle.republicans
## 353          1                     states
## 354          1                    however
## 355          1                      plans
## 356          1                       make
## 357          1                     voting
## 358          1                  difficult
## 359          1                    georgia
## 360          1                    example
## 361          1                  certainly
## 362          1                     impact
## 363          1                     places
## 364          1                  companies
## 365          1                       sell
## 366          1                   products
## 367          1                     across
## 368          1                    country
## 369          1                     across
## 370          1                    country
## 371          1                      black
## 372          1                      brown
## 373          1                     voters
## 374          1                       need
## 375          1                       know
## 376          1                       left
## 377          1                     behind
## 378          1                     stacey
## 379          1                     abrams
## 380          1                     voting
## 381          1                     rights
## 382          1                     leader
## 383          1                       told
## 384          1                    journal
## 385          1               constitution
## 386          1                  companies
## 387          1                     spoken
## 388          1                 forcefully
## 389          1                        now
## 390          1                    georgia
## 391          1                        law
## 392          1                      place
## 393          1                      mealy
## 394          1                    mouthed
## 395          1                debated.how
## 396          1                    culture
## 397          1                       wars
## 398          1             changedanother
## 399          1                      thing
## 400          1                   consider
## 401          1                  evolution
## 402          1                    culture
## 403          1                       wars
## 404          1                   us.while
## 405          1                  companies
## 406          1                       want
## 407          1                       take
## 408          1                      stand
## 409          1                      issue
## 410          1                       like
## 411          1                   abortion
## 412          1                complicated
## 413          1                   personal
## 414          1                  religious
## 415          1                    beliefs
## 416          1                       much
## 417          1                     easier
## 418          1                  companies
## 419          1                       take
## 420          1                     stands
## 421          1                  something
## 422          1                     simple
## 423          1                     voting
## 424          1                     rights
## 425          1                     course
## 426          1                 government
## 427          1                     making
## 428          1                     easier
## 429          1                     people
## 430          1                 vote.other
## 431          1                  companies
## 432          1                      might
## 433          1                    looking
## 434          1                      image
## 435          1                      rehab
## 436          1                   facebook
## 437          1                    twitter
## 438          1                     google
## 439          1                    targets
## 440          1                 democratic
## 441          1                frustration
## 442          1                     access
## 443          1             misinformation
## 444          1                      sites
## 445          1                 republican
## 446          1                allegations
## 447          1                   minimize
## 448          1               conservative
## 449          1                      views
## 450          1                 criticized
## 451          1                    georgia
## 452          1                        law
## 453          1                   endorsed
## 454          1                  democrats
## 455          1                   proposal
## 456          1                     create
## 457          1                   national
## 458          1                     voting
## 459          1              standards.the
## 460          1                    journey
## 461          1                  corporate
## 462          1                   wokeness
## 463          1                       long
## 464          1                       time
## 465          1                   making.a
## 466          1                    boycott
## 467          1                    arizona
## 468          1                        law
## 469          1                     widely
## 470          1                  perceived
## 471          1                       anti
## 472          1                  immigrant
## 473          1                        may
## 474          1                       cost
## 475          1                      state
## 476          1                        100
## 477          1                    million
## 478          1                    largely
## 479          1                    fizzled
## 480          1                     courts
## 481          1                   defanged
## 482          1                      state
## 483          1                  law.north
## 484          1                 carolina's
## 485          1                       anti
## 486          1                transgender
## 487          1                   bathroom
## 488          1                       bill
## 489          1                        led
## 490          1                   boycotts
## 491          1                     sports
## 492          1                    leagues
## 493          1                  companies
## 494          1                       2016
## 495          1                       cost
## 496          1                    state's
## 497          1                    economy
## 498          1                       3.75
## 499          1                    billion
## 500          1                  according
## 501          1                         ap
## 502          1                   analysis
## 503          1                      state
## 504          1                    leaders
## 505          1                 republican
## 506          1                   governor
## 507          1                       lost
## 508          1                        bid
## 509          1                 reelection
## 510          1                     rolled
## 511          1                       back
## 512          1                   elements
## 513          1                   law.nike
## 514          1                     enough
## 515          1                   invested
## 516          1                 perception
## 517          1                     social
## 518          1                    justice
## 519          1                   sponsors
## 520          1                quarterback
## 521          1                      colin
## 522          1                 kaepernick
## 523          1                       says
## 524          1                blackballed
## 525          1                 league.the
## 526          1                        nfl
## 527          1                    finding
## 528          1                       room
## 529          1                 kaepernick
## 530          1                     roster
## 531          1                    pledged
## 532          1                      spend
## 533          1                        250
## 534          1                    million
## 535          1                      fight
## 536          1                   systemic
## 537          1                     racism
#Display top 10 words
df4 %>% 
  count(word, sort = TRUE) %>% 
  top_n(20) %>%
  ggplot(aes(fct_reorder(word,n), n, fill = as.factor(n)))+ 
  geom_col() + 
  coord_flip() +
  theme(legend.position = "none")
## Selecting by n

#########

nrow(df4)
## [1] 537
round(nrow(df4)/100)
## [1] 5
section = rep(c(1,2, 3, 4,5, 6, 7,8, 9, 10,11), each = 10, 
              times = round(nrow(df4)/100))
length(section)
## [1] 550
section = as.data.frame(section)
section2 = slice(section, 1:nrow(df4))

df4 = df4 %>% arrange(linenumber) %>%
  cbind.data.frame(section2)

#==============
# Create bins for the manuscript - linear fashion
# and show the variation in sentiment across the manifesto


df4 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  spread(sentiment, n, fill=0) %>% 
  mutate(sent=positive-negative)  %>%
  ggplot(aes(x = section, y = sent, fill = as.factor(sent))) + 
  geom_col()+
  theme(legend.position = "none")

#how does emotion % sentiment change during the text
df4 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  ggplot(aes(x = section, y = n, fill = as.factor(sentiment))) + 
  geom_col(position = "stack")

Website 5

url5<-"https://www.cnn.com/2021/04/03/politics/state-legislation-voter-suppression/index.html"
webpage5 <- read_html(url5)
class(webpage5)
## [1] "xml_document" "xml_node"
text9 <-webpage5 %>% html_nodes("#body-text") %>%   html_text()

#Input data


df5 = data.frame(linenumber = 1:length(text9), text= text9)

head(df5)
##   linenumber
## 1          1
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              text
## 1  (CNN)Lawmakers in all but three states have introduced bills aimed at restricting ballot access, according to a new tally by the Brennan Center for Justice at New York University. Their latest report finds 361 bills restricting voting have been introduced in 47 states as of March 24. The total, released Thursday morning, marks a 43% rise in the number of bills introduced since Brennan last released a count a little over a month ago. The Brennan Center's previous tally identified 253 restrictive bills in 43 states in February. \n\nif(!window.pym){(function(b,c){var d=document.createElement("script");d.type="text/javascript",d.readyState?d.onreadystatechange=function(){("loaded"===d.readyState||"complete"===d.readyState)&&(d.onreadystatechange=null,c())}:d.onload=function(){c()},d.src=b,document.getElementsByTagName("head")[0].appendChild(d)})("//cdn.cnn.com/cnn/.e/interactive/js/lib/vendor/pym/pym.v1.min.js",function(){new pym.Parent("responsive-embed-20210401-voting-bills-by-state-update","//ix.cnn.io/dailygraphics/graphics/20210401-voting-bills-by-state-update/index.html",{title:"CNN Graphic"})})}else var responsiveEmbed=new pym.Parent("responsive-embed-20210401-voting-bills-by-state-update","//ix.cnn.io/dailygraphics/graphics/20210401-voting-bills-by-state-update/index.html",{title:"CNN Graphic"});\nThree states have led the country in the number of bills that aim to restrict the vote: Texas with 49 bills; Georgia, 25; and Arizona, 23. The rise reflects a sharp contrast to a year ago -- before the Covid-19 pandemic and well before the 2020 presidential election -- when state lawmakers were far less interested in restricting voting access. The Brennan Center's review of state legislation in February 2020 identified only 35 restrictive bills in 15 states.Read MoreThe legislative push is part of a national Republican effort that aims to restrict access to the ballot box following record turnout in the election. Republicans currently control both chambers of 30 state legislatures, including in Texas, Georgia and Arizona. The only three states that had not yet introduced a voting bill with restrictive provisions are Delaware, Ohio and Vermont.More than half of the 361 bills would make it harder to vote absentee and by mail, after a record number of Americans voted by mail in November. Nearly one in four restrictive bills seek to impose stricter voter identification requirements. \n\nif(!window.pym){(function(b,c){var d=document.createElement("script");d.type="text/javascript",d.readyState?d.onreadystatechange=function(){("loaded"===d.readyState||"complete"===d.readyState)&&(d.onreadystatechange=null,c())}:d.onload=function(){c()},d.src=b,document.getElementsByTagName("head")[0].appendChild(d)})("//cdn.cnn.com/cnn/.e/interactive/js/lib/vendor/pym/pym.v1.min.js",function(){new pym.Parent("responsive-embed-20210401-brennan-vote-restriction-multiples","//ix.cnn.io/dailygraphics/graphics/20210401-brennan-vote-restriction-multiples/index.html",{title:"CNN Graphic"})})}else var responsiveEmbed=new pym.Parent("responsive-embed-20210401-brennan-vote-restriction-multiples","//ix.cnn.io/dailygraphics/graphics/20210401-brennan-vote-restriction-multiples/index.html",{title:"CNN Graphic"});\nTexas has introduced 25 bills that would limit absentee and mail-in voting, more than any other state. Georgia and Arizona -- two key battlegrounds that flipped from 2016 to vote for President Joe Biden in 2020 -- follow Texas with 20 and 14 introduced bills targeting absentee voting, respectively.Texas also leads the nation in the number of bills targeting voter roll purges, voter registration and polling places.As the current leader for the most restrictive bills introduced overall, Texas is a key state to watch as bills continue to advance in its legislature. Seven restrictive bills have already advanced through the Texas legislature, meaning that a bill has either passed in at least one chamber or has otherwise seen action at the committee level. \n\nif(!window.pym){(function(b,c){var d=document.createElement("script");d.type="text/javascript",d.readyState?d.onreadystatechange=function(){("loaded"===d.readyState||"complete"===d.readyState)&&(d.onreadystatechange=null,c())}:d.onload=function(){c()},d.src=b,document.getElementsByTagName("head")[0].appendChild(d)})("//cdn.cnn.com/cnn/.e/interactive/js/lib/vendor/pym/pym.v1.min.js",function(){new pym.Parent("responsive-embed-20210401-voting-rights-bill-status","//ix.cnn.io/dailygraphics/graphics/20210401-voting-rights-bill-status/index.html",{title:"CNN Graphic"})})}else var responsiveEmbed=new pym.Parent("responsive-embed-20210401-voting-rights-bill-status","//ix.cnn.io/dailygraphics/graphics/20210401-voting-rights-bill-status/index.html",{title:"CNN Graphic"});\nNot every bill introduced will pass, or even reach a vote. But five have already been enacted into law and at least 41 others were advancing through the state legislative process as of March 24. Those five include SB202 in Georgia, the omnibus voting bill that has generated national controversy. The other four include an omnibus law in Iowa, two laws in Arkansas that tighten voter ID requirements, and one in Utah that mandates swift removal of dead people from the voting rolls.State lawmakers are likely to act quickly in the upcoming months to introduce more legislation and attempt to get their bills over the finish line for the year. All but 12 state legislatures plan to adjourn by June 30, according to the National Conference of State Legislatures.
df5$text = as.character(df5$text)

#Convert to tidy format: one row, one word
df5 = df5 %>% unnest_tokens(word, text)

#Remove stopwords
(  df5 = df5 %>% anti_join(get_stopwords()) )
## Joining, by = "word"
##     linenumber                          word
## 1            1                           cnn
## 2            1                     lawmakers
## 3            1                         three
## 4            1                        states
## 5            1                    introduced
## 6            1                         bills
## 7            1                         aimed
## 8            1                   restricting
## 9            1                        ballot
## 10           1                        access
## 11           1                     according
## 12           1                           new
## 13           1                         tally
## 14           1                       brennan
## 15           1                        center
## 16           1                       justice
## 17           1                           new
## 18           1                          york
## 19           1                    university
## 20           1                        latest
## 21           1                        report
## 22           1                         finds
## 23           1                           361
## 24           1                         bills
## 25           1                   restricting
## 26           1                        voting
## 27           1                    introduced
## 28           1                            47
## 29           1                        states
## 30           1                         march
## 31           1                            24
## 32           1                         total
## 33           1                      released
## 34           1                      thursday
## 35           1                       morning
## 36           1                         marks
## 37           1                            43
## 38           1                          rise
## 39           1                        number
## 40           1                         bills
## 41           1                    introduced
## 42           1                         since
## 43           1                       brennan
## 44           1                          last
## 45           1                      released
## 46           1                         count
## 47           1                        little
## 48           1                         month
## 49           1                           ago
## 50           1                       brennan
## 51           1                      center's
## 52           1                      previous
## 53           1                         tally
## 54           1                    identified
## 55           1                           253
## 56           1                   restrictive
## 57           1                         bills
## 58           1                            43
## 59           1                        states
## 60           1                      february
## 61           1                    window.pym
## 62           1                      function
## 63           1                             b
## 64           1                             c
## 65           1                           var
## 66           1                             d
## 67           1        document.createelement
## 68           1                        script
## 69           1                        d.type
## 70           1                          text
## 71           1                    javascript
## 72           1                  d.readystate
## 73           1          d.onreadystatechange
## 74           1                      function
## 75           1                        loaded
## 76           1                  d.readystate
## 77           1                      complete
## 78           1                  d.readystate
## 79           1          d.onreadystatechange
## 80           1                          null
## 81           1                             c
## 82           1                      d.onload
## 83           1                      function
## 84           1                             c
## 85           1                         d.src
## 86           1                             b
## 87           1 document.getelementsbytagname
## 88           1                          head
## 89           1                             0
## 90           1                   appendchild
## 91           1                             d
## 92           1                   cdn.cnn.com
## 93           1                           cnn
## 94           1                             e
## 95           1                   interactive
## 96           1                            js
## 97           1                           lib
## 98           1                        vendor
## 99           1                           pym
## 100          1                        pym.v1
## 101          1                        min.js
## 102          1                      function
## 103          1                           new
## 104          1                    pym.parent
## 105          1                    responsive
## 106          1                         embed
## 107          1                      20210401
## 108          1                        voting
## 109          1                         bills
## 110          1                         state
## 111          1                        update
## 112          1                     ix.cnn.io
## 113          1                 dailygraphics
## 114          1                      graphics
## 115          1                      20210401
## 116          1                        voting
## 117          1                         bills
## 118          1                         state
## 119          1                        update
## 120          1                    index.html
## 121          1                         title
## 122          1                           cnn
## 123          1                       graphic
## 124          1                          else
## 125          1                           var
## 126          1               responsiveembed
## 127          1                           new
## 128          1                    pym.parent
## 129          1                    responsive
## 130          1                         embed
## 131          1                      20210401
## 132          1                        voting
## 133          1                         bills
## 134          1                         state
## 135          1                        update
## 136          1                     ix.cnn.io
## 137          1                 dailygraphics
## 138          1                      graphics
## 139          1                      20210401
## 140          1                        voting
## 141          1                         bills
## 142          1                         state
## 143          1                        update
## 144          1                    index.html
## 145          1                         title
## 146          1                           cnn
## 147          1                       graphic
## 148          1                         three
## 149          1                        states
## 150          1                           led
## 151          1                       country
## 152          1                        number
## 153          1                         bills
## 154          1                           aim
## 155          1                      restrict
## 156          1                          vote
## 157          1                         texas
## 158          1                            49
## 159          1                         bills
## 160          1                       georgia
## 161          1                            25
## 162          1                       arizona
## 163          1                            23
## 164          1                          rise
## 165          1                      reflects
## 166          1                         sharp
## 167          1                      contrast
## 168          1                          year
## 169          1                           ago
## 170          1                         covid
## 171          1                            19
## 172          1                      pandemic
## 173          1                          well
## 174          1                          2020
## 175          1                  presidential
## 176          1                      election
## 177          1                         state
## 178          1                     lawmakers
## 179          1                           far
## 180          1                          less
## 181          1                    interested
## 182          1                   restricting
## 183          1                        voting
## 184          1                        access
## 185          1                       brennan
## 186          1                      center's
## 187          1                        review
## 188          1                         state
## 189          1                   legislation
## 190          1                      february
## 191          1                          2020
## 192          1                    identified
## 193          1                            35
## 194          1                   restrictive
## 195          1                         bills
## 196          1                            15
## 197          1                   states.read
## 198          1                       morethe
## 199          1                   legislative
## 200          1                          push
## 201          1                          part
## 202          1                      national
## 203          1                    republican
## 204          1                        effort
## 205          1                          aims
## 206          1                      restrict
## 207          1                        access
## 208          1                        ballot
## 209          1                           box
## 210          1                     following
## 211          1                        record
## 212          1                       turnout
## 213          1                      election
## 214          1                   republicans
## 215          1                     currently
## 216          1                       control
## 217          1                      chambers
## 218          1                            30
## 219          1                         state
## 220          1                  legislatures
## 221          1                     including
## 222          1                         texas
## 223          1                       georgia
## 224          1                       arizona
## 225          1                         three
## 226          1                        states
## 227          1                           yet
## 228          1                    introduced
## 229          1                        voting
## 230          1                          bill
## 231          1                   restrictive
## 232          1                    provisions
## 233          1                      delaware
## 234          1                          ohio
## 235          1                  vermont.more
## 236          1                          half
## 237          1                           361
## 238          1                         bills
## 239          1                          make
## 240          1                        harder
## 241          1                          vote
## 242          1                      absentee
## 243          1                          mail
## 244          1                        record
## 245          1                        number
## 246          1                     americans
## 247          1                         voted
## 248          1                          mail
## 249          1                      november
## 250          1                        nearly
## 251          1                           one
## 252          1                          four
## 253          1                   restrictive
## 254          1                         bills
## 255          1                          seek
## 256          1                        impose
## 257          1                      stricter
## 258          1                         voter
## 259          1                identification
## 260          1                  requirements
## 261          1                    window.pym
## 262          1                      function
## 263          1                             b
## 264          1                             c
## 265          1                           var
## 266          1                             d
## 267          1        document.createelement
## 268          1                        script
## 269          1                        d.type
## 270          1                          text
## 271          1                    javascript
## 272          1                  d.readystate
## 273          1          d.onreadystatechange
## 274          1                      function
## 275          1                        loaded
## 276          1                  d.readystate
## 277          1                      complete
## 278          1                  d.readystate
## 279          1          d.onreadystatechange
## 280          1                          null
## 281          1                             c
## 282          1                      d.onload
## 283          1                      function
## 284          1                             c
## 285          1                         d.src
## 286          1                             b
## 287          1 document.getelementsbytagname
## 288          1                          head
## 289          1                             0
## 290          1                   appendchild
## 291          1                             d
## 292          1                   cdn.cnn.com
## 293          1                           cnn
## 294          1                             e
## 295          1                   interactive
## 296          1                            js
## 297          1                           lib
## 298          1                        vendor
## 299          1                           pym
## 300          1                        pym.v1
## 301          1                        min.js
## 302          1                      function
## 303          1                           new
## 304          1                    pym.parent
## 305          1                    responsive
## 306          1                         embed
## 307          1                      20210401
## 308          1                       brennan
## 309          1                          vote
## 310          1                   restriction
## 311          1                     multiples
## 312          1                     ix.cnn.io
## 313          1                 dailygraphics
## 314          1                      graphics
## 315          1                      20210401
## 316          1                       brennan
## 317          1                          vote
## 318          1                   restriction
## 319          1                     multiples
## 320          1                    index.html
## 321          1                         title
## 322          1                           cnn
## 323          1                       graphic
## 324          1                          else
## 325          1                           var
## 326          1               responsiveembed
## 327          1                           new
## 328          1                    pym.parent
## 329          1                    responsive
## 330          1                         embed
## 331          1                      20210401
## 332          1                       brennan
## 333          1                          vote
## 334          1                   restriction
## 335          1                     multiples
## 336          1                     ix.cnn.io
## 337          1                 dailygraphics
## 338          1                      graphics
## 339          1                      20210401
## 340          1                       brennan
## 341          1                          vote
## 342          1                   restriction
## 343          1                     multiples
## 344          1                    index.html
## 345          1                         title
## 346          1                           cnn
## 347          1                       graphic
## 348          1                         texas
## 349          1                    introduced
## 350          1                            25
## 351          1                         bills
## 352          1                         limit
## 353          1                      absentee
## 354          1                          mail
## 355          1                        voting
## 356          1                         state
## 357          1                       georgia
## 358          1                       arizona
## 359          1                           two
## 360          1                           key
## 361          1                 battlegrounds
## 362          1                       flipped
## 363          1                          2016
## 364          1                          vote
## 365          1                     president
## 366          1                           joe
## 367          1                         biden
## 368          1                          2020
## 369          1                        follow
## 370          1                         texas
## 371          1                            20
## 372          1                            14
## 373          1                    introduced
## 374          1                         bills
## 375          1                     targeting
## 376          1                      absentee
## 377          1                        voting
## 378          1            respectively.texas
## 379          1                          also
## 380          1                         leads
## 381          1                        nation
## 382          1                        number
## 383          1                         bills
## 384          1                     targeting
## 385          1                         voter
## 386          1                          roll
## 387          1                        purges
## 388          1                         voter
## 389          1                  registration
## 390          1                       polling
## 391          1                     places.as
## 392          1                       current
## 393          1                        leader
## 394          1                   restrictive
## 395          1                         bills
## 396          1                    introduced
## 397          1                       overall
## 398          1                         texas
## 399          1                           key
## 400          1                         state
## 401          1                         watch
## 402          1                         bills
## 403          1                      continue
## 404          1                       advance
## 405          1                   legislature
## 406          1                         seven
## 407          1                   restrictive
## 408          1                         bills
## 409          1                       already
## 410          1                      advanced
## 411          1                         texas
## 412          1                   legislature
## 413          1                       meaning
## 414          1                          bill
## 415          1                        either
## 416          1                        passed
## 417          1                         least
## 418          1                           one
## 419          1                       chamber
## 420          1                     otherwise
## 421          1                          seen
## 422          1                        action
## 423          1                     committee
## 424          1                         level
## 425          1                    window.pym
## 426          1                      function
## 427          1                             b
## 428          1                             c
## 429          1                           var
## 430          1                             d
## 431          1        document.createelement
## 432          1                        script
## 433          1                        d.type
## 434          1                          text
## 435          1                    javascript
## 436          1                  d.readystate
## 437          1          d.onreadystatechange
## 438          1                      function
## 439          1                        loaded
## 440          1                  d.readystate
## 441          1                      complete
## 442          1                  d.readystate
## 443          1          d.onreadystatechange
## 444          1                          null
## 445          1                             c
## 446          1                      d.onload
## 447          1                      function
## 448          1                             c
## 449          1                         d.src
## 450          1                             b
## 451          1 document.getelementsbytagname
## 452          1                          head
## 453          1                             0
## 454          1                   appendchild
## 455          1                             d
## 456          1                   cdn.cnn.com
## 457          1                           cnn
## 458          1                             e
## 459          1                   interactive
## 460          1                            js
## 461          1                           lib
## 462          1                        vendor
## 463          1                           pym
## 464          1                        pym.v1
## 465          1                        min.js
## 466          1                      function
## 467          1                           new
## 468          1                    pym.parent
## 469          1                    responsive
## 470          1                         embed
## 471          1                      20210401
## 472          1                        voting
## 473          1                        rights
## 474          1                          bill
## 475          1                        status
## 476          1                     ix.cnn.io
## 477          1                 dailygraphics
## 478          1                      graphics
## 479          1                      20210401
## 480          1                        voting
## 481          1                        rights
## 482          1                          bill
## 483          1                        status
## 484          1                    index.html
## 485          1                         title
## 486          1                           cnn
## 487          1                       graphic
## 488          1                          else
## 489          1                           var
## 490          1               responsiveembed
## 491          1                           new
## 492          1                    pym.parent
## 493          1                    responsive
## 494          1                         embed
## 495          1                      20210401
## 496          1                        voting
## 497          1                        rights
## 498          1                          bill
## 499          1                        status
## 500          1                     ix.cnn.io
## 501          1                 dailygraphics
## 502          1                      graphics
## 503          1                      20210401
## 504          1                        voting
## 505          1                        rights
## 506          1                          bill
## 507          1                        status
## 508          1                    index.html
## 509          1                         title
## 510          1                           cnn
## 511          1                       graphic
## 512          1                         every
## 513          1                          bill
## 514          1                    introduced
## 515          1                          pass
## 516          1                          even
## 517          1                         reach
## 518          1                          vote
## 519          1                          five
## 520          1                       already
## 521          1                       enacted
## 522          1                           law
## 523          1                         least
## 524          1                            41
## 525          1                        others
## 526          1                     advancing
## 527          1                         state
## 528          1                   legislative
## 529          1                       process
## 530          1                         march
## 531          1                            24
## 532          1                          five
## 533          1                       include
## 534          1                         sb202
## 535          1                       georgia
## 536          1                       omnibus
## 537          1                        voting
## 538          1                          bill
## 539          1                     generated
## 540          1                      national
## 541          1                   controversy
## 542          1                          four
## 543          1                       include
## 544          1                       omnibus
## 545          1                           law
## 546          1                          iowa
## 547          1                           two
## 548          1                          laws
## 549          1                      arkansas
## 550          1                       tighten
## 551          1                         voter
## 552          1                            id
## 553          1                  requirements
## 554          1                           one
## 555          1                          utah
## 556          1                      mandates
## 557          1                         swift
## 558          1                       removal
## 559          1                          dead
## 560          1                        people
## 561          1                        voting
## 562          1                   rolls.state
## 563          1                     lawmakers
## 564          1                        likely
## 565          1                           act
## 566          1                       quickly
## 567          1                      upcoming
## 568          1                        months
## 569          1                     introduce
## 570          1                   legislation
## 571          1                       attempt
## 572          1                           get
## 573          1                         bills
## 574          1                        finish
## 575          1                          line
## 576          1                          year
## 577          1                            12
## 578          1                         state
## 579          1                  legislatures
## 580          1                          plan
## 581          1                       adjourn
## 582          1                          june
## 583          1                            30
## 584          1                     according
## 585          1                      national
## 586          1                    conference
## 587          1                         state
## 588          1                  legislatures
#Display top 10 words
df5 %>% 
  count(word, sort = TRUE) %>% 
  top_n(20) %>%
  ggplot(aes(fct_reorder(word,n), n, fill = as.factor(n)))+ 
  geom_col() + 
  coord_flip() +
  theme(legend.position = "none")
## Selecting by n

#########

nrow(df5)
## [1] 588
round(nrow(df5)/100)
## [1] 6
section = rep(c(1,2, 3, 4,5, 6, 7,8, 9, 10,11), each = 10, 
              times = round(nrow(df2)/100))
length(section)
## [1] 770
section = as.data.frame(section)
section2 = slice(section, 1:nrow(df5))

df5 = df5 %>% arrange(linenumber) %>%
  cbind.data.frame(section2)

#==============
# Create bins for the manuscript - linear fashion
# and show the variation in sentiment across the manifesto


df5 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  spread(sentiment, n, fill=0) %>% 
  mutate(sent=positive-negative)  %>%
  ggplot(aes(x = section, y = sent, fill = as.factor(sent))) + 
  geom_col()+
  theme(legend.position = "none")

#how does emotion % sentiment change during the text
df5 %>% inner_join(sentiments, by = "word") %>% 
  count(section, sentiment) %>% 
  ggplot(aes(x = section, y = n, fill = as.factor(sentiment))) + 
  geom_col(position = "stack")

Conclusion The Websites I have taken are all about Politics in the United States. I wanted to compare their sentiment by looking at the text and analyzing whether they are mostly positive, negative, or evenly distributed. What is interesting is that all the websites tend to differ for their sentiment. Websites 5 and 2 are evenly distributed between negative and positive sentiments. While Websites 3 and 1 are mostly positive, and website 4 is mostly negative. What I can take away is that for the most part, CNN’s articles about politics differ, meaning that they do not really have a bias when it comes to reporting with emotional words, or sentiments. This is good as when it comes to reporting politics emotions should not come into play as news sources should stick to the facts.