Summary

Headquartered in Bloomfield Hills, Michigan, the Penske Corporation provides a diversified array of transportation services. One division of the Penske Corporation is Penske Truck Rentals, with a fleet of more than 50,000 vehicles. Customers nationwide turn to Penske Truck Rentals for cargo vans, box trucks, flatbeds, refrigerated trucks, tractors, and trailers. The Penske brand relies upon providing outstanding customer service along with clean and reliable products to stay competitive in the personal truck rental market.

The objective of this project is to generate a sentiment analysis using a corpus of four negative online reviews of Penske Truck Rentals. The analysis will assist in revealing and isolating any apparent systemic lapse in service standards within the process of leasing Penske trucks. I used four online reviews from the website Ripoff Report and created separate .txt documents for each review.

The analysis uses the Minqing Hu and Bing Liu Positive and Negative Opinion Lexicons from their paper: Minqing Hu and Bing Liu. “Mining and Summarizing Customer Reviews.” Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD-2004), Aug 22-25, 2004, Seattle, Washington, USA,

The key take away from this project is the ability to identify the frequency of outlier negative sentiments that may appear across the corpus.

Process

Load packages

library(tm)
library(wordcloud)
library(stringr)
library(kableExtra)
library(httr)
library(httpuv)

Assign corpus of Penske reviews to a folder in the working direcory

folder <- "C:/Users/narce/OneDrive/Documents/GitHub/Penske/Penske/corpus"

Confirm the contents of the folder

list.files(path=folder, pattern="*.txt")
## [1] "Penske_1.txt" "Penske_2.txt" "Penske_3.txt" "Penske_4.txt"

Create character vector of the four file names

filelist <- list.files(path=folder, pattern="*.txt")
filelist
## [1] "Penske_1.txt" "Penske_2.txt" "Penske_3.txt" "Penske_4.txt"
str(filelist)
##  chr [1:4] "Penske_1.txt" "Penske_2.txt" "Penske_3.txt" "Penske_4.txt"

Create a separate file path for each element and saves that into a new value, filelist

filelist <-paste(folder, "\\", filelist, sep="")
filelist
## [1] "C:/Users/narce/OneDrive/Documents/GitHub/Penske/Penske/corpus\\Penske_1.txt"
## [2] "C:/Users/narce/OneDrive/Documents/GitHub/Penske/Penske/corpus\\Penske_2.txt"
## [3] "C:/Users/narce/OneDrive/Documents/GitHub/Penske/Penske/corpus\\Penske_3.txt"
## [4] "C:/Users/narce/OneDrive/Documents/GitHub/Penske/Penske/corpus\\Penske_4.txt"

Import each file as a character vector using laaply and the read.Lines function. ReadLines will treat each line of text as a separate element in a character vector. Laaply applies this to each file in the folder.

library(knitr)
kable(lapply(filelist, FUN=readLines), "html") %>%
  kable_styling() %>%
  scroll_box(width = "915px", height = "200px")
Blood all over the inside of one of the two trucks I rented! I reserved two trucks one of the reservations got lost but they were able to get a truck from another location. When I picked up the second truck I noticed it was dirty, at the time I thought it was from someone hauling tires. I wasn“t happy but I needed the truck. I loaded the”clean" truck first then I loaded the “dirty” truck by this time it was almost dark I had use the cargo light to see. I paid no intention to the condition of the truck these spots I thought were from tires. I loaded in Missouri and took it to New Mexico. I unloaded the “dirty” truck in the morning as the sun was coming up and noticed a blood stain after unloading a few feet of the 26’ truck. The first spot was nothing compared the the rest of the truck. the truck literally looked like a massacre happened on this truck. After I had the truck completely unloaded I drove it straight to the drop off which happened to be a corporate location and went in asking for a manager.
….. I told the manager that he needed to come out and look at the back of this truck and he did. He had a loss for words but ended up talking some pictures. We went back in side and he asked me when the truck was do back I told him “tomorrow” then he said it would be taken care of then. I was flabbergasted. I thought he would call the police or atleast get me out of the rolling crime scene but he didn’t. Since then I have spent the last six months trying to figure out what I was exposed to. I have been sent two lab reports that they claimed to have done on the truck(again no police). The first lab report had a date discrepancy so I called and got another copy of the report this time the conclusions were different and that report had a date discrepancy also. I believe both reports to have been falsified. I have spent the last six months wondering if I contracted something from this biohazard.
I had made a Penske truck rental reservation for August 31st at Home Depot so that I could help my daughter move from one apartment to another. Since first making the reservation in early August, I received two calls from Penske: one shortly after making the reservation to confirm it and to get my credit card number to guarantee I would show, and the second on August 30th to confirm that I was still planning to arrive at Home Depot at the agreed-to time the next day.
When my wife and I arrived at the appointed time, we were informed by Home Depot employees that there was no rental truck available, nor would there be. We were further informed that we were not the first that day to be told they were not getting their rental truck either. In fact, there had been nine others that were told the same thing. The Home Depot employee offered to call the Penske office so that I could get an explanation for myself, an offer I accepted. The person from the Framingham, MA office of Penske (he would only say that his name was Sonny, wouldn’t give me his last name) said that there wasn’t anything he could do and that they were over-booked and under-supplied. When I asked him why he hadn’t called earlier to inform me of this so that I could make other arrangements, he offered no response. Apparently, they are authorized to confirm reservations, but not when they are unable to meet their own obligations.
After hanging up, the Home Depot employee informed us that Penske had not only over-booked a significant number of rental reservations for that day, but that they had done so intentionally–saying that this was common on busy end of the month weekends. It was clear to me that they planned to do this and that as long as their vehicles were on the roads generating income, the negative effects of this strategy was of no consequence to Penske.
The result to me and my family was not pleasant, and had far reaching effects on friends and family for the entire rain-soaked Labor Day weekend. What I can say right now is that even though the weekend and the effects of Penske’s failure to meet its obligations have passed, the negative effects are only just beginning for Penske. Penske will never, ever earn my business again as long as I live. I will tell as many people as I can NOT to ever do business with them.
The effects have also, unfortunately, spilled over to my relationship with Home Depot. In the 60 minutes prior to my scheduled pick up my truck rental on the 31st, my wife and I purchased two rooms of carpeting with installation. That order has since been cancelled and gone to Lowes. Likewise, any time I have a choice in making home improvement purchases, I will do so with Lowes or frankly anyone other than Home Depot. Over the years, my wife and I have spent some $50K with Home Depot and more from close friends and immediate relatives. There will be no more.
You may ask, why am I angry with Home Depot? After all, they weren’t the ones who let me and my family in the lurch. The answer is a simple business fact: you are known by the company you keep and the partnerships you make. The truck rental display at the Home Depot rental center proudly boasts of their partnership with Penske. That decision today has cost Home Depot a good deal of future business from me and everyone else I can convince to avoid them (this post to consumer affairs is only the beginning). I only hope that every other person who was stood up this past weekend or at any time in the past by Penske does the same and that at some point a wise person at Home Depot realizes the extent their partnership with Penske has cost them financially and in customer loyalty.
My wife and I were recently married, and decided to move across the country from Sonoma CA to Redwood NY to be closer to her parents. We really had no issues until hitting the 80/90 East leaving Chicago. We were heading through early morning rush hour traffic, when I spotted something shining in the roadway about 4 cars ahead of me. Being as though I was in a 26 foot truck, I was able to see above all the other vehicles. I could not move to either lane due to traffic. Right before I passed over the object, I could see that it was a piece of plexiglass laying flat in the roadway. Knowing full weel what was going to happen, I watched in horror out of my side rear view mirror as the sheer mass of the truck created a draft larrge enough to pick up and hurl the plexiglass straight at my wifes car, that was directly behind me. it came up spinning into her bumper, grill and hood. Luckily, the piece split in 2 pefore continuing on its path straight at her and through her front windshield!
We pulled over to inspect the damage and found that the plexiglass had actually hit corner first into the bumper. She was lucky to be alive. We drove straight through the night and arrived in NY at about 3am. Upon waking the next morning, I immediately called Penske and told them about the damage. Their response was that, “they are not responsible for something laying in the roadway”. So I asked,“then why did I purchase full coverage insurance that I quote,”includes third party claims“?! My wife and I are filing a claim based on DAMAGE caused by YOUR TRUCK. Their response you ask?”Again sir, we don’t cover that kind of thing." Really? It is a third party claim. That is covered in your insurance package. Guess what? They are outright refusing to pay the damages. Big surprise. Corperate pig screws the little people. Anyway, after all that, I spent the morning unloading the truck only to find that the mattress and box spring to my bed are soaked and laying in a pool of water at the back of the truck. I finished emptying the truckand took it back to the drop off site. After telling them about both incidents the gave me a number to call. They did NOT ask to see the bed OR car damages. Hmmmmm. So, I went home to call penske AGAIN. Told me that they would cover the damages as long as I send pictures and have a receipt for the bed. Now, the pics, not a big deal. Understandable. The receipt? The bed is 3 years old. Why in the h**l would I have a receipt?! In conclusion, I purchased the TOP insurance packag that they had, yet they are covering NONE of the damages! Thanks a lot Penske! Go EFF yourself with a splintered log!
My husband and I rented a 15 ft truck from Penske in Bakersfield, CA. On 11/2/03 at 4:15 am while 1 mile up the grapevine on interstate 5 the truck came to an abrupt stop while we were in the middle lane. My husband and I both hurried to put on the emergency flashers and exit the vehicle.
Meanwhile large trucks were passing on our right, cars on the left, trying to avoid hitting us. We got to the shoulder of the road; my husband called 911 and alerted the CHP and asked to have a tow truck sent immediately.
We stood out in 30 degree freezing temperatures and waved by oncoming traffice to avoid hitting the truck. Twenty minutes later the CHP officer showed up. He parked his car behind our rental truck and placed several flares on the road. He stood back on the left side and we were on the right. We watched in horror as multiple semi trucks and cars approached the vehicle and swerved all over the road to avoid hitting each other AND the rental truck.
Thirty minutes after the CHP officer arrived the tow truck came. We were so relieved to get the rental truck off the road and onto the shoulder. After standing out in the cold for 1 1/4 hours (We were practically frozen) and experiencing the worst and most frightening thing that has ever happened to us we finally headed home in the tow truck. We were asked to take the truck to the Penske company in Bakersfield.
When we arrived were were told that “we are not responsible for the contents of the truck”. Needless to say at this point Penske has done nothing for us except demand that we pick up the truck’s contents immediately (as of 4pm on 11/3). As far as we know they still intend on charging us for the truck. They have no intention of reimbursing us for the items which were broken during the tow.
The manager told me they opened the back of the truck so I have no idea if everything is still there. My husband and I were nearly killed. We sat in a vehicle for two minutes or so (as we sat there I prayed to God that we not die for the sake of our children and grandchildren) in the middle lane of one of the busiest freeways in the state of California in pitch black wondering if we were going to be hit from behind at any second.
We feel that we were put into an unsafe vehicle. We were lucky that we walked away. Others in the same situation may not be as lucky. The bearing in the differential went out. This is what caused our near fatal accident. Could this have been avoided?
Evelyn
Bakersfield, California
U.S.A.

Assign a new vector to filelistA

filelistA <- lapply(filelist, FUN=readLines)
lapply(filelistA, FUN = paste, collapse=" ")
corpus <-lapply(filelistA, FUN = paste, collapse=" ")

Munging the Data

Removes punctuations

corpus2 <- gsub(pattern = "\\W", replace=" ", corpus)

Removes numbers

corpus2 <- gsub(pattern = "\\d", replacement = " ", corpus2)

Makes text lowercase

corpus2<-tolower(corpus2)

Removes stopwords (and, the, a…)

corpus2 <- removeWords(corpus2, stopwords("english"))

Removes single character text

corpus2 < gsub(pattern = "\\b[A-z]\\b{1}", replace=" ", corpus2)
## [1] FALSE FALSE FALSE FALSE

Removes white space

corpus2 <- stripWhitespace(corpus2)

Creates a wordcloud visualization of the most used words in the corpus

wordcloud(corpus2, random.order = FALSE, colors = brewer.pal(8, "Accent"))

Creates a corpus

corpus3 <- Corpus(VectorSource(corpus2))
summary(corpus3)
##   Length Class             Mode
## 1 2      PlainTextDocument list
## 2 2      PlainTextDocument list
## 3 2      PlainTextDocument list
## 4 2      PlainTextDocument list

Creates a Term document matrix

tdm <- TermDocumentMatrix(corpus3)

Creates the matrix

as.matrix(tdm)
viewmatrix <- as.matrix(tdm)

Changes the names of the columns (Read1 = Reading, PA, Malb = Malborough, MA, Read2 - Reading, PA, Baker = Bakersfield, CA)

colnames(viewmatrix) <- c("Read1", "Malb", "Read2", "Baker")
  kable(as.matrix(tdm), "html") %>%
  kable_styling() %>%
  scroll_box(width = "915px", height = "200px")
1 2 3 4
able 1 0 1 0
almost 1 0 0 0
also 1 1 0 0
another 2 1 0 0
asked 1 1 1 2
asking 1 0 0 0
atleast 1 0 0 0
back 3 0 2 2
believe 1 0 0 0
biohazard 1 0 0 0
blood 2 0 0 0
call 1 1 2 0
called 1 1 1 1
care 1 0 0 0
cargo 1 0 0 0
claimed 1 0 0 0
clean 1 0 0 0
come 1 0 0 0
coming 1 0 0 0
compared 1 0 0 0
completely 1 0 0 0
conclusions 1 0 0 0
condition 1 0 0 0
contracted 1 0 0 0
copy 1 0 0 0
corporate 1 0 0 0
crime 1 0 0 0
dark 1 0 0 0
date 2 0 0 0
didn 1 0 0 0
different 1 0 0 0
dirty 3 0 0 0
discrepancy 2 0 0 0
done 1 1 0 1
drop 1 0 1 0
drove 1 0 1 0
ended 1 0 0 0
exposed 1 0 0 0
falsified 1 0 0 0
feet 1 0 0 0
figure 1 0 0 0
first 3 2 1 0
flabbergasted 1 0 0 0
get 2 2 0 1
got 2 0 0 1
happened 2 0 0 1
happy 1 0 0 0
hauling 1 0 0 0
inside 1 0 0 0
intention 1 0 0 1
lab 2 0 0 0
last 2 1 0 0
light 1 0 0 0
like 1 0 0 0
literally 1 0 0 0
loaded 3 0 0 0
location 2 0 0 0
look 1 0 0 0
looked 1 0 0 0
loss 1 0 0 0
lost 1 0 0 0
manager 2 0 0 1
massacre 1 0 0 0
mexico 1 0 0 0
missouri 1 0 0 0
months 2 0 0 0
morning 1 0 3 0
needed 2 0 0 0
new 1 0 0 0
nothing 1 0 0 1
noticed 2 0 0 0
one 2 2 0 1
paid 1 0 0 0
picked 1 0 0 0
pictures 1 0 1 0
police 2 0 0 0
rented 1 0 0 1
report 3 0 0 0
reports 2 0 0 0
reservations 1 2 0 0
reserved 1 0 0 0
rest 1 0 0 0
rolling 1 0 0 0
said 1 1 0 0
scene 1 0 0 0
second 1 1 0 1
see 1 0 3 0
sent 1 0 0 1
side 1 0 1 1
since 1 2 0 0
six 2 0 0 0
someone 1 0 0 0
something 1 0 2 0
spent 2 1 1 0
spot 1 0 0 0
spots 1 0 0 0
stain 1 0 0 0
straight 1 0 3 0
sun 1 0 0 0
taken 1 0 0 0
talking 1 0 0 0
thought 3 0 0 0
time 3 4 0 0
tires 2 0 0 0
told 2 2 2 2
tomorrow 1 0 0 0
took 1 0 1 0
truck 15 5 5 14
trucks 2 0 0 2
trying 1 0 0 1
two 3 2 0 1
unloaded 2 0 0 0
unloading 1 0 1 0
use 1 0 0 0
wasn 1 1 0 0
went 2 0 1 1
wondering 1 0 0 1
words 1 0 0 0
accepted 0 1 0 0
affairs 0 1 0 0
agreed 0 1 0 0
angry 0 1 0 0
answer 0 1 0 0
anyone 0 1 0 0
anything 0 1 0 0
apartment 0 1 0 0
apparently 0 1 0 0
appointed 0 1 0 0
arrangements 0 1 0 0
arrive 0 1 0 0
arrived 0 1 1 2
ask 0 1 2 0
august 0 3 0 0
authorized 0 1 0 0
available 0 1 0 0
avoid 0 1 0 3
beginning 0 2 0 0
boasts 0 1 0 0
booked 0 2 0 0
business 0 4 0 0
busy 0 1 0 0
calls 0 1 0 0
can 0 3 0 0
cancelled 0 1 0 0
card 0 1 0 0
carpeting 0 1 0 0
center 0 1 0 0
choice 0 1 0 0
clear 0 1 0 0
close 0 1 0 0
common 0 1 0 0
company 0 1 0 1
confirm 0 3 0 0
consequence 0 1 0 0
consumer 0 1 0 0
convince 0 1 0 0
cost 0 2 0 0
credit 0 1 0 0
customer 0 1 0 0
daughter 0 1 0 0
day 0 4 0 0
deal 0 1 1 0
decision 0 1 0 0
depot 0 12 0 0
display 0 1 0 0
earlier 0 1 0 0
early 0 1 1 0
earn 0 1 0 0
effects 0 5 0 0
either 0 1 1 0
else 0 1 0 0
employee 0 2 0 0
employees 0 1 0 0
end 0 1 0 0
entire 0 1 0 0
even 0 1 0 0
ever 0 2 0 1
every 0 1 0 0
everyone 0 1 0 0
explanation 0 1 0 0
extent 0 1 0 0
fact 0 2 0 0
failure 0 1 0 0
family 0 3 0 0
far 0 1 0 1
financially 0 1 0 0
framingham 0 1 0 0
frankly 0 1 0 0
friends 0 2 0 0
future 0 1 0 0
generating 0 1 0 0
getting 0 1 0 0
give 0 1 0 0
gone 0 1 0 0
good 0 1 0 0
guarantee 0 1 0 0
hadn 0 1 0 0
hanging 0 1 0 0
help 0 1 0 0
home 0 13 1 1
hope 0 1 0 0
immediate 0 1 0 0
improvement 0 1 0 0
income 0 1 0 0
inform 0 1 0 0
informed 0 3 0 0
installation 0 1 0 0
intentionally 0 1 0 0
just 0 1 0 0
keep 0 1 0 0
known 0 1 0 0
labor 0 1 0 0
let 0 1 0 0
likewise 0 1 0 0
live 0 1 0 0
long 0 2 1 0
lowes 0 2 0 0
loyalty 0 1 0 0
lurch 0 1 0 0
made 0 1 0 0
make 0 2 0 0
making 0 3 0 0
many 0 1 0 0
may 0 1 0 1
meet 0 2 0 0
minutes 0 1 0 3
month 0 1 0 0
move 0 1 2 0
name 0 2 0 0
negative 0 2 0 0
never 0 1 0 0
next 0 1 1 0
nine 0 1 0 0
now 0 1 1 0
number 0 2 1 0
obligations 0 2 0 0
offer 0 1 0 0
offered 0 2 0 0
office 0 2 0 0
ones 0 1 0 0
order 0 1 0 0
others 0 1 0 1
partnership 0 2 0 0
partnerships 0 1 0 0
passed 0 1 1 0
past 0 2 0 0
penske 0 12 3 3
people 0 1 1 0
person 0 3 0 0
pick 0 1 1 1
planned 0 1 0 0
planning 0 1 0 0
pleasant 0 1 0 0
point 0 1 0 1
post 0 1 0 0
prior 0 1 0 0
proudly 0 1 0 0
purchased 0 1 1 0
purchases 0 1 0 0
rain 0 1 0 0
reaching 0 1 0 0
realizes 0 1 0 0
received 0 1 0 0
relationship 0 1 0 0
relatives 0 1 0 0
rental 0 7 0 3
reservation 0 3 0 0
response 0 1 2 0
result 0 1 0 0
right 0 1 1 2
roads 0 1 0 0
rooms 0 1 0 0
say 0 2 0 1
saying 0 1 0 0
scheduled 0 1 0 0
shortly 0 1 0 0
show 0 1 0 0
significant 0 1 0 0
simple 0 1 0 0
soaked 0 1 1 0
sonny 0 1 0 0
spilled 0 1 0 0
still 0 1 0 2
stood 0 1 0 2
strategy 0 1 0 0
supplied 0 1 0 0
tell 0 1 0 0
thing 0 1 1 1
though 0 1 1 0
today 0 1 0 0
unable 0 1 0 0
unfortunately 0 1 0 0
vehicles 0 1 1 0
weekend 0 3 0 0
weekends 0 1 0 0
weren 0 1 0 0
wife 0 3 2 0
will 0 4 0 0
wise 0 1 0 0
wouldn 0 1 0 0
years 0 1 1 0
across 0 0 1 0
actually 0 0 1 0
ahead 0 0 1 0
alive 0 0 1 0
anyway 0 0 1 0
based 0 0 1 0
bed 0 0 4 0
behind 0 0 1 2
big 0 0 2 0
box 0 0 1 0
bumper 0 0 2 0
came 0 0 1 2
car 0 0 2 1
cars 0 0 1 2
caused 0 0 1 1
chicago 0 0 1 0
claim 0 0 2 0
claims 0 0 1 0
closer 0 0 1 0
conclusion 0 0 1 0
continuing 0 0 1 0
corner 0 0 1 0
corperate 0 0 1 0
country 0 0 1 0
cover 0 0 2 0
coverage 0 0 1 0
covered 0 0 1 0
covering 0 0 1 0
created 0 0 1 0
damage 0 0 3 0
damages 0 0 4 0
decided 0 0 1 0
directly 0 0 1 0
don 0 0 1 0
draft 0 0 1 0
due 0 0 1 0
east 0 0 1 0
eff 0 0 1 0
emptying 0 0 1 0
enough 0 0 1 0
filing 0 0 1 0
find 0 0 1 0
finished 0 0 1 0
flat 0 0 1 0
foot 0 0 1 0
found 0 0 1 0
front 0 0 1 0
full 0 0 2 0
gave 0 0 1 0
going 0 0 1 1
grill 0 0 1 0
guess 0 0 1 0
happen 0 0 1 0
heading 0 0 1 0
hit 0 0 1 1
hitting 0 0 1 3
hmmmmm 0 0 1 0
hood 0 0 1 0
horror 0 0 1 1
hour 0 0 1 0
hurl 0 0 1 0
immediately 0 0 1 2
incidents 0 0 1 0
includes 0 0 1 0
inspect 0 0 1 0
insurance 0 0 3 0
issues 0 0 1 0
kind 0 0 1 0
knowing 0 0 1 0
lane 0 0 1 2
larrge 0 0 1 0
laying 0 0 3 0
leaving 0 0 1 0
little 0 0 1 0
log 0 0 1 0
lot 0 0 1 0
luckily 0 0 1 0
lucky 0 0 1 2
married 0 0 1 0
mass 0 0 1 0
mattress 0 0 1 0
mirror 0 0 1 0
night 0 0 1 0
none 0 0 1 0
object 0 0 1 0
old 0 0 1 0
outright 0 0 1 0
packag 0 0 1 0
package 0 0 1 0
parents 0 0 1 0
party 0 0 2 0
path 0 0 1 0
pay 0 0 1 0
pefore 0 0 1 0
pics 0 0 1 0
piece 0 0 2 0
pig 0 0 1 0
plexiglass 0 0 3 0
pool 0 0 1 0
pulled 0 0 1 0
purchase 0 0 1 0
quote 0 0 1 0
really 0 0 2 0
rear 0 0 1 0
receipt 0 0 3 0
recently 0 0 1 0
redwood 0 0 1 0
refusing 0 0 1 0
responsible 0 0 1 1
roadway 0 0 3 0
rush 0 0 1 0
screws 0 0 1 0
send 0 0 1 0
sheer 0 0 1 0
shining 0 0 1 0
sir 0 0 1 0
site 0 0 1 0
sonoma 0 0 1 0
spinning 0 0 1 0
splintered 0 0 1 0
split 0 0 1 0
spotted 0 0 1 0
spring 0 0 1 0
surprise 0 0 1 0
telling 0 0 1 0
thanks 0 0 1 0
third 0 0 2 0
top 0 0 1 0
traffic 0 0 2 0
truckand 0 0 1 0
understandable 0 0 1 0
upon 0 0 1 0
view 0 0 1 0
waking 0 0 1 0
watched 0 0 1 1
water 0 0 1 0
weel 0 0 1 0
wifes 0 0 1 0
windshield 0 0 1 0
yet 0 0 1 0
abrupt 0 0 0 1
accident 0 0 0 1
alerted 0 0 0 1
approached 0 0 0 1
avoided 0 0 0 1
away 0 0 0 1
bakersfield 0 0 0 3
bearing 0 0 0 1
black 0 0 0 1
broken 0 0 0 1
busiest 0 0 0 1
california 0 0 0 2
charging 0 0 0 1
children 0 0 0 1
chp 0 0 0 3
cold 0 0 0 1
contents 0 0 0 2
degree 0 0 0 1
demand 0 0 0 1
die 0 0 0 1
differential 0 0 0 1
emergency 0 0 0 1
evelyn 0 0 0 1
everything 0 0 0 1
except 0 0 0 1
exit 0 0 0 1
experiencing 0 0 0 1
fatal 0 0 0 1
feel 0 0 0 1
finally 0 0 0 1
flares 0 0 0 1
flashers 0 0 0 1
freeways 0 0 0 1
freezing 0 0 0 1
frightening 0 0 0 1
frozen 0 0 0 1
god 0 0 0 1
grandchildren 0 0 0 1
grapevine 0 0 0 1
headed 0 0 0 1
hours 0 0 0 1
hurried 0 0 0 1
husband 0 0 0 4
idea 0 0 0 1
intend 0 0 0 1
interstate 0 0 0 1
items 0 0 0 1
killed 0 0 0 1
know 0 0 0 1
large 0 0 0 1
later 0 0 0 1
left 0 0 0 2
meanwhile 0 0 0 1
middle 0 0 0 2
mile 0 0 0 1
multiple 0 0 0 1
near 0 0 0 1
nearly 0 0 0 1
needless 0 0 0 1
officer 0 0 0 2
oncoming 0 0 0 1
onto 0 0 0 1
opened 0 0 0 1
parked 0 0 0 1
passing 0 0 0 1
pitch 0 0 0 1
placed 0 0 0 1
practically 0 0 0 1
prayed 0 0 0 1
put 0 0 0 2
reimbursing 0 0 0 1
relieved 0 0 0 1
road 0 0 0 4
sake 0 0 0 1
sat 0 0 0 2
semi 0 0 0 1
several 0 0 0 1
shoulder 0 0 0 2
showed 0 0 0 1
situation 0 0 0 1
standing 0 0 0 1
state 0 0 0 1
stop 0 0 0 1
swerved 0 0 0 1
take 0 0 0 1
temperatures 0 0 0 1
thirty 0 0 0 1
tow 0 0 0 4
traffice 0 0 0 1
twenty 0 0 0 1
unsafe 0 0 0 1
vehicle 0 0 0 4
walked 0 0 0 1
waved 0 0 0 1
worst 0 0 0 1
viewmatrix <- as.matrix(tdm)

Comparision Wordcloud

Creates a comparision wordcloud the illustrates the most used term in each of the four documents. Insight & Analysis - “home depot” stands out in Malb, “truck” and “police” are significant in Read1, “damages” “insurance” and “roadway” in Read2, while “husband”, “two” and “vehicle” are the prominent terms in Baker.

comparison.cloud(viewmatrix)


Opinion Lexicons

Import Opinion Lexicons

opinion.lexicon.pos <- scan("positive-words.txt", what="character", comment.char = ";")

opinion.lexicon.neg <- scan("negative-words.txt", what="character", comment.char = ";")

Bag of Words

Creates a bag of words for each document in the corpus.

kable(corpus4 <- str_split(corpus2, pattern="\\s+"), "html", caption = "**Bag of Words**") %>%
  kable_styling() %>%
  scroll_box(width = "915px", height = "200px")
Bag of Words
ï
blood
inside
one
two
trucks
rented
reserved
two
trucks
one
reservations
got
lost
able
get
truck
another
location
picked
second
truck
noticed
dirty
time
thought
someone
hauling
tires
wasn
t
happy
needed
truck
loaded
clean
truck
first
loaded
dirty
truck
time
almost
dark
use
cargo
light
see
paid
intention
condition
truck
spots
thought
tires
loaded
missouri
took
new
mexico
unloaded
dirty
truck
morning
sun
coming
noticed
blood
stain
unloading
feet
truck
first
spot
nothing
compared
rest
truck
truck
literally
looked
like
massacre
happened
truck
truck
completely
unloaded
drove
straight
drop
happened
corporate
location
went
asking
manager
told
manager
needed
come
look
back
truck
loss
words
ended
talking
pictures
went
back
side
asked
truck
back
told
tomorrow
said
taken
care
flabbergasted
thought
call
police
atleast
get
rolling
crime
scene
didn
t
since
spent
last
six
months
trying
figure
exposed
sent
two
lab
reports
claimed
done
truck
police
first
lab
report
date
discrepancy
called
got
another
copy
report
time
conclusions
different
report
date
discrepancy
also
believe
reports
falsified
spent
last
six
months
wondering
contracted
something
biohazard
ï
made
penske
truck
rental
reservation
august
st
home
depot
help
daughter
move
one
apartment
another
since
first
making
reservation
early
august
received
two
calls
penske
one
shortly
making
reservation
confirm
get
credit
card
number
guarantee
show
second
august
th
confirm
still
planning
arrive
home
depot
agreed
time
next
day
wife
arrived
appointed
time
informed
home
depot
employees
rental
truck
available
informed
first
day
told
getting
rental
truck
either
fact
nine
others
told
thing
home
depot
employee
offered
call
penske
office
get
explanation
offer
accepted
person
framingham
ma
office
penske
say
name
sonny
wouldn
t
give
last
name
said
wasn
t
anything
booked
supplied
asked
hadn
t
called
earlier
inform
make
arrangements
offered
response
apparently
authorized
confirm
reservations
unable
meet
obligations
hanging
home
depot
employee
informed
us
penske
booked
significant
number
rental
reservations
day
done
intentionally
saying
common
busy
end
month
weekends
clear
planned
long
vehicles
roads
generating
income
negative
effects
strategy
consequence
penske
result
family
pleasant
far
reaching
effects
friends
family
entire
rain
soaked
labor
day
weekend
can
say
right
now
even
though
weekend
effects
penske
s
failure
meet
obligations
passed
negative
effects
just
beginning
penske
penske
will
never
ever
earn
business
long
live
will
tell
many
people
can
ever
business
effects
also
unfortunately
spilled
relationship
home
depot
minutes
prior
scheduled
pick
truck
rental
st
wife
purchased
two
rooms
carpeting
installation
order
since
cancelled
gone
lowes
likewise
time
choice
making
home
improvement
purchases
will
lowes
frankly
anyone
home
depot
years
wife
spent
k
home
depot
close
friends
immediate
relatives
will
may
ask
angry
home
depot
weren
t
ones
let
family
lurch
answer
simple
business
fact
known
company
keep
partnerships
make
truck
rental
display
home
depot
rental
center
proudly
boasts
partnership
penske
decision
today
cost
home
depot
good
deal
future
business
everyone
else
can
convince
avoid
post
consumer
affairs
beginning
hope
every
person
stood
past
weekend
time
past
penske
point
wise
person
home
depot
realizes
extent
partnership
penske
cost
financially
customer
loyalty
ï
wife
recently
married
decided
move
across
country
sonoma
ca
redwood
ny
closer
parents
really
issues
hitting
east
leaving
chicago
heading
early
morning
rush
hour
traffic
spotted
something
shining
roadway
cars
ahead
though
foot
truck
able
see
vehicles
move
either
lane
due
traffic
right
passed
object
see
piece
plexiglass
laying
flat
roadway
knowing
full
weel
going
happen
watched
horror
side
rear
view
mirror
sheer
mass
truck
created
draft
larrge
enough
pick
hurl
plexiglass
straight
wifes
car
directly
behind
came
spinning
bumper
grill
hood
luckily
piece
split
pefore
continuing
path
straight
front
windshield
pulled
inspect
damage
found
plexiglass
actually
hit
corner
first
bumper
lucky
alive
drove
straight
night
arrived
ny
upon
waking
next
morning
immediately
called
penske
told
damage
response
responsible
something
laying
roadway
asked
purchase
full
coverage
insurance
quote
includes
third
party
claims
wife
filing
claim
based
damage
caused
truck
response
ask
sir
don
t
cover
kind
thing
really
third
party
claim
covered
insurance
package
guess
outright
refusing
pay
damages
big
surprise
corperate
pig
screws
little
people
anyway
spent
morning
unloading
truck
find
mattress
box
spring
bed
soaked
laying
pool
water
back
truck
finished
emptying
truckand
took
back
drop
site
telling
incidents
gave
number
call
ask
see
bed
car
damages
hmmmmm
went
home
call
penske
told
cover
damages
long
send
pictures
receipt
bed
now
pics
big
deal
understandable
receipt
bed
years
old
h
l
receipt
conclusion
purchased
top
insurance
packag
yet
covering
none
damages
thanks
lot
penske
go
eff
splintered
log
ï
husband
rented
ft
truck
penske
bakersfield
ca
mile
grapevine
interstate
truck
came
abrupt
stop
middle
lane
husband
hurried
put
emergency
flashers
exit
vehicle
meanwhile
large
trucks
passing
right
cars
left
trying
avoid
hitting
us
got
shoulder
road
husband
called
alerted
chp
asked
tow
truck
sent
immediately
stood
degree
freezing
temperatures
waved
oncoming
traffice
avoid
hitting
truck
twenty
minutes
later
chp
officer
showed
parked
car
behind
rental
truck
placed
several
flares
road
stood
back
left
side
right
watched
horror
multiple
semi
trucks
cars
approached
vehicle
swerved
road
avoid
hitting
rental
truck
thirty
minutes
chp
officer
arrived
tow
truck
came
relieved
get
rental
truck
road
onto
shoulder
standing
cold
hours
practically
frozen
experiencing
worst
frightening
thing
ever
happened
us
finally
headed
home
tow
truck
asked
take
truck
penske
company
bakersfield
arrived
told
responsible
contents
truck
needless
say
point
penske
done
nothing
us
except
demand
pick
truck
s
contents
immediately
pm
far
know
still
intend
charging
us
truck
intention
reimbursing
us
items
broken
tow
manager
told
opened
back
truck
idea
everything
still
husband
nearly
killed
sat
vehicle
two
minutes
sat
prayed
god
die
sake
children
grandchildren
middle
lane
one
busiest
freeways
state
california
pitch
black
wondering
going
hit
behind
second
feel
put
unsafe
vehicle
lucky
walked
away
others
situation
may
lucky
bearing
differential
went
caused
near
fatal
accident
avoided
evelyn
bakersfield
california
u
s

Matches the bag of words to the positive lexicon of words. Doc1 = 3, Doc2 = 10, Doc3 = 5, Doc4 = 4.

lapply(corpus4, function(x) { sum(!is.na(match(x, opinion.lexicon.pos)))})
## [[1]]
## [1] 3
## 
## [[2]]
## [1] 10
## 
## [[3]]
## [1] 5
## 
## [[4]]
## [1] 4

Matches the bag of words to the negative lexicon of words. Doc1 = 10, Doc2 = 7, Doc3 = 12, Doc4 = 14

lapply(corpus4, function(x) { sum(!is.na(match(x, opinion.lexicon.neg)))})
## [[1]]
## [1] 10
## 
## [[2]]
## [1] 7
## 
## [[3]]
## [1] 12
## 
## [[4]]
## [1] 14

Calculates the sum totals of Positive sentiments vs negative sentiments in the corpus. Doc1 = -7, Doc2 = 3, Doc3 = -7, Doc4 = -10.

lapply(corpus4, function(x) { sum(!is.na(match(x, opinion.lexicon.pos))) - sum(!is.na(match(x, opinion.lexicon.neg)))})
## [[1]]
## [1] -7
## 
## [[2]]
## [1] 3
## 
## [[3]]
## [1] -7
## 
## [[4]]
## [1] -10

Sentiment Scores

Displays sentiment scores for each document in the corpus

scores <-unlist(lapply(corpus4, function(x) { sum(!is.na(match(x, opinion.lexicon.pos))) - sum(!is.na(match(x, opinion.lexicon.neg)))}))