knitr::opts_chunk$set(
  echo = FALSE,
  message = FALSE,
  warning = FALSE
)

# We expect a rooms object as input.
rooms <- params$rooms

if (is.null(rooms)) {
  stop("No data provided!")
}

Statistics generated on r Sys.time() and based on data from the last 30 days.

This data has a total of r length(unique(rooms$events$sender)) different IDs, speaking a total of r nrow(rooms$events) messages.

Daily Activity & trend

plot_daily_activity(rooms)

Daily Activity, breakdown by time-of-day

plot_time_of_day_activity(rooms)

Most active times

plot_active_times(rooms)

Top ten posters (by message count)

Words like "and", "the", "or", and so on have been removed before counting.

rooms$events |>
  dplyr::filter(type == "m.room.message" & !is.na(body)) |>
  dplyr::group_by(sender) |>
  tidytext::unnest_tokens(
    output = "word",
    input = body,
    drop = FALSE
  ) |>
  dplyr::filter(!(word %in% tidytext::stop_words$word)) |>
  dplyr::add_count(sender, name = "words") |>
  dplyr::group_by(sender) |>
  dplyr::slice_sample(n = 1) |>
  dplyr::left_join(
    dplyr::count(rooms$events, sender, name = "messages"),
    by = "sender"
  ) |>
  dplyr::arrange(-messages) |>
  dplyr::select(-word) |>
  dplyr::ungroup() |>
  dplyr::slice_head(n = 10) |>
  dplyr::mutate(body = stringr::str_replace_all(body, pattern = "\n", " ")) |>
  dplyr::rename(`random message` = body) |>
  knitr::kable(format = "html")

Most Used Words

words_data <- rooms$events |>
  dplyr::filter(type == "m.room.message" & !is.na(body)) |>
  tidytext::unnest_tokens(
    output = "word", input = body,
    drop = FALSE
  ) |>
  dplyr::filter(!(word %in% tidytext::stop_words$word))

words_data |>
  dplyr::count(word, sort = T) |>
  dplyr::slice_head(n = 10) |>
  dplyr::mutate(last_used_by = purrr::map_chr(
    word, ~ {
      words_data |>
        dplyr::filter(word == .x) |>
        dplyr::slice_tail(n = 1) |>
        dplyr::pull(sender)
    }
  )) |>
  knitr::kable(format = "html")


GregSutcliffe/ChatStat documentation built on March 18, 2022, 8:51 a.m.