Skip to content

Commit

Permalink
saving minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikhshafayat committed Jun 7, 2022
1 parent d098645 commit 9e3ac8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions DataAnalysis/Q3/BigramWordCloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ p_load(wordcloud)
p_load(tm)

####Loading all the data
#foxnews <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxalltweets_with_sentiment.csv")
#nytimes <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytalltweets_with_sentiment.csv")
foxnews <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxalltweets_with_sentiment.csv")
nytimes <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytalltweets_with_sentiment.csv")
foxtitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxtitle_with_sentiment.csv")
#nytitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytitle_with_sentiment.csv")
nytitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytitle_with_sentiment.csv")

foxnews <- foxnews %>% filter(grepl("^@", foxnews$text))
nytimes <- nytimes %>% filter(grepl("^@", nytimes$text))
Expand All @@ -30,7 +30,7 @@ bigram_wc <- function(foxnews){
bg_fox <- fox_unn %>%
separate(word, c("word1", "word2"), sep=" ")

avoid_list <- c("russia", "ukraine", "user", "http", "fox", "york", "news", "tucker")
avoid_list <- c("russia", "ukraine", "user", "http", "fox", "york", "news")
filter_bg_fox <- bg_fox %>%
filter(!word1 %in% stop_words$word) %>%
filter(!word2 %in% stop_words$word) %>%
Expand All @@ -47,7 +47,7 @@ bigram_wc <- function(foxnews){
wc <- wordcloud(words = count_bg$bigram, freq = count_bg$n, min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))

return(wc)
return(count_bg)
}

fox_pos <- foxnews %>% filter(label=="Positive")
Expand Down
2 changes: 1 addition & 1 deletion DataAnalysis/Q3/MakeWordCloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ make_cloud <- function(dataset, sentiment){
set.seed(1234)
wc <- wordcloud(words = df$word, freq = df$freq, min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2"))
return(wc)
return(df)

}

Expand Down
6 changes: 3 additions & 3 deletions DataAnalysis/Q3/Q3LinePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ library(dplyr)
library(pacman)
p_load(plotly)
# csv file -- change the file path here
#foxnews <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxalltweets_with_sentiment.csv")
#nytimes <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytalltweets_with_sentiment.csv")
foxnews <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxalltweets_with_sentiment.csv")
nytimes <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytalltweets_with_sentiment.csv")
foxtitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/foxtitle_with_sentiment.csv")
#nytitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytitle_with_sentiment.csv")
nytitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytitle_with_sentiment.csv")
q1 <- foxtitle

#filter tweets that starts with @
Expand Down
3 changes: 3 additions & 0 deletions DataAnalysis/Q3/Q3SidebySideBarPlotSentiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ foxtitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Met
nytitle <- read.csv("/Volumes/GoogleDrive/My Drive/Spring 2022/Data Science Methodology/UkraineConflictOnTwitter/SentimentAnalysis/data/q3/May30Scrap/nytitle_with_sentiment.csv")
#######3#preprocess everything

#filter for only the audience
foxnews <- foxnews %>% filter(grepl("^@", foxnews$text))
nytimes <- nytimes %>% filter(grepl("^@", nytimes$text))

nytimes <- nytimes %>% select(Date, text, label, score)
nytimes$Date <- sub(" .*", "", nytimes$Date) %>% as.Date(format="%Y-%m-%d", tz="UTC")
Expand Down

0 comments on commit 9e3ac8e

Please sign in to comment.