Introduction

The purpose of this report is to summarize my current progress on the Data Science Capstone project. Specifically, I will attempt to do the following:

Data

We begin by reading in the data (I used the “read_lines” function from the “readr” package) and viewing some summary statistics of the data, specifically word counts and line counts.

Word and line counts (blogs)

## [1] 37579923   899384

Word and line counts (news)

## [1] 34821445  1010371

Word and line counts (twitter)

## [1] 30194381  2360392

I then combined the files into a single corpus and subsetted the data into a random sample to make the data more manageable. My data set for analysis has about 43,000 elements, or roughly 1% of the original data.

summary(all_subset)
##       V1           
##  Length:42990      
##  Class :character  
##  Mode  :character

Exploratory Analysis

For my exploratory analysis, I used the “Quanteda” package. I examined 1-grams, 2-grams, and 3-grams to get a better sense of the data. The results of the exploratory analysis (tables of counts, word clouds) are shown below.

1-grams (with stop words)

##   the    to   and     a    of     i    in   for    is  that 
## 47863 27763 24286 23780 20396 16943 16686 10991 10899 10567

1-grams (without stop words)

## just said will  one like  can  get time  new  now 
## 3160 3129 3125 2889 2669 2555 2285 2183 2005 1875

2-grams

##  of_the  in_the  to_the for_the  on_the   to_be  at_the and_the    in_a 
##    4484    4088    2051    2039    1930    1653    1412    1293    1184 
##    is_a 
##     992

3-grams

##     one_of_the       a_lot_of thanks_for_the     out_of_the        to_be_a 
##            370            268            243            175            171 
##       it_was_a    going_to_be    some_of_the      i_want_to     the_end_of 
##            169            165            145            145            141

Next steps

My next step will be to build a predictive model using the training data and the n-grams above. I then plan to deploy the model into a Shiny app where a user can enter a phrase, and the model will predict the following words.