knitr::opts_chunk$set(echo = TRUE)

Sample Survey Report

library(Text.Replace)
library(rprojroot)

# Example on the Survey Data
# data set located on another machine due to permissions

# Locate sample data in package and load relative to project root
root <- find_root(is_rstudio_project)

dest_All <- file.path(root, 'inst','extdata')

sample_data <- paste(dest_All, 'surveyData_2.csv', sep = "/")
sample_questions <- paste(dest_All, 'surveyQuestions.csv', sep = "/")
survey_questions <- readr::read_csv(sample_questions)

survey_corpus = Text.Replace::create_corpus(readr::read_csv(sample_data), "comments")

survey_dfm = Text.Replace:::create_dfm(survey_corpus,
                                     num_ngrams = 1:5,
                                     tolower = TRUE,
                                     stem = FALSE,
                                     select = NULL,
                                     remove = NULL,
                                     dictionary = NULL,
                                     thesaurus = NULL,
                                     groups = NULL,
                                     remove_punct = T)
survey_dfm_trim = quanteda::dfm_trim(survey_dfm[[1]], min_termfreq = 10)

# basic wordcloud of ngrams = 1
quanteda::textplot_wordcloud(survey_dfm_trim)



clawilso15/Text.Replace documentation built on Feb. 6, 2021, 5:45 a.m.