Re: [R] Creating a year-month indicator and groupby with category

2022-10-04 Thread Rui Barradas
Hello, The error comes from having 2 colors and 4 labels in scale_colour_manual("", values = c(f_cols[1], m_cols[1]), labels = c("F", "M" , "C" , "G")) You need the same number of colors and labels. For instance, though they're probably not the colors you want the following vector has 4

Re: [R] Creating a year-month indicator and groupby with category

2022-10-03 Thread Tariq Khasiri
Thanks everyone for being so kind and patient with me throughout the process! Mr. Barradas and Mr. Lemon, very generous of you for taking the time and patience to go over my code and data , and taking the time to give me meaningful feedback! With your help and suggestion, I was successful in

Re: [R] Creating a year-month indicator and groupby with category

2022-10-03 Thread Jim Lemon
Hi Tariq, There were a couple of glitches in your data structure. Here's an example of a simple plot: dat<-structure(list(year = c(2018, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2018, 2018, 2018, 2018, 2018, 2018, 2018,

Re: [R] Creating a year-month indicator and groupby with category

2022-10-02 Thread Rui Barradas
Hello, First of all, I'll repost the data at end because the OP posted with a pointer ref: problems = and this must be removed for the dput output to run. Suggestion: coerce to class "data.frame" and post the output of dput(as.data.frame(dat)) Now the plot. Here are two plots of share

[R] Creating a year-month indicator and groupby with category

2022-10-02 Thread Tariq Khasiri
Hello, I have the following data. I want to show in a line plot how each different company is earning over the timeline of my data sample. I'm not sure how I can create the *year-month indicator* to plot it nicely in my horizontal axis out of my dataset. After creating the *year-month*