This homework we will be coding with the strategic coding tools!
Let’s bring in dem libraries first mon
library(pracma)
## Warning: package 'pracma' was built under R version 4.4.3
library(pryr)
## Warning: package 'pryr' was built under R version 4.4.3
##
## Attaching package: 'pryr'
## The following object is masked from 'package:pracma':
##
## bits
library(upscaler)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ purrr::compose() masks pryr::compose()
## ✖ purrr::cross() masks pracma::cross()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::partial() masks pryr::partial()
## ✖ dplyr::where() masks pryr::where()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(stringr)
# I put the data into the originalData folder for access but within that we only essentially want one file which is the count data. we will pull out the file names for each
c.file.l <- ""
nam <- list.files("OriginalData/NEON_count-landbird/")
for(i in nam){
fn <- paste("OriginalData/NEON_count-landbird/",i,"/",sep = "")
c.file <- list.files(fn,pattern = "*count",full.names = TRUE)
c.file.l <- c(c.file.l,c.file)
}
c.file.l <- c.file.l[2:11]
print(c.file.l)
## [1] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2015-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2015-06.expanded.20241118T065914Z.csv"
## [2] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2016-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2016-06.expanded.20241118T142515Z.csv"
## [3] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2017-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2017-06.expanded.20241118T043125Z.csv"
## [4] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2018-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2018-06.expanded.20241118T105926Z.csv"
## [5] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2019-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2019-06.expanded.20241118T064156Z.csv"
## [6] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2020-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2020-06.expanded.20241118T184512Z.csv"
## [7] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2020-07/NEON.D01.BART.DP1.10003.001.brd_countdata.2020-07.expanded.20241118T010504Z.csv"
## [8] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2021-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2021-06.expanded.20241118T105538Z.csv"
## [9] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2022-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2022-06.expanded.20241118T033934Z.csv"
## [10] "OriginalData/NEON_count-landbird/NEON.D01.BART.DP1.10003.001.2023-06/NEON.D01.BART.DP1.10003.001.brd_countdata.2023-06.expanded.20241118T091043Z.csv"
source_batch(folder = "Functions/")
## File "Functions//CalculateAbundance.R" sourced.
## File "Functions//CalculateRichness.R" sourced.
## File "Functions//CleanData.R" sourced.
## File "Functions//ExtractYear.R" sourced.
## File "Functions//GenerateHistograms.R" sourced.
## File "Functions//RunRegression.R" sourced.
clean_data()
## [1] "...checking function: clean_data()"
extract_year()
## [1] "2015" "2016" "2017" "2018" "2019" "2020" "2020" "2021"
calculate_abundance()
# show abundance values
print(read.csv(file = "abundance.csv",header = TRUE,sep = ","))
## year year_count
## 1 2015 454
## 2 2016 684
## 3 2017 411
## 4 2018 512
## 5 2019 402
## 6 2020 525
## 7 2021 906
## 8 2022 581
## 9 2023 513
calculate_richness()
## `summarise()` has grouped output by 'scientificName'. You can override using
## the `.groups` argument.
#show richness values
print(read.csv(file = "speciesrichness.csv",header = TRUE,sep = ","))
## year speciescount
## 1 2015 40
## 2 2016 38
## 3 2017 34
## 4 2018 36
## 5 2019 43
## 6 2020 45
## 7 2021 49
## 8 2022 38
## 9 2023 41
run_regression()
## `geom_smooth()` using formula = 'y ~ x'
below here are things that I did in upscaler to get everything setup
# Now that we have the file names we can make some pseudo code that will describe the order of operations for what we are going to do!
# build_function(c("clean_data","extract_year","calculate_abundance","calculate_richness","run_regression","generate_histograms"))
#### these are the things I did to make the
# and using the upscaler package we will create a folder
# add_folder()
```