and performed wordcloud and # Sentimental analysis on the same.
library(rvest)
## Warning: package 'rvest' was built under R version 3.5.1
## Loading required package: xml2
## Warning: package 'xml2' was built under R version 3.5.1
library(XML)
## Warning: package 'XML' was built under R version 3.5.1
##
## Attaching package: 'XML'
## The following object is masked from 'package:rvest':
##
## xml
library(magrittr)
## Warning: package 'magrittr' was built under R version 3.5.1
library(tm)
## Warning: package 'tm' was built under R version 3.5.1
## Loading required package: NLP
## Warning: package 'NLP' was built under R version 3.5.1
library(wordcloud)
## Warning: package 'wordcloud' was built under R version 3.5.1
## Loading required package: RColorBrewer
library(wordcloud2)
library(syuzhet)
## Warning: package 'syuzhet' was built under R version 3.5.1
library(lubridate)
## Warning: package 'lubridate' was built under R version 3.5.1
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.1
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:NLP':
##
## annotate
library(scales)
## Warning: package 'scales' was built under R version 3.5.1
##
## Attaching package: 'scales'
## The following object is masked from 'package:syuzhet':
##
## rescale
library(reshape2)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.1
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:lubridate':
##
## intersect, setdiff, union
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# install.packages('devtools')
# devtools::install_github("lchiffon/wordcloud2")
# Amazon Reviews #############################
aurl <- "https://www.amazon.com/MSI-GT63-TITAN-052-Extreme-i7-8750H/product-reviews/B07CSFW5Y1/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews"
amazon_reviews <- NULL
for (i in 1:10){
murl <- read_html(as.character(paste(aurl,i,sep="=")))
rev <- murl %>%
html_nodes(".review-text") %>%
html_text()
amazon_reviews <- c(amazon_reviews,rev)
}
length(amazon_reviews)
## [1] 100
setwd("C:/Users/Thiru/Desktop/Assignments In Progress/Text Mining/Ecommerce Analysis")
write.table(amazon_reviews,"MSIGTGN.txt",row.names = F)
MSIGTGN_Lap <- read.delim('MSIGTGN.TXT')
str(MSIGTGN_Lap)
## 'data.frame': 100 obs. of 1 variable:
## $ x: Factor w/ 10 levels "Come bakc to review this computer after one-month using experience!For the computer itself, I would say it is t"| __truncated__,..: 10 7 4 9 8 2 3 5 6 1 ...
View(MSIGTGN_Lap)
# Build Corpus and DTM/TDM
library(tm)
corpus <- MSIGTGN_Lap[-1,]
head(corpus)
## [1] Really enjoying this laptop, sound and visual are great. First thing I did was play Dead by Daylight on it. Went off and murdered my friends and called it a day. Handled it very well, well the computer. My friends were not so happy. Highly recommend this laptop for someone who is a big gamer.
## [2] I was blown away by the amount of power this laptop has. Its like they managed to compress a desktop into a laptop. I ran all my games in Ultra and 60fps. The size is big normally because of the fans. Theres a button to acrivate fan boost. In matter of seconds it dramatically reduces your GPU and CPU' temp. This is product is holds very high standards in its performance and blows alot of competition in the market out of the water. It is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go. Only issue I have is the fans maybe a bit too loud, but honestly it isnt too distracting and can be overlooked.
## [3] The first laptop I received almost a week ago, the speakers did not work. I tried updating the drivers, uninstalling and reinstalling, I tried everything and only the headphone jack would work. So they sent me a replacement and I just received it today and right away the speakers work and so far everything is running very well. This is my replacement laptop for my old Alienware m17x r2, and to be honest I've never heard of MSI brand of laptops, it's always been Alienware/Dell/HP/Apple; and I was looking into the Alienware 17 R5 (they too now have individual color keys for the keyboard instead of their typical 4 zones) or the MacBook Pro 17 with the i9. Upon research and looking into reviews, I decided to give the MSI gt75 a try. This is my first mechanical keyboard which I could live with one or without but it is kind of fun to type with; and I really like that this laptop doesn't burn my legs while it's on my lap like my old Alienware does. I looked into the i9 4K model but since I'm not a real computer gamer, I didn't need it. FHD works perfectly fine for me and I don't have to have two massive power bricks. Be warned: If you drop the power brick on the floor, you'll most likely damage the floor!The added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects I could do. =)
## [4] So far this has been an amazing purchase. Love that the laptop doesn't get to hot as the cooling system has worked flawlessly thus far. The one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life. It last's maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop. Would recommend this to anyone looking for a great gaming comp on the go. If you are looking for a small compact laptop though that this is not, read the description first before purchase.
## [5] First of all if your looking for a small laptop this is not for you. Its big its bad and its bulky. But if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well, look no further. Boot up time is about 15 seconds from the moment you hit the power button thanks to the ssd. The colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past. The color keyboard is completely customizable, make any key any color, or turn off the lighting all together as well as many preset profiles to choose from. The only thing this laptop lacks is a dvd/cd rom drive. But thats easy enough to just get an external one. All i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you 7 years or so before it falls behind the times.
## [6] I had two issues with this machine. 1. First one was when Windows did an update, it somehow confused the software MSI had on the machine, something called Killer? I only got networking working again after using a Restore. 2. Now, in just two months, I now have lost my sound. After doing a machine reset it did not work and MSI gave me a return order yesterday. However, last night, while computer was in sleep mode, the sound returned. I suspect a windows update of some kind did this. Not sure if this is MSI or Microsoft's updates causing the issues. Changed my review from one star to three and if things keep working okay will update the rating again.
## 10 Levels: Come bakc to review this computer after one-month using experience!For the computer itself, I would say it is the best computer and also the most expensive one I have ever used.The durability is really good. Once I put my hands on it, I can feel the build-up quality is exactly the one I like. Steelseries keyboard makes me enjoy typing/working with it, although it is not a \\real\\ mechanical keyboard. The \\disco\\ mode lights up the whole computer in the dark. Great keyboard! The screen has a very broad visible range and it looks really big compare with my 12' macbook. I enjoy this high refresh rate screen when I am playing CSGO. Basically it can meet up all you need for gaming on a laotop so far. It runs smoothly under all hightest gaming settings. The audio sounds powerful. Just love it.However, the price of this computer is also in \\beast\\ level. $3000+ includes tax. And it is too heavy to carry it around. But what I need for this computer is just its performance, I set it at home like a desktop. It perfectly fits me. What makes my shopping experience a little bit worse is that the shipping date is delay. But I got a refund from Amazon. I do appreciate it!Overall my rating score for this computer is 4.5. I do love it. ...
class(corpus)
## [1] "factor"
corpus <- Corpus(VectorSource(corpus))
inspect(corpus[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] Really enjoying this laptop, sound and visual are great. First thing I did was play Dead by Daylight on it. Went off and murdered my friends and called it a day. Handled it very well, well the computer. My friends were not so happy. Highly recommend this laptop for someone who is a big gamer.
## [2] I was blown away by the amount of power this laptop has. Its like they managed to compress a desktop into a laptop. I ran all my games in Ultra and 60fps. The size is big normally because of the fans. Theres a button to acrivate fan boost. In matter of seconds it dramatically reduces your GPU and CPU' temp. This is product is holds very high standards in its performance and blows alot of competition in the market out of the water. It is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go. Only issue I have is the fans maybe a bit too loud, but honestly it isnt too distracting and can be overlooked.
## [3] The first laptop I received almost a week ago, the speakers did not work. I tried updating the drivers, uninstalling and reinstalling, I tried everything and only the headphone jack would work. So they sent me a replacement and I just received it today and right away the speakers work and so far everything is running very well. This is my replacement laptop for my old Alienware m17x r2, and to be honest I've never heard of MSI brand of laptops, it's always been Alienware/Dell/HP/Apple; and I was looking into the Alienware 17 R5 (they too now have individual color keys for the keyboard instead of their typical 4 zones) or the MacBook Pro 17 with the i9. Upon research and looking into reviews, I decided to give the MSI gt75 a try. This is my first mechanical keyboard which I could live with one or without but it is kind of fun to type with; and I really like that this laptop doesn't burn my legs while it's on my lap like my old Alienware does. I looked into the i9 4K model but since I'm not a real computer gamer, I didn't need it. FHD works perfectly fine for me and I don't have to have two massive power bricks. Be warned: If you drop the power brick on the floor, you'll most likely damage the floor!The added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects I could do. =)
## [4] So far this has been an amazing purchase. Love that the laptop doesn't get to hot as the cooling system has worked flawlessly thus far. The one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life. It last's maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop. Would recommend this to anyone looking for a great gaming comp on the go. If you are looking for a small compact laptop though that this is not, read the description first before purchase.
## [5] First of all if your looking for a small laptop this is not for you. Its big its bad and its bulky. But if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well, look no further. Boot up time is about 15 seconds from the moment you hit the power button thanks to the ssd. The colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past. The color keyboard is completely customizable, make any key any color, or turn off the lighting all together as well as many preset profiles to choose from. The only thing this laptop lacks is a dvd/cd rom drive. But thats easy enough to just get an external one. All i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you 7 years or so before it falls behind the times.
# Clean the text
corpus <- tm_map(corpus,tolower)
## Warning in tm_map.SimpleCorpus(corpus, tolower): transformation drops
## documents
inspect(corpus[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying this laptop, sound and visual are great. first thing i did was play dead by daylight on it. went off and murdered my friends and called it a day. handled it very well, well the computer. my friends were not so happy. highly recommend this laptop for someone who is a big gamer.
## [2] i was blown away by the amount of power this laptop has. its like they managed to compress a desktop into a laptop. i ran all my games in ultra and 60fps. the size is big normally because of the fans. theres a button to acrivate fan boost. in matter of seconds it dramatically reduces your gpu and cpu' temp. this is product is holds very high standards in its performance and blows alot of competition in the market out of the water. it is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go. only issue i have is the fans maybe a bit too loud, but honestly it isnt too distracting and can be overlooked.
## [3] the first laptop i received almost a week ago, the speakers did not work. i tried updating the drivers, uninstalling and reinstalling, i tried everything and only the headphone jack would work. so they sent me a replacement and i just received it today and right away the speakers work and so far everything is running very well. this is my replacement laptop for my old alienware m17x r2, and to be honest i've never heard of msi brand of laptops, it's always been alienware/dell/hp/apple; and i was looking into the alienware 17 r5 (they too now have individual color keys for the keyboard instead of their typical 4 zones) or the macbook pro 17 with the i9. upon research and looking into reviews, i decided to give the msi gt75 a try. this is my first mechanical keyboard which i could live with one or without but it is kind of fun to type with; and i really like that this laptop doesn't burn my legs while it's on my lap like my old alienware does. i looked into the i9 4k model but since i'm not a real computer gamer, i didn't need it. fhd works perfectly fine for me and i don't have to have two massive power bricks. be warned: if you drop the power brick on the floor, you'll most likely damage the floor!the added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects i could do. =)
## [4] so far this has been an amazing purchase. love that the laptop doesn't get to hot as the cooling system has worked flawlessly thus far. the one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life. it last's maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop. would recommend this to anyone looking for a great gaming comp on the go. if you are looking for a small compact laptop though that this is not, read the description first before purchase.
## [5] first of all if your looking for a small laptop this is not for you. its big its bad and its bulky. but if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well, look no further. boot up time is about 15 seconds from the moment you hit the power button thanks to the ssd. the colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past. the color keyboard is completely customizable, make any key any color, or turn off the lighting all together as well as many preset profiles to choose from. the only thing this laptop lacks is a dvd/cd rom drive. but thats easy enough to just get an external one. all i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you 7 years or so before it falls behind the times.
corpus <- tm_map(corpus,removePunctuation)
## Warning in tm_map.SimpleCorpus(corpus, removePunctuation): transformation
## drops documents
inspect(corpus[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying this laptop sound and visual are great first thing i did was play dead by daylight on it went off and murdered my friends and called it a day handled it very well well the computer my friends were not so happy highly recommend this laptop for someone who is a big gamer
## [2] i was blown away by the amount of power this laptop has its like they managed to compress a desktop into a laptop i ran all my games in ultra and 60fps the size is big normally because of the fans theres a button to acrivate fan boost in matter of seconds it dramatically reduces your gpu and cpu temp this is product is holds very high standards in its performance and blows alot of competition in the market out of the water it is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go only issue i have is the fans maybe a bit too loud but honestly it isnt too distracting and can be overlooked
## [3] the first laptop i received almost a week ago the speakers did not work i tried updating the drivers uninstalling and reinstalling i tried everything and only the headphone jack would work so they sent me a replacement and i just received it today and right away the speakers work and so far everything is running very well this is my replacement laptop for my old alienware m17x r2 and to be honest ive never heard of msi brand of laptops its always been alienwaredellhpapple and i was looking into the alienware 17 r5 they too now have individual color keys for the keyboard instead of their typical 4 zones or the macbook pro 17 with the i9 upon research and looking into reviews i decided to give the msi gt75 a try this is my first mechanical keyboard which i could live with one or without but it is kind of fun to type with and i really like that this laptop doesnt burn my legs while its on my lap like my old alienware does i looked into the i9 4k model but since im not a real computer gamer i didnt need it fhd works perfectly fine for me and i dont have to have two massive power bricks be warned if you drop the power brick on the floor youll most likely damage the floorthe added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects i could do
## [4] so far this has been an amazing purchase love that the laptop doesnt get to hot as the cooling system has worked flawlessly thus far the one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life it lasts maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop would recommend this to anyone looking for a great gaming comp on the go if you are looking for a small compact laptop though that this is not read the description first before purchase
## [5] first of all if your looking for a small laptop this is not for you its big its bad and its bulky but if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well look no further boot up time is about 15 seconds from the moment you hit the power button thanks to the ssd the colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past the color keyboard is completely customizable make any key any color or turn off the lighting all together as well as many preset profiles to choose from the only thing this laptop lacks is a dvdcd rom drive but thats easy enough to just get an external one all i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you 7 years or so before it falls behind the times
corpus <- tm_map(corpus,removeNumbers)
## Warning in tm_map.SimpleCorpus(corpus, removeNumbers): transformation drops
## documents
inspect(corpus[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying this laptop sound and visual are great first thing i did was play dead by daylight on it went off and murdered my friends and called it a day handled it very well well the computer my friends were not so happy highly recommend this laptop for someone who is a big gamer
## [2] i was blown away by the amount of power this laptop has its like they managed to compress a desktop into a laptop i ran all my games in ultra and fps the size is big normally because of the fans theres a button to acrivate fan boost in matter of seconds it dramatically reduces your gpu and cpu temp this is product is holds very high standards in its performance and blows alot of competition in the market out of the water it is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go only issue i have is the fans maybe a bit too loud but honestly it isnt too distracting and can be overlooked
## [3] the first laptop i received almost a week ago the speakers did not work i tried updating the drivers uninstalling and reinstalling i tried everything and only the headphone jack would work so they sent me a replacement and i just received it today and right away the speakers work and so far everything is running very well this is my replacement laptop for my old alienware mx r and to be honest ive never heard of msi brand of laptops its always been alienwaredellhpapple and i was looking into the alienware r they too now have individual color keys for the keyboard instead of their typical zones or the macbook pro with the i upon research and looking into reviews i decided to give the msi gt a try this is my first mechanical keyboard which i could live with one or without but it is kind of fun to type with and i really like that this laptop doesnt burn my legs while its on my lap like my old alienware does i looked into the i k model but since im not a real computer gamer i didnt need it fhd works perfectly fine for me and i dont have to have two massive power bricks be warned if you drop the power brick on the floor youll most likely damage the floorthe added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects i could do
## [4] so far this has been an amazing purchase love that the laptop doesnt get to hot as the cooling system has worked flawlessly thus far the one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life it lasts maybe a little over hours for me thus far but really that has been the only thing that i can say bad about this laptop would recommend this to anyone looking for a great gaming comp on the go if you are looking for a small compact laptop though that this is not read the description first before purchase
## [5] first of all if your looking for a small laptop this is not for you its big its bad and its bulky but if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well look no further boot up time is about seconds from the moment you hit the power button thanks to the ssd the colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past the color keyboard is completely customizable make any key any color or turn off the lighting all together as well as many preset profiles to choose from the only thing this laptop lacks is a dvdcd rom drive but thats easy enough to just get an external one all i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you years or so before it falls behind the times
corpus_clean<-tm_map(corpus,stripWhitespace)
## Warning in tm_map.SimpleCorpus(corpus, stripWhitespace): transformation
## drops documents
inspect(corpus[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying this laptop sound and visual are great first thing i did was play dead by daylight on it went off and murdered my friends and called it a day handled it very well well the computer my friends were not so happy highly recommend this laptop for someone who is a big gamer
## [2] i was blown away by the amount of power this laptop has its like they managed to compress a desktop into a laptop i ran all my games in ultra and fps the size is big normally because of the fans theres a button to acrivate fan boost in matter of seconds it dramatically reduces your gpu and cpu temp this is product is holds very high standards in its performance and blows alot of competition in the market out of the water it is the perfect blend for hardcore gaming enthusiast and people who are constantly on the go only issue i have is the fans maybe a bit too loud but honestly it isnt too distracting and can be overlooked
## [3] the first laptop i received almost a week ago the speakers did not work i tried updating the drivers uninstalling and reinstalling i tried everything and only the headphone jack would work so they sent me a replacement and i just received it today and right away the speakers work and so far everything is running very well this is my replacement laptop for my old alienware mx r and to be honest ive never heard of msi brand of laptops its always been alienwaredellhpapple and i was looking into the alienware r they too now have individual color keys for the keyboard instead of their typical zones or the macbook pro with the i upon research and looking into reviews i decided to give the msi gt a try this is my first mechanical keyboard which i could live with one or without but it is kind of fun to type with and i really like that this laptop doesnt burn my legs while its on my lap like my old alienware does i looked into the i k model but since im not a real computer gamer i didnt need it fhd works perfectly fine for me and i dont have to have two massive power bricks be warned if you drop the power brick on the floor youll most likely damage the floorthe added bonus of having the colorful back lit keyboard with the ability to program it in so many different color combinations is one of my favorite things about the computer and i can spend hours just playing with they keyboard and all the different effects i could do
## [4] so far this has been an amazing purchase love that the laptop doesnt get to hot as the cooling system has worked flawlessly thus far the one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life it lasts maybe a little over hours for me thus far but really that has been the only thing that i can say bad about this laptop would recommend this to anyone looking for a great gaming comp on the go if you are looking for a small compact laptop though that this is not read the description first before purchase
## [5] first of all if your looking for a small laptop this is not for you its big its bad and its bulky but if your looking for a potent gaming rig you can pack up and take to a friends house or out and about that delivers stunning graphics well look no further boot up time is about seconds from the moment you hit the power button thanks to the ssd the colors and graphics produced by the display and gpu are incredible to say the least the depth of color makes games ive played before look more stunning than they did in the past the color keyboard is completely customizable make any key any color or turn off the lighting all together as well as many preset profiles to choose from the only thing this laptop lacks is a dvdcd rom drive but thats easy enough to just get an external one all i can say at this point is the pricetag on this machine may be a bit steep but this is a rig that is going to last you years or so before it falls behind the times
cleanset<-tm_map(corpus,removeWords, stopwords('english'))
## Warning in tm_map.SimpleCorpus(corpus, removeWords, stopwords("english")):
## transformation drops documents
inspect(cleanset[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying laptop sound visual great first thing play dead daylight went murdered friends called day handled well well computer friends happy highly recommend laptop someone big gamer
## [2] blown away amount power laptop like managed compress desktop laptop ran games ultra fps size big normally fans theres button acrivate fan boost matter seconds dramatically reduces gpu cpu temp product holds high standards performance blows alot competition market water perfect blend hardcore gaming enthusiast people constantly go issue fans maybe bit loud honestly isnt distracting can overlooked
## [3] first laptop received almost week ago speakers work tried updating drivers uninstalling reinstalling tried everything headphone jack work sent replacement just received today right away speakers work far everything running well replacement laptop old alienware mx r honest ive never heard msi brand laptops always alienwaredellhpapple looking alienware r now individual color keys keyboard instead typical zones macbook pro upon research looking reviews decided give msi gt try first mechanical keyboard live one without kind fun type really like laptop doesnt burn legs lap like old alienware looked k model since im real computer gamer didnt need fhd works perfectly fine dont two massive power bricks warned drop power brick floor youll likely damage floorthe added bonus colorful back lit keyboard ability program many different color combinations one favorite things computer can spend hours just playing keyboard different effects
## [4] far amazing purchase love laptop doesnt get hot cooling system worked flawlessly thus far one big glaring thing can say far reviews correct bad battery life lasts maybe little hours thus far really thing can say bad laptop recommend anyone looking great gaming comp go looking small compact laptop though read description first purchase
## [5] first looking small laptop big bad bulky looking potent gaming rig can pack take friends house delivers stunning graphics well look boot time seconds moment hit power button thanks ssd colors graphics produced display gpu incredible say least depth color makes games ive played look stunning past color keyboard completely customizable make key color turn lighting together well many preset profiles choose thing laptop lacks dvdcd rom drive thats easy enough just get external one can say point pricetag machine may bit steep rig going last years falls behind times
removeURL <- function(x) gsub('http[[:alnum:]]*','',x)
cleanset <- tm_map(cleanset, content_transformer(removeURL))
## Warning in tm_map.SimpleCorpus(cleanset, content_transformer(removeURL)):
## transformation drops documents
inspect(cleanset[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying laptop sound visual great first thing play dead daylight went murdered friends called day handled well well computer friends happy highly recommend laptop someone big gamer
## [2] blown away amount power laptop like managed compress desktop laptop ran games ultra fps size big normally fans theres button acrivate fan boost matter seconds dramatically reduces gpu cpu temp product holds high standards performance blows alot competition market water perfect blend hardcore gaming enthusiast people constantly go issue fans maybe bit loud honestly isnt distracting can overlooked
## [3] first laptop received almost week ago speakers work tried updating drivers uninstalling reinstalling tried everything headphone jack work sent replacement just received today right away speakers work far everything running well replacement laptop old alienware mx r honest ive never heard msi brand laptops always alienwaredellhpapple looking alienware r now individual color keys keyboard instead typical zones macbook pro upon research looking reviews decided give msi gt try first mechanical keyboard live one without kind fun type really like laptop doesnt burn legs lap like old alienware looked k model since im real computer gamer didnt need fhd works perfectly fine dont two massive power bricks warned drop power brick floor youll likely damage floorthe added bonus colorful back lit keyboard ability program many different color combinations one favorite things computer can spend hours just playing keyboard different effects
## [4] far amazing purchase love laptop doesnt get hot cooling system worked flawlessly thus far one big glaring thing can say far reviews correct bad battery life lasts maybe little hours thus far really thing can say bad laptop recommend anyone looking great gaming comp go looking small compact laptop though read description first purchase
## [5] first looking small laptop big bad bulky looking potent gaming rig can pack take friends house delivers stunning graphics well look boot time seconds moment hit power button thanks ssd colors graphics produced display gpu incredible say least depth color makes games ive played look stunning past color keyboard completely customizable make key color turn lighting together well many preset profiles choose thing laptop lacks dvdcd rom drive thats easy enough just get external one can say point pricetag machine may bit steep rig going last years falls behind times
cleanset<-tm_map(cleanset,removeWords, c('laptop','can'))
## Warning in tm_map.SimpleCorpus(cleanset, removeWords, c("laptop", "can")):
## transformation drops documents
# Since the word Laptop and can is used more, this can be removed as we are
# mining the tweets for this laptop only.Also the word "Can" is common english word.
# we can pull back the word "can" if needed.
cleanset <- tm_map(cleanset, gsub,pattern = 'computer', replacement = 'machine')
## Warning in tm_map.SimpleCorpus(cleanset, gsub, pattern = "computer",
## replacement = "machine"): transformation drops documents
# the barplot pulls both Computer and Machine as separate words. this should be
# counted as one as both holds the same synonym.
inspect(cleanset[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying sound visual great first thing play dead daylight went murdered friends called day handled well well machine friends happy highly recommend someone big gamer
## [2] blown away amount power like managed compress desktop ran games ultra fps size big normally fans theres button acrivate fan boost matter seconds dramatically reduces gpu cpu temp product holds high standards performance blows alot competition market water perfect blend hardcore gaming enthusiast people constantly go issue fans maybe bit loud honestly isnt distracting overlooked
## [3] first received almost week ago speakers work tried updating drivers uninstalling reinstalling tried everything headphone jack work sent replacement just received today right away speakers work far everything running well replacement old alienware mx r honest ive never heard msi brand laptops always alienwaredellhpapple looking alienware r now individual color keys keyboard instead typical zones macbook pro upon research looking reviews decided give msi gt try first mechanical keyboard live one without kind fun type really like doesnt burn legs lap like old alienware looked k model since im real machine gamer didnt need fhd works perfectly fine dont two massive power bricks warned drop power brick floor youll likely damage floorthe added bonus colorful back lit keyboard ability program many different color combinations one favorite things machine spend hours just playing keyboard different effects
## [4] far amazing purchase love doesnt get hot cooling system worked flawlessly thus far one big glaring thing say far reviews correct bad battery life lasts maybe little hours thus far really thing say bad recommend anyone looking great gaming comp go looking small compact though read description first purchase
## [5] first looking small big bad bulky looking potent gaming rig pack take friends house delivers stunning graphics well look boot time seconds moment hit power button thanks ssd colors graphics produced display gpu incredible say least depth color makes games ive played look stunning past color keyboard completely customizable make key color turn lighting together well many preset profiles choose thing lacks dvdcd rom drive thats easy enough just get external one say point pricetag machine may bit steep rig going last years falls behind times
cleanset <- tm_map(cleanset,stripWhitespace)
## Warning in tm_map.SimpleCorpus(cleanset, stripWhitespace): transformation
## drops documents
inspect(cleanset[1:5])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 5
##
## [1] really enjoying sound visual great first thing play dead daylight went murdered friends called day handled well well machine friends happy highly recommend someone big gamer
## [2] blown away amount power like managed compress desktop ran games ultra fps size big normally fans theres button acrivate fan boost matter seconds dramatically reduces gpu cpu temp product holds high standards performance blows alot competition market water perfect blend hardcore gaming enthusiast people constantly go issue fans maybe bit loud honestly isnt distracting overlooked
## [3] first received almost week ago speakers work tried updating drivers uninstalling reinstalling tried everything headphone jack work sent replacement just received today right away speakers work far everything running well replacement old alienware mx r honest ive never heard msi brand laptops always alienwaredellhpapple looking alienware r now individual color keys keyboard instead typical zones macbook pro upon research looking reviews decided give msi gt try first mechanical keyboard live one without kind fun type really like doesnt burn legs lap like old alienware looked k model since im real machine gamer didnt need fhd works perfectly fine dont two massive power bricks warned drop power brick floor youll likely damage floorthe added bonus colorful back lit keyboard ability program many different color combinations one favorite things machine spend hours just playing keyboard different effects
## [4] far amazing purchase love doesnt get hot cooling system worked flawlessly thus far one big glaring thing say far reviews correct bad battery life lasts maybe little hours thus far really thing say bad recommend anyone looking great gaming comp go looking small compact though read description first purchase
## [5] first looking small big bad bulky looking potent gaming rig pack take friends house delivers stunning graphics well look boot time seconds moment hit power button thanks ssd colors graphics produced display gpu incredible say least depth color makes games ive played look stunning past color keyboard completely customizable make key color turn lighting together well many preset profiles choose thing lacks dvdcd rom drive thats easy enough just get external one say point pricetag machine may bit steep rig going last years falls behind times
#Term Document Matrix :
# Convert the unstructured data to structured data :
tdm <- TermDocumentMatrix(cleanset)
tdm
## <<TermDocumentMatrix (terms: 415, documents: 99)>>
## Non-/sparse entries: 5427/35658
## Sparsity : 87%
## Maximal term length: 20
## Weighting : term frequency (tf)
# the terms indicate that there are 5973 words and 39262 documents(# of tweets) in this TDM
# Sparsity is 87% which indicates that there are lots of zero values.
tdm <- as.matrix(tdm)
tdm[1:10,1:20]
## Docs
## Terms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## big 1 1 0 1 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0
## called 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
## day 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## daylight 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## dead 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## enjoying 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
## first 1 0 2 1 1 1 0 0 0 0 1 0 2 1 1 1 0 0 0 0
## friends 2 0 0 0 1 0 0 0 0 0 2 0 0 0 1 0 0 0 0 0
## gamer 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
## great 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 1 1 0
# Bar Plot
w <- rowSums(tdm) # provides the no of times a particular word has been used.
w <- subset(w, w>= 25) # Pull words that were used more than 25 times.
barplot(w, las = 2, col = rainbow(50))

# the word Machine as the highest frequency. This implies
# that MSI_Laptop has got more reviews about the Machine's performance or
# battery or about their specifications.
# Word Cloud :
library(wordcloud)
w <- sort(rowSums(tdm), decreasing = TRUE) # Sort words in decreasing order.
set.seed(123)
wordcloud(words = names(w), freq = w,
max.words = 250,random.order = F,
min.freq = 3,
colors = brewer.pal(8, 'Dark2'),
scale = c(5,0.3),
rot.per = 0.6)
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : networking could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : reason could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : awesome could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : touchpad could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : buildup could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : durability could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : exactly could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : experiencefor could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : hands could not be fit on page. It will not be plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : heavy could not be fit on page. It will not be plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : includes could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : itoverall could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : laotop could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : lights could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : powerful could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : price could not be fit on page. It will not be plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : refund could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : runs could not be fit on page. It will not be plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : shopping could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : typingworking could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : usedthe could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : visible could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = names(w), freq = w, max.words = 250,
## random.order = F, : worse could not be fit on page. It will not be plotted.

library(wordcloud2)
w <- data.frame(names(w),w)
colnames(w) <- c('word','freq')
wordcloud2(w,size = 0.5, shape = 'triangle', rotateRatio = 0.5, minSize = 1)
# lettercloud
letterCloud(w,word = 'Am',frequency(5), size=1)
# Sentiment Analysis for tweets:
library(syuzhet)
library(lubridate)
library(ggplot2)
library(scales)
library(reshape2)
library(dplyr)
# install.packages("syuzhet")
# Read File
Amzn_reviews <- read.delim('MSIGTGN.TXT')
reviews <- as.character(Amzn_reviews[-1,])
class(reviews)
## [1] "character"
# Obtain Sentiment scores
s <- get_nrc_sentiment(reviews)
## Warning: package 'bindrcpp' was built under R version 3.5.1
head(s)
## anger anticipation disgust fear joy sadness surprise trust negative
## 1 0 2 0 0 2 0 0 3 0
## 2 2 4 0 0 2 0 1 2 2
## 3 2 3 2 2 5 2 2 4 1
## 4 4 0 1 1 1 1 0 3 4
## 5 2 1 1 1 0 1 0 2 3
## 6 1 1 0 2 2 2 0 3 3
## positive
## 1 3
## 2 2
## 3 9
## 4 2
## 5 2
## 6 3
reviews[4]
## [1] "So far this has been an amazing purchase. Love that the laptop doesn't get to hot as the cooling system has worked flawlessly thus far. The one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life. It last's maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop. Would recommend this to anyone looking for a great gaming comp on the go. If you are looking for a small compact laptop though that this is not, read the description first before purchase."
# "So far this has been an amazing purchase. Love that the laptop doesn't get to hot as the cooling system has worked flawlessly thus far. The one big glaring thing that i can say so far is that the reviews were very correct about the bad battery life. It last's maybe a little over 2 hours for me thus far but really that has been the only thing that i can say bad about this laptop. Would recommend this to anyone looking for a great gaming comp on the go. If you are looking for a small compact laptop though that this is not, read the description first before purchase.
# on tweet 4, you have 4 for anger, each one work for disgust, fear
# and sadness, 3 for trust , 4 words for negative and 2 positive.
get_nrc_sentiment('Love')
## anger anticipation disgust fear joy sadness surprise trust negative
## 1 0 0 0 0 1 0 0 0 0
## positive
## 1 1
# Love has one Joy and one positive
get_nrc_sentiment('glaring') #1 Anger and 1 Negavite
## anger anticipation disgust fear joy sadness surprise trust negative
## 1 1 0 0 0 0 0 0 0 1
## positive
## 1 0
# it has a bad battery life
# barplot
barplot(colSums(s), las = 2.5, col = rainbow(10),
ylab = 'Count',main= 'Sentiment scores for Amazon Reviews
-MSI GT63 TITAN Gaming Laptop')
