#r #ggplot2
Вопрос:
У меня есть эти данные сообщений по дате
https://www.mediafire.com/file/8rvexe3bswd57ly/data.xlsx/file
Сначала я построил график еженедельной частоты, используя этот код, и он отлично работает
library(tidyverse)
library(lubridate)
library(readxl)
library(tidytext)
library(stringr)
library(tidyr)
library(dplyr)
library(scales)
stories <- read_xlsx("C:/User/data.xlsx")%>%
mutate(time = as.POSIXct(time, origin = "1970-01-01"),
week = round_date(time, "week"))
stories %>%
count(Week = round_date(time, "week")) %>%
ggplot(aes(Week, n))
scale_x_datetime(breaks = date_breaks("1 months"),labels = date_format("%Y-%m"))
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
geom_line()
ggtitle('The number of Titles posted per Week')
Я использую этот учебник
https://towardsdatascience.com/auto-tagging-stack-overflow-questions-5426af692904
Теперь я пытаюсь сравнить рост или уменьшение определенных тегов с течением времени, как в учебнике:
title_words <- stories %>%
distinct(titles, .keep_all = TRUE) %>%
unnest_tokens(word, titles, drop = FALSE) %>%
distinct(ID, word, .keep_all = TRUE) %>%
anti_join(stop_words, by = "word") %>%
filter(str_detect(word, "[^\d]")) %>%
group_by(word) %>%
mutate(word_total = n()) %>%
ungroup()
title_words
word_counts <- title_words %>%
count(word, sort = TRUE)
word_counts
tags <- c("coronavirus", "china")
q_per_year <- stories %>%
count(Week = week(time)) %>%
rename(WeekTotal = n)
head(q_per_year)
tags_per_year <- word_counts %>%
filter(word %in% tags)%>%
inner_join(stories)
count(Week = week(time), word)
inner_join(q_per_year)
ggplot(tags_per_year, aes(Week, n / WeekTotal, color = word))
geom_line()
scale_y_continuous(labels = scales::percent_format())
ylab("% of Stack Overflow questions with this tag")
ggtitle('Growth or Shrinking of Particular Tags Overtime')
Но я получаю ошибку во внутреннем соединении
Error: `by` must be supplied when `x` and `y` have no common variables.
i use by = character()` to perform a cross-join.
переменная word_counts в порядке, а также q_per_year, но я не могу понять, что происходит с внутренними соединениями
Комментарии:
1. данные, опубликованные для этого вопроса, больше не находятся по ссылке