0

Does anyone have suggestions on how to decompose this data set in r? Also, the first column is coming up as character, but when I ran ggplot, it was correctly analyzed as date data. Do I still need to convert it to date? And if so, how?

please click here for data set

pogibas
  • 27,303
  • 19
  • 84
  • 117
  • Welcome to StackOverflow. What do you mean by decomposition? – pogibas Oct 31 '18 at 14:20
  • I would like to get graphs of seasonal, trend, random and observed data. – Mackenzie Miller Oct 31 '18 at 14:21
  • Please read and edit your question according to: [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Can you add example of your data using `dput()` function? Also, explain wanted output. How this random data should be generated? You can also add your `ggplot2` function. – pogibas Oct 31 '18 at 14:24
  • https://drive.google.com/file/d/16vjT4l-2Krnu8gpjpa7BP83ayjw1AChZ/view?usp=sharing – Mackenzie Miller Oct 31 '18 at 14:36
  • Could you please tell me what is the source of the data? – utubun Oct 31 '18 at 20:37

1 Answers1

0

Ok, I am trying to fight my way back from my own imagination, away from the dark vision of decomposed composers... However, if season means year, and decomposition means summary of the composer's popularity over the year, using your data, it might be done this way:

library(tidyverse)
library(lubridate)
library(ggthemes)

read_csv("test2.csv") %>%     
  mutate(date = ymd(paste(month,"-01", sep="")), month = NULL) %>%
  mutate(season = cut(date, "year")) %>% 
  group_by(season, composer) %>%
  summarise(popularity = mean(popularity)) %>%
  ggplot(aes(x = year(season), y = popularity, group = composer, colour = composer)) +
      geom_line(alpha = 0.75) +
      ggthemes::scale_colour_gdocs(name = "Composer:") + # comment out this line
      labs(x = "Season", y = "Popularity") +
      ggthemes::theme_few()                              # comment out this line

trendy composers

utubun
  • 4,400
  • 1
  • 14
  • 17