R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: NLP
## 
## 
## Attaching package: 'NLP'
## 
## 
## The following object is masked from 'package:ggplot2':
## 
##     annotate
## 
## 
## Loading required package: Matrix
## 
## 
## Attaching package: 'Matrix'
## 
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## 
## Attaching package: 'textmineR'
## 
## 
## The following object is masked from 'package:Matrix':
## 
##     update
## 
## 
## The following object is masked from 'package:stats':
## 
##     update
## 
## 
## 
## Attaching package: 'scales'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
## 
## 
## randomForest 4.7-1.1
## 
## Type rfNews() to see new features/changes/bug fixes.
## 
## 
## Attaching package: 'randomForest'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
## 
## 
## The following object is masked from 'package:ggplot2':
## 
##     margin
## 
## 
## 
## Attaching package: 'yardstick'
## 
## 
## The following object is masked from 'package:readr':
## 
##     spec
## Rows: 70,000
## Columns: 1
## $ text <chr> "why do i want a smartwatch now?", "Looking for a Samsung #smartw…
## <<VCorpus>>
## Metadata:  corpus specific: 0, document level (indexed): 0
## Content:  documents: 70000
## Loading required package: RColorBrewer

## <<DocumentTermMatrix (documents: 6, terms: 74658)>>
## Non-/sparse entries: 47/447901
## Sparsity           : 100%
## Maximal term length: 65
## Weighting          : term frequency (tf)
## A LDA_VEM topic model with 3 topics.
## # A tibble: 6 × 3
##   topic term           beta
##   <int> <chr>         <dbl>
## 1     1 – black 0.000000327
## 2     2 – black 0.00000301 
## 3     3 – black 0.00000426 
## 4     1 – cnet  0.0000134  
## 5     2 – cnet  0.00000166 
## 6     3 – cnet  0.00000775

## # A tibble: 223,974 × 3
##    topic term               beta
##    <int> <chr>             <dbl>
##  1     1 – black     0.000000327
##  2     2 – black     0.00000301 
##  3     3 – black     0.00000426 
##  4     1 – cnet      0.0000134  
##  5     2 – cnet      0.00000166 
##  6     3 – cnet      0.00000775 
##  7     1 – dipssi    0.00000125 
##  8     2 – dipssi    0.00000129 
##  9     3 – dipssi    0.00000126 
## 10     1 – eurojourn 0.00000144 
## # ℹ 223,964 more rows

References: Text Mining with R: A Tidy Approach. https://www.tidytextmining.com/. Learning Social Media Analytics with R, Oreilly - Free e-book (online access available at https: //library.csub.edu/). Course notes, Zhenning Jimmy Xu, https://bookdown.org/utjimmyx/marketing_research/ https://rpubs.com/utjimmyx