The goal of this project is to display that we’ve gotten used to working with the data and that we are on track to create the prediction algorithm.
The data comes from the Coursera Swiftkey dataset and contains text files collected from news, twitter and blogs.
summary<- readRDS( ".\\data\\Summary.RData")
print(summary)
## Twitter Blogs News
## File_Size "319 Mb" "255.4 Mb" "19.8 Mb"
## Line_Counts "2360148" "899288" "77259"
## Word_Counts "162096241" "206824505" "15639408"
In conclusion, the data size is very big and uses a lot of memory. To lower the usage, we will subset 10,000 randomly sampled lines.
The data will be processed through e.g. removing punctuaction, converting all letters to lowercase, word stemming, removing unnecessary white spaces, removing numbers, removing stop words e.g. a, an, the.
Using the processed data we can create a wordcloud which will show the most used words in the text files.
library(wordcloud)
## Warning: package 'wordcloud' was built under R version 4.3.2
## Loading required package: RColorBrewer
corpus <- readRDS(".\\data\\corpus.RData")
wordcloud(corpus, max.words=100, random.order=T, rot.per=0.15, colors=brewer.pal(8, 'Accent'))
## Loading required namespace: tm
To create a basis of the prediction model we will use the NGram function which determines the frequency of words (2 or more words in sequence).