bb <- getbb("Florida")
tmp <- c(2,1,4,3)
sb_bb <- bb[tmp]
test <- get_inat_obs(
  taxon_id = 551307,
  place_id = 21,
  maxresults = 3512,
  bounds = sb_bb,
  geo = TRUE,
  meta = FALSE)
mypoints <- test[
  test$coordinates_obscured == "false" &
    test$quality_grade == "research", ]
library(readxl)
setwd("~/UNC 25-26/Fall/GEOG 391")
library(readr)
Sharks <- read_csv("C:/Users/Kendall/OneDrive/Documents/UNC 25-26/Fall/Geog 391/Sharks.csv")
## Rows: 34 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): NAME
## dbl (5): totalsight, totalbite, avgseverity, fatal, beach
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(Sharks)
attach(Sharks)
par(xpd=TRUE)
ggplot(data = Sharks, mapping = aes(x=beach, y=totalbite))+
  geom_point(aes(color=NAME, size=beach))+
  geom_smooth()+
  geom_smooth(method = 'lm')+
  xlab("Coastline Length (miles)")+
  ylab("Number of Shark Attacks")+
  ggtitle("Number of Shark Attacks by County Coastline Length")+ 
  theme(legend.text = element_text(size = 8),
        legend.box.spacing = unit(0.25, "cm"),
        legend.key.size = unit(.25, "cm"),
        legend.title = element_text(size = 14, face = "bold"))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

par(xpd=TRUE)
ggplot(data = Sharks, mapping = aes(x=beach, y=totalsight))+
  geom_point(aes(color=NAME, size=beach))+
  geom_smooth()+
  geom_smooth(method = 'lm')+
  xlab("Coastline Length (miles)")+
  ylab("Number of Shark Sightings")+
  ggtitle("Number of Shark Sightings by County Coastline Length")+ 
  theme(legend.text = element_text(size = 8),
        legend.box.spacing = unit(0.25, "cm"),
        legend.key.size = unit(.25, "cm"),
        legend.title = element_text(size = 14, face = "bold"))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

p = ggplot(data=Sharks)+
  geom_point(mapping=aes(x=beach, y=totalbite), color="red", shape=15, size=2.5)+
  geom_smooth(mapping=aes(x=beach, y=totalbite), color="red")+
  geom_point(mapping=aes(x=beach, y=totalsight), color="dodgerblue", shape=16, size=2.5)+
  geom_smooth(mapping=aes(x=beach, y=totalsight), color="dodgerblue")+
  xlab("Length of Coastline")+
  ylab("Number of Bites and Sightings by Coastline Length")+
  ggtitle("Scatterplot of Number of Bites/Sightings by Type per Coasline Length")+
  theme_gray()
ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
lmbite <- lm(Sharks$totalbite~Sharks$beach)
summary(lmbite)
## 
## Call:
## lm(formula = Sharks$totalbite ~ Sharks$beach)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -63.882 -21.939  -1.329   9.022 285.188 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   -9.0915    15.4779  -0.587  0.56107   
## Sharks$beach   1.3915     0.5067   2.746  0.00982 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 55.29 on 32 degrees of freedom
## Multiple R-squared:  0.1907, Adjusted R-squared:  0.1654 
## F-statistic:  7.54 on 1 and 32 DF,  p-value: 0.009818
lmsight <- lm(Sharks$totalsight~Sharks$beach)
summary(lmsight)
## 
## Call:
## lm(formula = Sharks$totalsight ~ Sharks$beach)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -101.27  -30.28  -11.84    4.39  477.46 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   -3.4245    25.8380  -0.133   0.8954  
## Sharks$beach   1.9230     0.8459   2.273   0.0299 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 92.3 on 32 degrees of freedom
## Multiple R-squared:  0.139,  Adjusted R-squared:  0.1121 
## F-statistic: 5.168 on 1 and 32 DF,  p-value: 0.02986
btst <- lm(Sharks$totalsight~Sharks$totalbite)
summary(btst)
## 
## Call:
## lm(formula = Sharks$totalsight ~ Sharks$totalbite)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -72.89 -32.84 -24.71  -1.00 524.42 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)  
## (Intercept)       37.1043    18.2389   2.034   0.0503 .
## Sharks$totalbite   0.2406     0.2829   0.851   0.4014  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 98.37 on 32 degrees of freedom
## Multiple R-squared:  0.02211,    Adjusted R-squared:  -0.008453 
## F-statistic: 0.7234 on 1 and 32 DF,  p-value: 0.4014
multi <- lm(Sharks$totalbite~Sharks$totalsight+Sharks$beach)
summary(multi)
## 
## Call:
## lm(formula = Sharks$totalbite ~ Sharks$totalsight + Sharks$beach)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -64.630 -22.337  -1.343   9.068 284.747 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)  
## (Intercept)       -9.12624   15.72757  -0.580   0.5659  
## Sharks$totalsight -0.01016    0.10757  -0.094   0.9254  
## Sharks$beach       1.41099    0.55478   2.543   0.0162 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 56.17 on 31 degrees of freedom
## Multiple R-squared:  0.1909, Adjusted R-squared:  0.1387 
## F-statistic: 3.658 on 2 and 31 DF,  p-value: 0.03748

#Table of results

Regression t-value p-value Multiple r2
Bite 2.746 0.00982** 0.1907
Sight 2.273 0.0299* 0.139
Bite~Sight 0.851 0.4014 0.02211
Multi -0.58 0.03748 0.1909*