Make basic stats with your data

1. Lets try doing some basic stats with the data from the previous modules.

2. If the previous data got lost, type it in again into the script as data<-read.csv("").

3. In order to find the mean, type mean() into the script with what you want to find the mean of.

4. In the dataset from above, lets find the mean calories. Type mean(data$Calories) into the script. Then, press Run.

5. The console should look like below. The mean number of calories in everything in the menu is 368.2692 calories.

6. In order to produce tests of significance, use the formula: cor()

7. To do this with our data, try looking at the significance between Calories and Fat using the formula: cor(data$Calories,data$Fat).

8. In the console, the following should be there. The correlation is 0.90.

9. To test a single correlation coefficient, use the formula cor.test()

10. Using our dataset to test a single correlation coefficient, use the variables Calories and Fat. Enter the script: cor.test(data$Calories,data$Fat). Then, press, Run.

11. Pearson's product-moment correlation should come up in the console, like the following. Here you can see, the t test, degrees of value, p-value, 95 percent confidence interval and the correlation between the variables.

12. Try making another correlation between two other variables in the dataset.

13. An independent 2-group t test is where one variable is the numbers and the other is a binary (tall versus short) factor. You can make it binary by selecting rows 1 through 57 that category becomes binary because there are only 2 options by typing x<-(data$Calories[1:57]).

14. Then, use the formula t.test() in order to run the t-test. Type: t.test(x~y) in the console.

15. The following should come up in the console.