0

I have financial data (CleanStocks.csv) that include sectors, companies, and their stock prices. I needed to find out find how many companies were in each sector so I did table(CleanStocks$Sector) which gave me this:

Consumer Discretionary           Consumer Staples                     Energy 
                    55                         25                          6 
            Financials                Health Care                Industrials 
                    60                         35                         52 
Information Technology                  Materials                Real Estate 
                    39                         20                         27 

Now I need to get sd(CleanStocks$Price) and mean(CleanStock$Price) for the companies in each of the sectors above into the table also and don't really know where to start, seems simple but I'm stuck

1 Answers1

0
tapply(CleanStocks$Price,CleanStocks$Sector,mean)
tapply(CleanStocks$Price,CleanStocks$Sector,sd)
user2974951
  • 7,144
  • 1
  • 13
  • 21
  • @AbbeyLewis If the answer helped feel free to accept the answer by clicking on check mark to the left. You can accept only one answer per post. Refer - https://stackoverflow.com/help/someone-answers – Ronak Shah Mar 04 '21 at 08:52