Browse Source

Edit: new plot for participation by date

pull/14/head
janwey 1 year ago
parent
commit
acae2e3de5
4 changed files with 32 additions and 80 deletions
  1. BIN
      data/blogs_media.ods
  2. BIN
      plots/ilfs-participation-by-date.pdf
  3. BIN
      plots/ilfs-participation-by-date.png
  4. 32
    80
      plotte.R

BIN
data/blogs_media.ods View File


BIN
plots/ilfs-participation-by-date.pdf View File


BIN
plots/ilfs-participation-by-date.png View File


+ 32
- 80
plotte.R View File

@@ -5,8 +5,12 @@
################################################################################

## Loading Packages {{{ ----
install.packages("stringi")
library("stringi")
### ggplot2 for plots
install.packages("ggplot2")
library("ggplot2")
### arrange ggplot2 plots
install.packages("gridExtra")
library("gridExtra")
# }}}

## Loading Data {{{ ----
@@ -14,7 +18,6 @@ load(file = "./data/ilovefs-all_2018-02-20_14-57-16.RData")
### following requires you to extract the hashtags first (see further down).
### this can later be imported via a CSV file again
hash_ment <- read.csv2(file = "./data/tags_mentions.csv", sep = ",", header = FALSE)
#hashtags <- read.csv2(file = "./data/ilovefs-projects_manual.csv", header = TRUE, sep = ",")
# }}}

## Extract Hashtags {{{ ----
@@ -81,8 +84,6 @@ twitter_mentions <- sub(x = twitter_mentions, pattern = "…", replace = "")
unique(twitter_mentions)
# }}}



### Participation per Platform {{{ ----

#### Calculating Platform numbers
@@ -122,79 +123,30 @@ dev.off()

### Time and Date {{{ ----

#### Aggregate Date & Time into single strings
twitter_datetime <- rev(paste0(twitter$date, twitter$time))
fediver_datetime <- rev(paste0(mastodon$date, mastodon$time))

library("ggplot2")
twitter_time <- strptime(paste0(twitter$date, twitter$time), format = "%Y%m%d%H%M%S")

ggplot(data = twitter, aes(x=twitter_time)) +
geom_histogram(aes(fill=..count..), binwidth=60*180) +
scale_x_datetime("Date") +
scale_y_continuous("Frequency") +
# ggtitle("Participation in the ILoveFreeSoftware Campaign") +
scale_fill_gradient("Count", low="#640000", high="#FF0000")
opts(title="#ISMB Tweet Frequency July 11-17", legend.position='none')
ggsave(file="./plots/ilfs-participation-by-date.pdf", width=7, height=7)






#### Density Plots of Postings over Time
#pdf(file = "./plots/participation_datetime.pdf", height = 7, width = 14)
##### Fediverse (initial plot)
# plot(density(as.numeric(fediver_datetime)),
# type = "h", xaxt = "n", yaxt = "n",
# xlab = "", ylab = "Frequency Posts",
# main = "Participation around I Love Free Software Day",
# col = "#a22430", axes = FALSE, lwd = 0.6)
##### Twitter
# lines(density(as.numeric(twitter_datetime)), type = "h", col = "#1da1f2", lwd = 0.6)
##### Added Axis (shows date)
# axis(side = 1, labels = c("10.02.18", "11.02.18", "12.02.18", "13.02.18", "14.02.18", "15.02.18", "16.02.18"),
# at = c(20180210120000, 20180211120000, 20180212120000, 20180213120000, 20180214120000, 20180215120000, 20180216120000))
##### Add legend
# legend(x = "topleft", legend = c("Twitter", "Fediverse"),
# fill = c("#1da1f2", "#a22430"), bty = "n")
#dev.off()

#### Extract posting times only on February 14th
#twitter_ilfsd <- twitter$time[which(twitter$date == "20180214")]
#fediver_ilfsd <- mastodon$time[which(mastodon$date == "20180214")]

#### Get aggregated number of posts over time during the day
#time <- seq(from = 000000, to = 240000, by = 010000)
#twitter_aggregated <- c()
#for(i in 1:length(time)){
# twitter_aggregated[i] <- length(which(as.numeric(rev(twitter_ilfsd)) < time[i]))
#}
#fediver_aggregated <- c()
#for(i in 1:length(time)){
# fediver_aggregated[i] <- length(which(as.numeric(rev(fediver_ilfsd)) < time[i]))
#}

#### Plotting the aggregated number of posts during the day
#pdf(file = "./plots/participation_time.pdf", height = 7, width = 14)
# ##### Twitter
# plot(x = time, y = twitter_aggregated, type = "l",
# main = "Number of Posts about #ilovefs on February 14 2018",
# xlab = "Time (UTC)",
# ylab = "Number of Posts",
# xaxt = "n", col = "#1da1f2", lwd = 3,
# axes = FALSE,
# ylim = c(0, length(twitter$text) + 50))
# ##### Fediverse
# lines(x = time, y = fediver_aggregated, type = "l", col = "#a22430", lwd = 3)
# ##### Add Axis (show time and number of posts)
# axis(side = 1, labels = c("00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00", "24:00"),
# at = c(000000, 030000, 060000, 090000, 120000, 150000, 180000, 210000, 240000))
# axis(side = 2, labels = as.character(seq(from = 0, to = max(twitter_aggregated) + 100, by = 50)),
# at = seq(from = 0, to = max(twitter_aggregated) + 100, by = 50))
# ##### Add legend
# legend(x = "topleft", legend = c("Twitter", "Fediverse"),
# fill = c("#1da1f2", "#a22430"), bty = "n")
#dev.off()
#### Transform time into POSIX dates
twitter_time <- strptime(paste0(twitter$date, twitter$time),
format = "%Y%m%d%H%M%S")
mastodon_time <- strptime(paste0(mastodon$date, mastodon$time),
format = "%Y%m%d%H%M%S")

#### Participation by Time on Twitter
twitter_plot <- ggplot(data = twitter, aes(x=twitter_time)) +
geom_histogram(aes(fill=..count..), binwidth=60*180) +
scale_x_datetime("Date") +
scale_y_continuous("Frequency") +
ggtitle("Participation on Twitter") +
scale_fill_gradient("Count", low="#002864", high="#329cc3")

#### Participation by Time in the Fediverse
mastodon_plot <- ggplot(data = mastodon, aes(x=mastodon_time)) +
geom_histogram(aes(fill=..count..), binwidth=60*180) +
scale_x_datetime("Date") +
scale_y_continuous("Frequency") +
ggtitle("Participation in the Fediverse") +
scale_fill_gradient("Count", low="#640000", high="#FF0000")

#### Export / Save plots as PDF
pdf(file="./plots/ilfs-participation-by-date.pdf", width=14, height=7)
grid.arrange(twitter_plot, mastodon_plot, ncol = 2)
dev.off()
# }}}

Loading…
Cancel
Save