SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
RForcecom: An R package which
provides a connection to Force.com
and Salesforce.com
Takekatsu Hiramura
2014-07-02
The R User Conference 2014 @ UCLA
1
Agenda
2
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
Agenda
3
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
Takekatsu Hiramura
» IT consultant, Software Engineer and Data scientist
» Private website:
http://thira.plavox.info/
» Blog:
http://hiratake55.wordpress.com/
» R-bloggers:
http://www.r-bloggers.com/author/takekatsu-hiramura/
4
Agenda
5
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
Specific features of CRM
About Salesforce.com/Force.com
6
» “Salesforce.com “ is one of the most famous SaaS (Software-as-a-Service)
based CRM (Customer Relationship Management) service.
» “Force.com” is a application platform of Salesforce.com, and it specifically
called PaaS (Platform-as-a-Service).
Campaign
Management
Contract
Management
Customer
Management
Product
Management
and etc.
Sales
Forecasting
Case
Management
Overview of the Application/Service Architecture
Application Platform
Service
Custom Object
Apex /
VisualForce
Web API
and etc.
Agenda
7
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
The RForcecom package
I developed an R package “RForcecom” which provides a connection to
Salesforce.com and Force.com via REST API.
8
 Statistical Analysis
 Machine Learning
 Data Manipulation
 Visualization
 Customer Relationship
Management
 Dashboard
 Collaboration Platform
(Chatter,Schedule,ToDo etc.)
RSalesforce.com
Delete
Insert
Update/Upsert
Data extract
SOQL query
Search
The CRAN page of the RForcecom
9
http://cran.r-project.org/web/packages/RForcecom/
Source code is available on GitHub
10
https://github.com/hiratake55/RForcecom
Agenda
11
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
Features of RForcecom
Execute a SOSL rforcecom.search()
Create a record rforcecom.create()
Retrieve record rforcecom.retrieve()
Update a record rforcecom.update()
Upsert a record rforcecom.upsert()
Delete a record rforcecom.delete()
Retrieve a server timestamp rforcecom.getServerTimestamp()
Execute a SOQL rforcecom.query()
Sign in to the Force.com rforcecom.login()
Feature Function name#
Retrieve object descriptions rforcecom.getObjectDescription()
Retrieve a list of objects rforcecom.getObjectList
8
2
3
4
5
6
11
7
1
10
9
12
Sign in to the Force.com
13
> library(RForcecom)
> username <- yourname@yourcompany.com
> password <- "YourPasswordSECURITY_TOKEN”
> instanceURL <- https://xxx.salesforce.com/
> apiVersion <- "26.0“
> session <- rforcecom.login(username, password, instanceURL, apiVersion)
Retrieve records
14
> objectName <- "Case"
> fields <- c("CaseNumber", "Subject", "Status")
> rforcecom.retrieve(session, objectName, fields, order=c("CaseNumber"),limit=12)
Salesforce.com R
Execute a SOQL
> soqlQuery <- "SELECT Id, Name, Industry FROM Account order by CreatedDate"
> rforcecom.query(session, soqlQuery)
15
Salesforce.com R
Agenda
16
1. About me
2. Brief introduction of Force.com and Salesforce.com
3. Overview of RForcecom
4. Features of RForcecom
5. Example of the analysis using RForcecom
-Visualizing consumers’ voice-
RForcecom demo : Visualizing consumers’ voice
» Assume you are a manager at a company and want to know the
consumers’ voice from CRM. Consumers’ voices are stored in
Salesforce.com which registered by their call center staff.
17
Call Center Salesforce.com R Managers
Data collection/
Operation
Data
Management
Data Analysis Reporting
Customer
Mgmt.
Case Mgmt.
REST/SOAP
API
API Client
(RForcecom)
NLP
(TreeTagger)
Visualization
(Wordcloud)
…
…
Sample Dataset:
Delta’s Twitter Social Customer Support Account
» It is difficult to use actual dataset, so I crawled Delta Airline’s Twitter
account (@DeltaAssist)and stored tweets to Salesforce.com instead
of actual dataset.
18
https://twitter.com/DeltaAssist/with_replies
Step 1: Retrieving a dataset from Salesforce.com
» Tweets sent to @DeltaAssist are stored in Salesforce.com.
19
Step 1: Retrieving a dataset from Salesforce.com
» Tweets sent to @DeltaAssist are stored in Salesforce.com.
20
Step 1: Retrieving a dataset from Salesforce.com
» Load required libraries and sign into Salesforce.com.
21
> library(RForcecom)
> username <- yourname@yourcompany.com
> password <- "YourPasswordSECURITY_TOKEN”
> instanceURL <- https://xxx.salesforce.com/
> apiVersion <- "26.0“
> session <- rforcecom.login(username, password, instanceURL, apiVersion)
Step 1: Retrieving a dataset from Salesforce.com
» To retrieve dataset with parameters of objectname and field names.
22
> CustomerVoice <-rforcecom.retrieve(session,"CustomerVoice__c",c("TweetDate__c","Tweet__c"))
> head(CustomerVoice$Tweet__c,10)
Step 2: Extracting high-frequency keywords
23
> library(koRpus)
> temp.file.name<-tempfile()
> write.table(CustomerVoice$Tweet__c,temp.file.name,col.names=F,row.names=F)
> tagged<-treetag(temp.file.name, lang="en",
treetagger="manual",TT.options=list(path="C:/Apps/TreeTagger", preset="en",encoding="UTF-8"))
> tagged.DF<-tagged@TT.res
> head(tagged.DF,10)
» Tag the word class for each words using “koRpus“ package and TreeTagger.
Step 2: Extracting high-frequency keywords
24
> term<-tagged.DF[tagged.DF$wclass=="noun",]$token
> term<-tolower(term)
> head(term,20)
» Filter “noun” from tagged list
Step 2: Extracting high-frequency keywords
25
> term.unique<-unique(term)
> term.freq <- unlist(lapply(term.unique,function(x){length(term[term==x])}))
> termfreq<-data.frame(term=term.unique, freq=term.freq)
> termfreq<-termfreq[order(termfreq$freq,decreasing=T),]
> head(termfreq,10)
» Count frequencies of the terms.
Step 3: Visualizing the words as a word cloud
26
> library(wordcloud)
> termfreq.top<-head(termfreq, n=100)
> pal <- brewer.pal(8, "Dark2")
> windowsFonts(SegoeUI = "Segoe UI")
> wordcloud(termfreq.top$term, termfreq.top$freq, random.color=T, colors=pal, family="SegoeUI")
» Visualize the terms using wordcloud package. “Flight” is the most frequent.
Step 4: Visualize the Buzz-word of the day
27
> CustomerVoice.sun<- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-25T00:00:00-04:00and TweetDate__c < 2014-05-26T00:00:00-04:00")
> CustomerVoice.mon <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-26T00:00:00-04:00and TweetDate__c < 2014-05-27T00:00:00-04:00")
> CustomerVoice.tue <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-27T00:00:00-04:00and TweetDate__c < 2014-05-28T00:00:00-04:00")
> CustomerVoice.wed <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-28T00:00:00-04:00and TweetDate__c < 2014-05-29T00:00:00-04:00")
> CustomerVoice.thu <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-29T00:00:00-04:00and TweetDate__c < 2014-05-30T00:00:00-04:00")
> CustomerVoice.fri <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-30T00:00:00-04:00and TweetDate__c < 2014-05-31T00:00:00-04:00")
> CustomerVoice.sat<- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c
where TweetDate__c >= 2014-05-31T00:00:00-04:00and TweetDate__c < 2014-06-01T00:00:00-04:00")
> CustomerVoice.all <- rbind(CustomerVoice.sun, CustomerVoice.mon, CustomerVoice.tue,
CustomerVoice.wed, CustomerVoice.thu, CustomerVoice.fri, CustomerVoice.sat)
» Retreive daily datasets by SOQL.
Step 4: Visualize the Buzz-word of the day
28
# Tag, Extract noun, Calculate TF
make.treetag<-function(CustomerVoice){
temp.file.name<-tempfile()
write.table(CustomerVoice$Tweet__c,temp.file.name,col.names=F,row.names=F)
tagged<-treetag(temp.file.name, lang="en", treetagger="manual",TT.options=list(path="C:/Apps/TreeTagger",
preset="en",encoding="UTF-8"))
tagged.DF<-tagged@TT.res
# Extract noun, To lower
term<-tagged.DF[tagged.DF$wclass=="noun",]$token
term<-tolower(term)
# Count frequency of term
term.unique<-unique(term)
term.freq <- unlist(lapply(term.unique,function(x){length(term[term==x])}))
termfreq.DF<-data.frame(term=term.unique, freq=term.freq, stringsAsFactors=F)
termfreq.DF<-termfreq.DF[order(termfreq.DF$freq,decreasing=T),]
return(termfreq.DF)
}
# Apply to each dataset
termfreq.sun<-make.treetag(CustomerVoice.sun)
termfreq.mon<-make.treetag(CustomerVoice.mon)
termfreq.tue<-make.treetag(CustomerVoice.tue)
termfreq.wed<-make.treetag(CustomerVoice.wed)
termfreq.thu<-make.treetag(CustomerVoice.thu)
termfreq.fri<-make.treetag(CustomerVoice.fri)
termfreq.sat<-make.treetag(CustomerVoice.sat)
termfreq.all<-make.treetag(CustomerVoice.all)
» Tag, extract noun and calculate the Term Frequency (TF).
*TF (Term Frequency):
number of occurrence of term i in document j
29
Step 4: Visualize the Buzz-word of the day
# Calculate IDF
IDF.documents <- sapply(termfreq.all$term,function(x){
sum(
nrow(termfreq.sun[termfreq.sun$term==x,])>0,
nrow(termfreq.mon[termfreq.mon$term==x,])>0,
nrow(termfreq.tue[termfreq.tue$term==x,])>0,
nrow(termfreq.wed[termfreq.wed$term==x,])>0,
nrow(termfreq.thu[termfreq.thu$term==x,])>0,
nrow(termfreq.fri[termfreq.fri$term==x,])>0,
nrow(termfreq.sat[termfreq.sat$term==x,])>0
)
})
IDF<-data.frame(term=termfreq.all$term,IDF=log(7/IDF.documents))
» Calculate the Inverse Document Frequency (IDF).
*IDF (Inverse Document Frequency):
IDF measures “Term specificity”.
df: number of documents containing term i.
N: Total Number of documents
Reference: http://dovgalecs.com/blog/matlab-simple-tf-idf/
IDF=
Step 4: Visualize the Buzz-word of the day
30
# Calculate TF and returns TF-IDF
calc.tfidf <- function(termfreq){
# TF
termfreq$TF <- termfreq$freq/sum(termfreq$freq)
# TF-IDF
tfidf.val <- lapply(termfreq$term,function(x){
tf_i <- termfreq[termfreq$term==x,]$TF
idf_i <- IDF[IDF$term==x,]$IDF
return(tf_i * idf_i)
})
tdidf <- data.frame(term=termfreq$term, TFIDF=unlist(tfidf.val))
return(tdidf)
}
tfidf.sun <- calc.tfidf(termfreq.sun)
tfidf.mon <- calc.tfidf(termfreq.mon)
tfidf.tue <- calc.tfidf(termfreq.tue)
tfidf.wed <- calc.tfidf(termfreq.wed)
tfidf.thu <- calc.tfidf(termfreq.thu)
tfidf.fri <- calc.tfidf(termfreq.fri)
tfidf.sat <- calc.tfidf(termfreq.sat)
» Calculate the TF-IDF of each dataset.
*TF-IDF
(Term Frequency–Inverse Document Frequency):
TF-IDF measures how important a word is in a
document.
TF-IDF = TF × IDF
Step 4: Visualize the Buzz-word of the day
31
# Wordcloud
draw.wordcloud<- function(tfidf,title=""){
png.filename <- paste("wordcloud-", title,".png", sep="")
png(png.filename,width=7,height=7,units="in", res=600)
tfidf <- tfidf[order(tfidf$TFIDF, decreasing=T),]
tfidf.head <- head(tfidf, n=100) # Extract to 100 terms
par(oma = c(0, 1, 2, 1)) # Set margin
pal <- brewer.pal(8, "Dark2")
wordcloud(tfidf.head$term,tfidf.head$TFIDF,random.color=T,colors=pal,main=title) # Plot Wordcloud
par(oma = c(0, 0, 0, 0)) # Unset Margin
title(title) # Add Title
dev.off() # Close File
}
# Plot Wordcloudfor each dataset
draw.wordcloud(tfidf.sun,title="2014-05-25(Sun)")
draw.wordcloud(tfidf.mon,title="2014-05-26(Mon)")
draw.wordcloud(tfidf.tue,title="2014-05-27(Tue)")
draw.wordcloud(tfidf.wed,title="2014-05-28(Wed)")
draw.wordcloud(tfidf.thu,title="2014-05-29(Thu)")
draw.wordcloud(tfidf.fri,title="2014-05-30(Fri)")
draw.wordcloud(tfidf.sat,title="2014-05-31(Sat)")
» Output word clouds as PNG format.
Step 4: Visualize the Buzz-word of the day
» These wordclouds are describing the trends of the day.
32
Step 4: Visualize the Buzz-word of the day
» These wordclouds are describing the trends of the day.
wordcloud of a Sunday
 There are specific location such
as “Vancouver”, “Boston” and
“Phoenix”.
 It seems that this day has more
questions about a route or a
booking than other days or
troubles that happened in
specific airport.
33
Step 4: Visualize the Buzz-word of the day
» These wordclouds are describing the trends of the day.
wordcloud of a Thursday
 The words “seatback”, “pain”
and ”captains” appeared in the
word cloud.
 It seems that there are troubles
with the fleet, cabin or in-flight
service somewhere.
34
Step 4: Visualize the Buzz-word of the day
» These wordclouds are describing the trends of the day.
Wordcloud of a Friday
 There are words : “award” and
“platinum”.
 It seems that this day has more
questions about frequent flyer
program than a normal day.
35
Conclusion
36
» I told a brief introduction of SaaS-Based CRM “Salesforce.com” and its
applicationplatform “Force.com”.
» An R package RForcecom has various features for exchanging data
with Salesforce.com/Force.com.
» I made a sample use case of RForcecom using Twitter dataset and
visualized customers’ voice.
» The framework might be applied to for conducting a sentiment
(negative/positive) analysis and for analyzing customer feedback for
specific product or service to improve customer satisfaction.
37
Thank you
» Any Questions?
Takekatsu Hiramura
http://thira.plavox.info/
thira@plavox.info http://rforcecom.plavox.info/

Weitere ähnliche Inhalte

Was ist angesagt?

Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2monikadeshmane
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
Getting started with Pod::Weaver
Getting started with Pod::WeaverGetting started with Pod::Weaver
Getting started with Pod::WeaverJoshua Keroes
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to GroovyAnton Arhipov
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersDavide Ciambelli
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin IGuixing Bai
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in ElixirJesse Anderson
 
[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기NAVER D2
 
Comparative Genomics with GMOD and BioPerl
Comparative Genomics with GMOD and BioPerlComparative Genomics with GMOD and BioPerl
Comparative Genomics with GMOD and BioPerlJason Stajich
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Aheadthinkphp
 

Was ist angesagt? (17)

Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
Finding Clojure
Finding ClojureFinding Clojure
Finding Clojure
 
Getting started with Pod::Weaver
Getting started with Pod::WeaverGetting started with Pod::Weaver
Getting started with Pod::Weaver
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Basic commands
Basic commandsBasic commands
Basic commands
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional Programing
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin I
 
Leaks & Zombies
Leaks & ZombiesLeaks & Zombies
Leaks & Zombies
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 
[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기
 
Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Comparative Genomics with GMOD and BioPerl
Comparative Genomics with GMOD and BioPerlComparative Genomics with GMOD and BioPerl
Comparative Genomics with GMOD and BioPerl
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
 

Ähnlich wie RForcecom: An R package which provides a connection to Force.com and Salesforce.com

Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apexRinku Saini
 
Teradata online training
Teradata online trainingTeradata online training
Teradata online trainingMonster Courses
 
3 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 20153 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 2015Manuel Bernhardt
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules RestructuredDoiT International
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
Does Your IBM i Security Meet the Bar for GDPR?
Does Your IBM i Security Meet the Bar for GDPR?Does Your IBM i Security Meet the Bar for GDPR?
Does Your IBM i Security Meet the Bar for GDPR?Precisely
 
React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015Robert Pearce
 
Text Mining with R -- an Analysis of Twitter Data
Text Mining with R -- an Analysis of Twitter DataText Mining with R -- an Analysis of Twitter Data
Text Mining with R -- an Analysis of Twitter DataYanchang Zhao
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to RestStratoscale
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsSalesforce Developers
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자Donghyeok Kang
 
Beyond Lists - Functional Kats Conf Dublin 2015
Beyond Lists - Functional Kats Conf Dublin 2015Beyond Lists - Functional Kats Conf Dublin 2015
Beyond Lists - Functional Kats Conf Dublin 2015Phillip Trelford
 
Solr Search Engine: Optimize Is (Not) Bad for You
Solr Search Engine: Optimize Is (Not) Bad for YouSolr Search Engine: Optimize Is (Not) Bad for You
Solr Search Engine: Optimize Is (Not) Bad for YouSematext Group, Inc.
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyMoby Project
 
Rapid prototyping search applications with solr
Rapid prototyping search applications with solrRapid prototyping search applications with solr
Rapid prototyping search applications with solrLucidworks (Archived)
 

Ähnlich wie RForcecom: An R package which provides a connection to Force.com and Salesforce.com (20)

Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apex
 
Teradata online training
Teradata online trainingTeradata online training
Teradata online training
 
3 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 20153 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 2015
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules Restructured
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Does Your IBM i Security Meet the Bar for GDPR?
Does Your IBM i Security Meet the Bar for GDPR?Does Your IBM i Security Meet the Bar for GDPR?
Does Your IBM i Security Meet the Bar for GDPR?
 
React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015React.js Basics - ConvergeSE 2015
React.js Basics - ConvergeSE 2015
 
Text Mining with R -- an Analysis of Twitter Data
Text Mining with R -- an Analysis of Twitter DataText Mining with R -- an Analysis of Twitter Data
Text Mining with R -- an Analysis of Twitter Data
 
Xm lparsers
Xm lparsersXm lparsers
Xm lparsers
 
Basic Unix
Basic UnixBasic Unix
Basic Unix
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to Rest
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
[제1회 루씬 한글분석기 기술세미나] solr로 나만의 검색엔진을 만들어보자
 
Beyond Lists - Functional Kats Conf Dublin 2015
Beyond Lists - Functional Kats Conf Dublin 2015Beyond Lists - Functional Kats Conf Dublin 2015
Beyond Lists - Functional Kats Conf Dublin 2015
 
Solr Search Engine: Optimize Is (Not) Bad for You
Solr Search Engine: Optimize Is (Not) Bad for YouSolr Search Engine: Optimize Is (Not) Bad for You
Solr Search Engine: Optimize Is (Not) Bad for You
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and Moby
 
Rapid prototyping search applications with solr
Rapid prototyping search applications with solrRapid prototyping search applications with solr
Rapid prototyping search applications with solr
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 

Mehr von Takekatsu Hiramura

SeekR: A Search Engine for R users
SeekR: A Search Engine for R usersSeekR: A Search Engine for R users
SeekR: A Search Engine for R usersTakekatsu Hiramura
 
SeekR Annual Search Trends Report 2015
SeekR Annual Search Trends Report 2015SeekR Annual Search Trends Report 2015
SeekR Annual Search Trends Report 2015Takekatsu Hiramura
 
「R for Cloud Computing」の紹介
「R for Cloud Computing」の紹介「R for Cloud Computing」の紹介
「R for Cloud Computing」の紹介Takekatsu Hiramura
 
The R User Conference 2014 @ UCLA
The R User Conference 2014 @ UCLAThe R User Conference 2014 @ UCLA
The R User Conference 2014 @ UCLA Takekatsu Hiramura
 
中の人が語る seekR.jp の裏側
中の人が語る seekR.jp の裏側中の人が語る seekR.jp の裏側
中の人が語る seekR.jp の裏側Takekatsu Hiramura
 

Mehr von Takekatsu Hiramura (7)

SageMakeR
SageMakeRSageMakeR
SageMakeR
 
SeekR Search Trend Report
SeekR Search Trend ReportSeekR Search Trend Report
SeekR Search Trend Report
 
SeekR: A Search Engine for R users
SeekR: A Search Engine for R usersSeekR: A Search Engine for R users
SeekR: A Search Engine for R users
 
SeekR Annual Search Trends Report 2015
SeekR Annual Search Trends Report 2015SeekR Annual Search Trends Report 2015
SeekR Annual Search Trends Report 2015
 
「R for Cloud Computing」の紹介
「R for Cloud Computing」の紹介「R for Cloud Computing」の紹介
「R for Cloud Computing」の紹介
 
The R User Conference 2014 @ UCLA
The R User Conference 2014 @ UCLAThe R User Conference 2014 @ UCLA
The R User Conference 2014 @ UCLA
 
中の人が語る seekR.jp の裏側
中の人が語る seekR.jp の裏側中の人が語る seekR.jp の裏側
中の人が語る seekR.jp の裏側
 

Kürzlich hochgeladen

定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 

Kürzlich hochgeladen (20)

Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 

RForcecom: An R package which provides a connection to Force.com and Salesforce.com

  • 1. RForcecom: An R package which provides a connection to Force.com and Salesforce.com Takekatsu Hiramura 2014-07-02 The R User Conference 2014 @ UCLA 1
  • 2. Agenda 2 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 3. Agenda 3 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 4. Takekatsu Hiramura » IT consultant, Software Engineer and Data scientist » Private website: http://thira.plavox.info/ » Blog: http://hiratake55.wordpress.com/ » R-bloggers: http://www.r-bloggers.com/author/takekatsu-hiramura/ 4
  • 5. Agenda 5 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 6. Specific features of CRM About Salesforce.com/Force.com 6 » “Salesforce.com “ is one of the most famous SaaS (Software-as-a-Service) based CRM (Customer Relationship Management) service. » “Force.com” is a application platform of Salesforce.com, and it specifically called PaaS (Platform-as-a-Service). Campaign Management Contract Management Customer Management Product Management and etc. Sales Forecasting Case Management Overview of the Application/Service Architecture Application Platform Service Custom Object Apex / VisualForce Web API and etc.
  • 7. Agenda 7 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 8. The RForcecom package I developed an R package “RForcecom” which provides a connection to Salesforce.com and Force.com via REST API. 8  Statistical Analysis  Machine Learning  Data Manipulation  Visualization  Customer Relationship Management  Dashboard  Collaboration Platform (Chatter,Schedule,ToDo etc.) RSalesforce.com Delete Insert Update/Upsert Data extract SOQL query Search
  • 9. The CRAN page of the RForcecom 9 http://cran.r-project.org/web/packages/RForcecom/
  • 10. Source code is available on GitHub 10 https://github.com/hiratake55/RForcecom
  • 11. Agenda 11 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 12. Features of RForcecom Execute a SOSL rforcecom.search() Create a record rforcecom.create() Retrieve record rforcecom.retrieve() Update a record rforcecom.update() Upsert a record rforcecom.upsert() Delete a record rforcecom.delete() Retrieve a server timestamp rforcecom.getServerTimestamp() Execute a SOQL rforcecom.query() Sign in to the Force.com rforcecom.login() Feature Function name# Retrieve object descriptions rforcecom.getObjectDescription() Retrieve a list of objects rforcecom.getObjectList 8 2 3 4 5 6 11 7 1 10 9 12
  • 13. Sign in to the Force.com 13 > library(RForcecom) > username <- yourname@yourcompany.com > password <- "YourPasswordSECURITY_TOKEN” > instanceURL <- https://xxx.salesforce.com/ > apiVersion <- "26.0“ > session <- rforcecom.login(username, password, instanceURL, apiVersion)
  • 14. Retrieve records 14 > objectName <- "Case" > fields <- c("CaseNumber", "Subject", "Status") > rforcecom.retrieve(session, objectName, fields, order=c("CaseNumber"),limit=12) Salesforce.com R
  • 15. Execute a SOQL > soqlQuery <- "SELECT Id, Name, Industry FROM Account order by CreatedDate" > rforcecom.query(session, soqlQuery) 15 Salesforce.com R
  • 16. Agenda 16 1. About me 2. Brief introduction of Force.com and Salesforce.com 3. Overview of RForcecom 4. Features of RForcecom 5. Example of the analysis using RForcecom -Visualizing consumers’ voice-
  • 17. RForcecom demo : Visualizing consumers’ voice » Assume you are a manager at a company and want to know the consumers’ voice from CRM. Consumers’ voices are stored in Salesforce.com which registered by their call center staff. 17 Call Center Salesforce.com R Managers Data collection/ Operation Data Management Data Analysis Reporting Customer Mgmt. Case Mgmt. REST/SOAP API API Client (RForcecom) NLP (TreeTagger) Visualization (Wordcloud) … …
  • 18. Sample Dataset: Delta’s Twitter Social Customer Support Account » It is difficult to use actual dataset, so I crawled Delta Airline’s Twitter account (@DeltaAssist)and stored tweets to Salesforce.com instead of actual dataset. 18 https://twitter.com/DeltaAssist/with_replies
  • 19. Step 1: Retrieving a dataset from Salesforce.com » Tweets sent to @DeltaAssist are stored in Salesforce.com. 19
  • 20. Step 1: Retrieving a dataset from Salesforce.com » Tweets sent to @DeltaAssist are stored in Salesforce.com. 20
  • 21. Step 1: Retrieving a dataset from Salesforce.com » Load required libraries and sign into Salesforce.com. 21 > library(RForcecom) > username <- yourname@yourcompany.com > password <- "YourPasswordSECURITY_TOKEN” > instanceURL <- https://xxx.salesforce.com/ > apiVersion <- "26.0“ > session <- rforcecom.login(username, password, instanceURL, apiVersion)
  • 22. Step 1: Retrieving a dataset from Salesforce.com » To retrieve dataset with parameters of objectname and field names. 22 > CustomerVoice <-rforcecom.retrieve(session,"CustomerVoice__c",c("TweetDate__c","Tweet__c")) > head(CustomerVoice$Tweet__c,10)
  • 23. Step 2: Extracting high-frequency keywords 23 > library(koRpus) > temp.file.name<-tempfile() > write.table(CustomerVoice$Tweet__c,temp.file.name,col.names=F,row.names=F) > tagged<-treetag(temp.file.name, lang="en", treetagger="manual",TT.options=list(path="C:/Apps/TreeTagger", preset="en",encoding="UTF-8")) > tagged.DF<-tagged@TT.res > head(tagged.DF,10) » Tag the word class for each words using “koRpus“ package and TreeTagger.
  • 24. Step 2: Extracting high-frequency keywords 24 > term<-tagged.DF[tagged.DF$wclass=="noun",]$token > term<-tolower(term) > head(term,20) » Filter “noun” from tagged list
  • 25. Step 2: Extracting high-frequency keywords 25 > term.unique<-unique(term) > term.freq <- unlist(lapply(term.unique,function(x){length(term[term==x])})) > termfreq<-data.frame(term=term.unique, freq=term.freq) > termfreq<-termfreq[order(termfreq$freq,decreasing=T),] > head(termfreq,10) » Count frequencies of the terms.
  • 26. Step 3: Visualizing the words as a word cloud 26 > library(wordcloud) > termfreq.top<-head(termfreq, n=100) > pal <- brewer.pal(8, "Dark2") > windowsFonts(SegoeUI = "Segoe UI") > wordcloud(termfreq.top$term, termfreq.top$freq, random.color=T, colors=pal, family="SegoeUI") » Visualize the terms using wordcloud package. “Flight” is the most frequent.
  • 27. Step 4: Visualize the Buzz-word of the day 27 > CustomerVoice.sun<- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-25T00:00:00-04:00and TweetDate__c < 2014-05-26T00:00:00-04:00") > CustomerVoice.mon <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-26T00:00:00-04:00and TweetDate__c < 2014-05-27T00:00:00-04:00") > CustomerVoice.tue <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-27T00:00:00-04:00and TweetDate__c < 2014-05-28T00:00:00-04:00") > CustomerVoice.wed <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-28T00:00:00-04:00and TweetDate__c < 2014-05-29T00:00:00-04:00") > CustomerVoice.thu <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-29T00:00:00-04:00and TweetDate__c < 2014-05-30T00:00:00-04:00") > CustomerVoice.fri <- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-30T00:00:00-04:00and TweetDate__c < 2014-05-31T00:00:00-04:00") > CustomerVoice.sat<- rforcecom.query(session, "select Tweet__c, TweetDate__c from CustomerVoice__c where TweetDate__c >= 2014-05-31T00:00:00-04:00and TweetDate__c < 2014-06-01T00:00:00-04:00") > CustomerVoice.all <- rbind(CustomerVoice.sun, CustomerVoice.mon, CustomerVoice.tue, CustomerVoice.wed, CustomerVoice.thu, CustomerVoice.fri, CustomerVoice.sat) » Retreive daily datasets by SOQL.
  • 28. Step 4: Visualize the Buzz-word of the day 28 # Tag, Extract noun, Calculate TF make.treetag<-function(CustomerVoice){ temp.file.name<-tempfile() write.table(CustomerVoice$Tweet__c,temp.file.name,col.names=F,row.names=F) tagged<-treetag(temp.file.name, lang="en", treetagger="manual",TT.options=list(path="C:/Apps/TreeTagger", preset="en",encoding="UTF-8")) tagged.DF<-tagged@TT.res # Extract noun, To lower term<-tagged.DF[tagged.DF$wclass=="noun",]$token term<-tolower(term) # Count frequency of term term.unique<-unique(term) term.freq <- unlist(lapply(term.unique,function(x){length(term[term==x])})) termfreq.DF<-data.frame(term=term.unique, freq=term.freq, stringsAsFactors=F) termfreq.DF<-termfreq.DF[order(termfreq.DF$freq,decreasing=T),] return(termfreq.DF) } # Apply to each dataset termfreq.sun<-make.treetag(CustomerVoice.sun) termfreq.mon<-make.treetag(CustomerVoice.mon) termfreq.tue<-make.treetag(CustomerVoice.tue) termfreq.wed<-make.treetag(CustomerVoice.wed) termfreq.thu<-make.treetag(CustomerVoice.thu) termfreq.fri<-make.treetag(CustomerVoice.fri) termfreq.sat<-make.treetag(CustomerVoice.sat) termfreq.all<-make.treetag(CustomerVoice.all) » Tag, extract noun and calculate the Term Frequency (TF). *TF (Term Frequency): number of occurrence of term i in document j
  • 29. 29 Step 4: Visualize the Buzz-word of the day # Calculate IDF IDF.documents <- sapply(termfreq.all$term,function(x){ sum( nrow(termfreq.sun[termfreq.sun$term==x,])>0, nrow(termfreq.mon[termfreq.mon$term==x,])>0, nrow(termfreq.tue[termfreq.tue$term==x,])>0, nrow(termfreq.wed[termfreq.wed$term==x,])>0, nrow(termfreq.thu[termfreq.thu$term==x,])>0, nrow(termfreq.fri[termfreq.fri$term==x,])>0, nrow(termfreq.sat[termfreq.sat$term==x,])>0 ) }) IDF<-data.frame(term=termfreq.all$term,IDF=log(7/IDF.documents)) » Calculate the Inverse Document Frequency (IDF). *IDF (Inverse Document Frequency): IDF measures “Term specificity”. df: number of documents containing term i. N: Total Number of documents Reference: http://dovgalecs.com/blog/matlab-simple-tf-idf/ IDF=
  • 30. Step 4: Visualize the Buzz-word of the day 30 # Calculate TF and returns TF-IDF calc.tfidf <- function(termfreq){ # TF termfreq$TF <- termfreq$freq/sum(termfreq$freq) # TF-IDF tfidf.val <- lapply(termfreq$term,function(x){ tf_i <- termfreq[termfreq$term==x,]$TF idf_i <- IDF[IDF$term==x,]$IDF return(tf_i * idf_i) }) tdidf <- data.frame(term=termfreq$term, TFIDF=unlist(tfidf.val)) return(tdidf) } tfidf.sun <- calc.tfidf(termfreq.sun) tfidf.mon <- calc.tfidf(termfreq.mon) tfidf.tue <- calc.tfidf(termfreq.tue) tfidf.wed <- calc.tfidf(termfreq.wed) tfidf.thu <- calc.tfidf(termfreq.thu) tfidf.fri <- calc.tfidf(termfreq.fri) tfidf.sat <- calc.tfidf(termfreq.sat) » Calculate the TF-IDF of each dataset. *TF-IDF (Term Frequency–Inverse Document Frequency): TF-IDF measures how important a word is in a document. TF-IDF = TF × IDF
  • 31. Step 4: Visualize the Buzz-word of the day 31 # Wordcloud draw.wordcloud<- function(tfidf,title=""){ png.filename <- paste("wordcloud-", title,".png", sep="") png(png.filename,width=7,height=7,units="in", res=600) tfidf <- tfidf[order(tfidf$TFIDF, decreasing=T),] tfidf.head <- head(tfidf, n=100) # Extract to 100 terms par(oma = c(0, 1, 2, 1)) # Set margin pal <- brewer.pal(8, "Dark2") wordcloud(tfidf.head$term,tfidf.head$TFIDF,random.color=T,colors=pal,main=title) # Plot Wordcloud par(oma = c(0, 0, 0, 0)) # Unset Margin title(title) # Add Title dev.off() # Close File } # Plot Wordcloudfor each dataset draw.wordcloud(tfidf.sun,title="2014-05-25(Sun)") draw.wordcloud(tfidf.mon,title="2014-05-26(Mon)") draw.wordcloud(tfidf.tue,title="2014-05-27(Tue)") draw.wordcloud(tfidf.wed,title="2014-05-28(Wed)") draw.wordcloud(tfidf.thu,title="2014-05-29(Thu)") draw.wordcloud(tfidf.fri,title="2014-05-30(Fri)") draw.wordcloud(tfidf.sat,title="2014-05-31(Sat)") » Output word clouds as PNG format.
  • 32. Step 4: Visualize the Buzz-word of the day » These wordclouds are describing the trends of the day. 32
  • 33. Step 4: Visualize the Buzz-word of the day » These wordclouds are describing the trends of the day. wordcloud of a Sunday  There are specific location such as “Vancouver”, “Boston” and “Phoenix”.  It seems that this day has more questions about a route or a booking than other days or troubles that happened in specific airport. 33
  • 34. Step 4: Visualize the Buzz-word of the day » These wordclouds are describing the trends of the day. wordcloud of a Thursday  The words “seatback”, “pain” and ”captains” appeared in the word cloud.  It seems that there are troubles with the fleet, cabin or in-flight service somewhere. 34
  • 35. Step 4: Visualize the Buzz-word of the day » These wordclouds are describing the trends of the day. Wordcloud of a Friday  There are words : “award” and “platinum”.  It seems that this day has more questions about frequent flyer program than a normal day. 35
  • 36. Conclusion 36 » I told a brief introduction of SaaS-Based CRM “Salesforce.com” and its applicationplatform “Force.com”. » An R package RForcecom has various features for exchanging data with Salesforce.com/Force.com. » I made a sample use case of RForcecom using Twitter dataset and visualized customers’ voice. » The framework might be applied to for conducting a sentiment (negative/positive) analysis and for analyzing customer feedback for specific product or service to improve customer satisfaction.
  • 37. 37 Thank you » Any Questions? Takekatsu Hiramura http://thira.plavox.info/ thira@plavox.info http://rforcecom.plavox.info/