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
  • 9,535
  • 1
  • 17
  • 24