-
Notifications
You must be signed in to change notification settings - Fork 6
/
confidence_interval.Rmd
46 lines (25 loc) · 1.84 KB
/
confidence_interval.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
```{r}
#Load in your 20 viral scaffolds data set (you may need to get this file from Emily, Nada, or Amanda if you don't have it already.)
#twenty_viral_scaffolds <-
#twenty_viral_scaffolds
```
```{r}
#In order to write a function to calculate a 95% confidence interval for the mean of the 20 scaffolds data set, you will need to use a function called qt(), which outputs the t-value for a given confidence level and sample size.
#For example, if I want the two-tailed t-value for a confidence level of 95% and a sample size of 50, I would write:
qt(p=0.975, df = 49)
#We use p = 0.975, and not p = 0.95, because this is a two-tailed test: 1 - 0.975 is 0.025, and so the margin of error contains the mean +/- t at 0.025, or a total error of 0.05.
```
```{r}
#Write a function to output a confidence interval, based on the formula we discussed today, and using the function qt() to generate the t-value at a given confidence level.
conf_int <-
#Calculate the 95% confidence interval for the twenty scaffolds data set.
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.