library(twitteR)
library(tidytext)
library(stringr)
library(ggplot2)
library(dplyr)
library(knitr)

options(scipen=999, digits = 2)
num_tweets <- 1000
hash1 <- searchTwitter('expouav2016', n = num_tweets)
hash2 <- searchTwitter('UAVExpo2016', n = num_tweets)
hash3 <- searchTwitter('expouav', n = num_tweets)

hash1_df <- twListToDF(hash1) %>% mutate(Hash = 'expouav2016', CountCol = 1)
hash2_df <- twListToDF(hash2) %>% mutate(Hash = 'UAVExpo2016', CountCol = 1)
hash3_df <- twListToDF(hash3) %>% mutate(Hash = 'expouav', CountCol = 1)

FinalDF <- rbind(hash1_df, hash2_df, hash3_df) %>% mutate(ShortDate = as.Date(created, format = "%m/%d/%Y"))
# Create data frame to count how many times each hash was used
UseCount <- FinalDF %>% group_by(Hash) %>% summarize(n = n())

# Enforce the order of the bars for the chart by specifying the order explicitly
UseCount$Hash <- factor(UseCount$Hash, levels = UseCount$Hash[order(UseCount$n)])

# Create Bar Graph that displays how many times each hash was used
Plot1 <- ggplot(data = UseCount, aes(x = Hash, y = n)) +
  geom_bar(fill = "deeppink2", colour = "black", stat = "identity") + 
  geom_text(aes(label = n, vjust = -.5)) +
  labs(x = "Hash Tag") +
  labs(y = "# of Times Used") +
  labs(title = "Usage Chart")

# Count how many unique users used the hash tags
UniqueUsers <- n_distinct(FinalDF$screenName)


# Isolate each unique status source
FinalDF$statusSource = substr(FinalDF$statusSource, 
                               regexpr('>', FinalDF$statusSource) + 1, 
                               regexpr('</a>', FinalDF$statusSource) - 1)

# Summarize tweets by platform source - create data frame
FinalDF_platform <- FinalDF %>% group_by(statusSource) %>% summarize(n = n()) %>% 
  mutate(PercentofTweets = (n/sum(n)*100)) %>% arrange(desc(PercentofTweets)) %>% top_n(10)

# Enforce the order of the bars for the chart by specifying the order explicitly
FinalDF_platform$statusSource <- factor(FinalDF_platform$statusSource, levels = FinalDF_platform$statusSource[order(FinalDF_platform$PercentofTweets)])

# Create Horizontal Bar Chart that displays the top 10 most used platforms
Plot2 <- ggplot(data = FinalDF_platform, aes(x = statusSource, y = PercentofTweets)) +
  geom_bar(fill = "dodgerblue1", colour = "black", stat = "identity") + 
  coord_flip() +
  geom_text(aes(label = round(PercentofTweets, digits = 1), hjust = -.2)) +
  labs(x = "Source Platform") +
  labs(y = "% of Tweets") +
  labs(title = "Platforms Used by % of Tweets")
  

# Summarize tweets by the person who posted the tweet (ScreenName)
FinalDF_Names <- FinalDF %>% group_by(screenName) %>%  summarize(n = n()) %>% arrange(desc(n)) %>% top_n(10)

# Enforce the order of the bars for the chart by specifying the order explicitly
FinalDF_Names$screenName <- factor(FinalDF_Names$screenName, levels = FinalDF_Names$screenName[order(FinalDF_Names$n)])

# Create Horizontal Bar Chart that displays the top 10 most active users
Plot3 <- ggplot(data = FinalDF_Names, aes(x = screenName, y = n)) +
  geom_bar(fill = "darkslateblue", colour = "black", stat = "identity") + 
  coord_flip() +
  geom_text(aes(label = n, hjust = -.2)) +
  labs(x = "Screen Name") +
  labs(y = "# of Tweets") +
  labs(title = "Top Users by # of Tweets")


# Word summary
reg <- "([^A-Za-z\\d#@']|'(?![A-Za-z\\d#@]))"
FinalDF_words <- FinalDF %>%
  filter(!str_detect(text, '^"')) %>%
  mutate(text = str_replace_all(text, "https://t.co/[A-Za-z\\d]+|&amp;", "")) %>%
  unnest_tokens(word, text, token = "regex", pattern = reg) %>%
  filter(!word %in% stop_words$word,
         str_detect(word, "[a-z]"))

# Sentiment Analysis - Create table that relates sentiments to words
nrc <- sentiments %>% filter(lexicon == "nrc") %>% select(word, sentiment)
Expo_Sentiments <- FinalDF_words %>% inner_join(nrc, by = "word")

# Create Table to display top 15 sentiments
Sentiment_Table <- Expo_Sentiments %>% group_by(sentiment) %>% summarize(n = n()) %>% arrange(desc(n)) %>% top_n(15)

# Positive word analysis - Create Table to display top 15 Positive words used
nrcPositive <- get_sentiments("nrc") %>% filter(sentiment == "positive")
uav_Positive <- FinalDF_words %>% semi_join(nrcPositive) %>% count(word, sort = TRUE) %>% arrange(desc(n)) %>% top_n(15)

# Negative word analysis - Create Table to display top 15 negative words used
nrcNegative <- get_sentiments("nrc") %>% filter(sentiment == "negative")
uav_Negative <- FinalDF_words %>% semi_join(nrcNegative) %>% count(word, sort = TRUE) %>% arrange(desc(n)) %>% top_n(15)


# Create Table to display Top 25 words used overall - not including the searched hash or rt (retweet)
Pop_Words <- FinalDF_words %>% group_by(word) %>% filter(word != "rt", word != "@expouav", word != "#uavexpo2016", word != "#expouav2016") %>% summarize(n = n()) %>% arrange(desc(n)) %>% top_n(25)


# Create table grouping by hash then date created for time series chart
CreatedDate <- FinalDF %>% group_by(Hash, ShortDate) %>% summarize(Total_Tweets = sum(CountCol))

# Create Line Graph to display hash usage by date over time
Plot4 <- ggplot(data = CreatedDate, aes(x = ShortDate, y = Total_Tweets, group = Hash, colour = Hash)) +
 geom_line() + 
 geom_point(size = 4, shape = 20) +
 scale_y_continuous(name = "# of Tweets", breaks=seq(0,400,50)) +
 labs(x = "Date") +
 labs(title = "Hash Use by Date")

Commercial UAV Expo & Conference 2016

October 31 to November 2

MGM Grand - Las Vegas, Nevada

Event Overview

Commercial UAV Expo and Conference is a Business to Business trade show that focuses on unmanned aerial vehicles for use in the industries of:
  • Surveying & Mapping
  • Civil Infrastructure
  • Process, Power & Utilities
  • Aggregates & Mining
  • Construction
  • Law Enforcement
  • Emergency Response & Search and Rescue (SAR)
  • Precision Agriculture
The international Exhibition includes drone airframe manufacturers, component and sensor manufacturers, software developers and service companies. Commercial UAV Expo has more exhibitors than any other commercial drone show.
The above information was taken directly from the Commercial UAV website, which can be found Here.

Twitter Analytics

Each year, the sales and marketing team create an “offical” hash tag for the event and distribute it on their marketing materials prior to the show; the hash tag for this year’s show was #expouav2016. During the event, the team discovered that many attendees were not using the correct hash tag or were getting it mixed up, often using #UAVExpo2016 or #expouav. The following report will provide more insight into the usage of Twitter for the Commercial UAV show.
This first bar chart shows the number of times each hash tag was used.

There were 273 unique people that used the 3 hash tags above. The chart below shows the top 10 most active users based on number of tweets using the hash tags.

The following table displays the 25 most used words in the tweets, not including the hash tags themselves.

Sentiment Usage

sentiment n
positive 331
anticipation 139
negative 134
trust 93
surprise 69
fear 53
joy 41
anger 25
disgust 13
sadness 1
I wanted to look more closely as to what words people used that were specifically noted as positive and negative. The following tables display the top 15 words associated with each of those sentiments.

Positive Words

word n
solution 50
unique 47
agriculture 40
traditional 28
flying 16
crucial 10
continue 8
keynote 8
laser 8
including 7
launch 6
model 6
offer 6
talk 6
management 5

Negative Words

word n
drone 96
avoidance 5
collision 5
hood 5
sneak 5
actionable 2
caution 2
force 2
gap 2
john 2
mar 2
wait 2
cage 1
explosion 1
loony 1
radiation 1
The final chart displays the usage of these 3 hash tags over time.