-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
24 lines (24 loc) · 1013 Bytes
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
install.packages("handcodeR", force = TRUE)
library(handcodeR)
if(!require(pacman)) install.packages("pacman")
install.packages("pacman")
pacman::p_load(archiveRetriever,
stringr)
# Use the archiveRetriever to download article
nytimes_article <- scrape_urls(Urls = "http://web.archive.org/web/20201001004918/https://www.nytimes.com/2020/09/30/opinion/biden-trump-2020-debate.html",
Paths = c(title = "//h1[@itemprop='headline']",
author = "//span[@itemprop='name']",
date = "//time//text()",
article = "//section[@itemprop='articleBody']//p"))
# Split up the article in different sentences
sentences <- unlist(str_split(nytimes_article$article, pattern = "(?<=\\.)\\s"))
head(sentences)
annotated <- handcode(data = sentences,
candidate = c("Joe Biden", "Donald Trump"),
sentiment = c("positive", "negative"))
View(annotated)
install.packages("revtools")
library (revtools)
setwd("/Users/manika/Desktop/Github/handbook")
source("~/Desktop/Github/handbook/_common.R")
source("~/Desktop/Github/handbook/_common.R")