I want to take averages of certain columns in my excel sheet that I have imported into R Studio but I am not sure how. For example, I have the column "period type" and I want to take the average of the number of sales associated with "period type". But before I take the average of sales, how do I pull the column from my excel sheet if the excel sheet has already been imported?
Asked
Active
Viewed 1,790 times
-2
-
1You'll need to provide more information beyond descriptions. See the following link for how to create an example: https://stackoverflow.com/help/minimal-reproducible-example – manotheshark Dec 30 '19 at 17:31
-
1Ok, welcome to so, this is a really vague question, can you provide us the data using either the dput function or some other form of reproducible example see.https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Bruno Dec 30 '19 at 17:32
1 Answers
0
The following might be something you are looking for. Ensure header is set to TRUE, which names all the columns as you import it. The '$' allows you to reference one particular column from the data matrix.
diamond<- read.csv(file="diamonddata.csv", header=TRUE)
diamond$clarity

mckennae
- 46
- 3