R
Content Outline
Install the Webex Experience Management R SDK to get started.
Fetch Responses using R
library(cloudcherry)
{r, echo=FALSE, include= FALSE}
df = GetAnswers("yourusername", "yourpassword,
c("5b76ae7502dedf18082612c5", "5b76ae7502dedf18082612c4","5b87ceb1a02f260b2c0f58e6",
"5b87cea6a02f260b2c0f5544", "5b87ce9c693abf171097562a", "5b87ce8da02f260b2c0f4c6f",
"5b87ce7e693abf1710975347", "5b87ce49a02f260b2c0f3a23", "5b76ae91c474540e2c6b1f6c"),
"2016-05-31", "2018-08-30", 10000, T)
colnames(df) = c("Theme",
"Sentiment",
"Advice_quality",
"Understood_needs",
"Explanation",
"Communication",
"Enthusiasm",
"Friendliness",
"NPS")
N-Gram Word Vector Analysis
library(cloudcherry)
{R, include = F, echo = F}
comments_df = GetAnswers("yourusername", "yourpassword",
c("5b7be56502dedf1cbca94aa3"),
"2016-05-31", "2018-08-30", 10000, T)
library(tidyverse)
library(stringr)
library(tidytext)
series <- tibble()
clean <- tibble(text = comments_df) %>%
unnest_tokens(bigram, text, token = "ngrams", n = 2)
series <- rbind(series, clean)
series %>%
separate(bigram, c("word1", "word2"), sep = " ") %>%
filter(!word1 %in% stop_words$word,
!word2 %in% stop_words$word) %>%
count(word1, word2, sort = TRUE)
library(igraph)
(bigram_graph <- series %>%
separate(bigram, c("word1", "word2"), sep = " ") %>%
filter(!word1 %in% stop_words$word,
!word2 %in% stop_words$word) %>%
count(word1, word2, sort = TRUE) %>%
unite("bigram", c(word1, word2), sep = " ") %>%
filter(n > 150) %>%
graph_from_data_frame()
)
library(ggraph)
set.seed(123)
a <- grid::arrow(type = "closed", length = unit(.15, "inches"))
ggraph(bigram_graph, layout = "fr") +
geom_edge_link() +
geom_node_point(color = "lightblue", size = 5) +
geom_node_text(aes(label = name), vjust = 1, hjust = 1) +
theme_void()
Regression Plot
library(ggplot2, quietly = T)
ggplot(df, aes(x=Friendliness, y=NPS)) +
#geom_point(color='#2980B9', size = 4) +
geom_smooth(method=lm, color='#2C3E50')
Decision Tree
library(rpart, quietly = T)
library(rpart.plot, quietly = T)
dtCart = rpart(NPS ~ Advice_quality + Understood_needs + Explanation
+ Communication + Enthusiasm + Friendliness,data=df,method="anova", cp = 0.02)
plot(dtCart,main="Decision Tree for NPS",uniform=TRUE)
text(dtCart,cex = 0.7,use.n = TRUE,xpd =TRUE)