0

I am trying to use ggplot2 to produce different visualization along with the regression model in it. This is not a HOMEWORK assignment!

I have a data science project that I need to produce. I have a dataset of three main products distributed over 7 regions. I want to create a plot by using ggplot2 that outputs 7 little screens in which have regression models in them. Please ask me for more clarification since this is my first time using ggplot2.

Here is my code:

 data1 %>% 
 mutate(PRODUCT_SUB_LINE_DESCR=as.character(PRODUCT_SUB_LINE_DESCR)) %>% 
 group_by(ACCTG_YEAR_KEY, PRODUCT_SUB_LINE_DESCR, CUST_REGION_DESCR) %>% 
 summarise(Sales= sum(Sales)) %>% 
 ggplot() + geom_smooth(aes(x=PRODUCT_SUB_LINE_DESCR,y=Sales,
   color=PRODUCT_SUB_LINE_DESCR), method = "lm",show.legend = F) + 
 facet_wrap(~CUST_REGION_DESCR) 

My output was 7 empty little screens. Why is that?enter image description here

Adam Ralphus
  • 339
  • 3
  • 14
  • We can't help you if you don't post a (sample) of your data or a reproducible example with fake data. – user3640617 Jun 04 '18 at 13:25
  • @user3640617 How do I post a sample of data on here? It is 5000 data points file ! – Adam Ralphus Jun 04 '18 at 13:28
  • Maybe whoever gave this post a thumb down gives a hint how to improve it instead of being passive aggressive! – Adam Ralphus Jun 04 '18 at 13:37
  • 1
    Not my downvote, but this question lacks a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example); If x-axis is categorical how do you expect to use `lm`? – pogibas Jun 04 '18 at 14:06
  • 2
    [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how to post an R question that we can answer. That includes posting a sample of your data, posting your desired outcome, and probably not taking offense when you get downvoted – camille Jun 04 '18 at 14:07

0 Answers0