Professional Documents
Culture Documents
#clear plot
dev.off()
#packages install
install.packages("pacman")
require(pacman) # Gives a confirmation message.
library(pacman) # No message.
p_load(rvest, XML,magrittr)
for (i in 1:20){
aw <- read_html(as.character(paste(aurl,i,sep ="=")))
rev <- aw %>% html_nodes(".review-text") %>% html_text()
reviews <- c(reviews,rev)
}
write.table(reviews,"aw.txt")
getwd()
##################################
str(txt)
length(txt)
# Corpus
p_load(tm)
x <- Corpus(VectorSource(txt))
inspect(x[1])
inspect(x[160])
# Data Cleansing
x1 <- tm_map(x, tolower)
inspect(x1[1])
inspect(x1[5])
x1 <- tm_map(x1, removeNumbers)
inspect(x1[1])
tdm[1:20, 1:20]
inspect(x[3])
# Bar plot
w <- rowSums(tdm)
w
# better visualization
wordcloud(words = names(w_sub1), freq = w_sub1,
random.order=F,colors=rainbow(30),scale=c(2,0.5),rot.per=0.4)
windows()
#for review of the Apple Watch, key things discussed are data/ cellular,
hours, screen, heart rate monitor