---
title: "R Notebook"
output:
html_document:
df_print: paged
html_notebook: default
pdf_document: default
---
###Read in data and subset to intermittent streams that we could sample (were not completely dry)
```{r}
rm(list = ls())
df <- read.csv("~/Dropbox/Active/Arizona/1) CA Smith Fellowship/Ecosphere Submission/Datasets/DataS2.csv", header = T, skip = 1)
#Subset df to intermittent streams
df_i <- df[which(df$Flow.class=="Intermittent"),]
df_i <- df_i[which(df_i$Invertebrate.richness!=0),]
```
###Days flowing by protected area
```{r}
with(df_i, shapiro.test(Days.flowing[Basin == "Pinnacles"]))
with(df_i, shapiro.test(Days.flowing[Basin == "Point Reyes"]))
var.test(Days.flowing ~ Basin, df_i, alternative = "two.sided")
wilcox.test(Days.flowing ~ Basin, df_i, alternative = "two.sided")
plot(Days.flowing ~ Basin, df_i)
```
###Drying frequency by protected area
```{r}
with(df_i, shapiro.test(Drying.frequency[Basin == "Pinnacles"]))
with(df_i, shapiro.test(Drying.frequency[Basin == "Point Reyes"]))
var.test(Drying.frequency ~ Basin, df_i, alternative = "two.sided")
wilcox.test(Drying.frequency ~ Basin, df_i, alternative = "less")
plot(Drying.frequency ~ Basin, df_i)
```
###Flow permanence by protected area
```{r}
with(df_i, shapiro.test(Flow.permanence[Basin == "Pinnacles"]))
with(df_i, shapiro.test(Flow.permanence[Basin == "Point Reyes"]))
var.test(Flow.permanence ~ Basin, df_i, alternative = "two.sided")
wilcox.test(Flow.permanence ~ Basin, data = df_i)
plot(Flow.permanence ~ Basin, data = df_i)
```
###Distance to perennial refuge by protected area
```{r}
with(df_i, shapiro.test(Stream.distance.to.perennial.refuge..m.[Basin == "Pinnacles"]))
with(df_i, shapiro.test(Stream.distance.to.perennial.refuge..m.[Basin == "Point Reyes"]))
var.test(Stream.distance.to.perennial.refuge..m. ~ Basin, df_i, alternative = "two.sided")
wilcox.test(Stream.distance.to.perennial.refuge..m. ~ Basin, data = df_i, alternative = "greater")
plot(Stream.distance.to.perennial.refuge..m. ~ Basin, data = df_i)
```