# Here is an outline of the code we'll start with
## Copy and paste all of this into a .Rmd R markdown file.

## Fill in the missing functions or other information
## (as-is it won’t work)

## Some data I made up
telos.dist  <- rnorm(n = 10, mean = 1000, sd = 30)
telos.cntrl  <- rnorm(n = 10, mean = 1000, sd = 30)

## calculate means
mean.dist <-  mean(telos.dist)
mean.cntrl <-  mean(telos.cntrl)

## calculate standard deviations
sd.dist <-  sd(telos.dist)
sd.cntrl <-  sd(telos.cntrl)

## determine sample size (HINT: function has a name related 
##   to geometry, not sample size)
N.dist  <-   length(telos.dist)
N.cntrl <-   length(telos.cntrl)


## calculate standard error (SD)
se.dist <- sd.dist/sqrt(N.dist)
se.cntrl <- sd.cntrl/sqrt(N.cntrl)

## Challenge - make a vector the letter "D" to indicate
### the disturbance treatment.
trt.dist  <- rep("D", times = N.dist)

##make a vector the letter "C" to indicate
### the control treatment.  
trt.cntrl <- rep("C", times = N.cntrl)

  
## Make a vector consolidating the data vectors  
telos <- c(telos.dist, telos.cntrl)
trt   <- c(trt.dist, trt.cntrl)

## Make a dataframe
df <- data.frame(telos, trt)
df
##        telos trt
## 1  1005.7883   D
## 2   983.4808   D
## 3  1040.0836   D
## 4  1068.4442   D
## 5  1032.5289   D
## 6  1016.8941   D
## 7   961.2624   D
## 8   973.3319   D
## 9   985.8701   D
## 10 1037.1786   D
## 11 1013.1562   C
## 12 1029.8702   C
## 13 1003.6704   C
## 14 1035.1856   C
## 15 1005.6464   C
## 16  999.5078   C
## 17 1009.4223   C
## 18 1039.6905   C
## 19 1010.8105   C
## 20 1056.1669   C
## Load the lowbrow_errbars() function
### from 
# https://docs.google.com/document/d/1uTwQXbmnQfYvMi2oaDCStK02_N8jle73mkAQAFVh47s/edit?usp=sharing

## Make plot
#lowbrow_errbars(means = c(mean.dist, mean.cntrl),
#                SEs =  c(se.dist, se.cntrl))

## Run a t-test
t.test(telos ~ trt, data = df)
## 
##  Welch Two Sample t-test
## 
## data:  telos by trt
## t = 0.79373, df = 13.913, p-value = 0.4407
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -16.74185  36.39459
## sample estimates:
## mean in group C mean in group D 
##        1020.313        1010.486
boxplot(telos ~ trt, data = df)

Experimenting with Randomly Generated DataSets

##How to Create Random data in R, Random Normal Data
  #runif()
  #rnorm()
  #sample(c())

telos.dist <- rnorm(n = 10000, mean = 1000, sd = 30)
hist(telos.dist)
#Helpful function is abline()
abline(v = mean(telos.dist), lwd = 3, col = 2)