0

How do I predict the sales at the mean price level for each brand in this cvs file?

And then how do I model sales as a function of the interaction between price and brand, and the other interaction between price and feature, using log?

This is what I have done for the first part:

x = mean(drinks$price)
print(x)

but I don't understand how I can get the mean price for each individual brand and then predict the sales for each of those brands.

Here is a part of my csv file (called drinks.cvs):

# store week  brand     sales   price  feature
1   2   40  tropicana   8256    3.87    0
2   2   46  tropicana   6144    3.87    0
3   2   47  tropicana   3840    3.87    0
4   2   48  tropicana   8000    3.87    0
5   2   50  tropicana   8896    3.87    0
6   2   86  minute.maid 15104   2.09    0
7   2   87  minute.maid 76480   1.39    1
8   2   88  minute.maid 5056    2.39    0
9   2   89  minute.maid 4736    2.39    0
10  2   90  minute.maid 4480    2.39    0
11  2   140 dominicks   4800    2.09    0
12  2   141 dominicks   9664    1.69    0
13  2   142 dominicks   45568   1.69    0
14  2   143 dominicks   20992   1.74    0
15  2   144 dominicks   6592    2.09    0
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • Please add a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). That way you can help others to help you! – dario Feb 10 '20 at 16:33
  • You need to read the csv file into an R data frame, then slice it by brand to calculate the mean price for each brand. Google and the R documentation have lots of help and example data frames you can practice with. – Nigel Davies Feb 10 '20 at 16:59
  • 2
    This has nothing to do with RStudio specifically. This is just about R. And this doesn't really seem to be a specific programming question that's appropriate for Stack Overflow. If you have general questions about statistical model fitting, then you should ask such questions over at [stats.se] instead. You are more likely to get better answers there. If you want to predict you need to specify some sort of model. If this is for a class, I suggest you contact your teacher for help first rather than Stack Overflow. – MrFlick Feb 10 '20 at 16:59

0 Answers0