Skip to content

Instantly share code, notes, and snippets.

View joshcullen's full-sized avatar

Josh Cullen joshcullen

View GitHub Profile
### Example script for checking status of URLs ###
library(httr)
library(glue)
# Define info for wind
get_date <- Sys.Date()
product_erddap = "erdQCwindproducts1day"
variable_erddap = "wind_v"
@joshcullen
joshcullen / Calculate weighted KDE.R
Last active July 19, 2024 15:10
Example for calculating a weighted KDE using the {ks} R package
# Example for generating weighted KDE using {ks}
library(tidyverse)
library(ks)
library(sf)
library(terra)
library(tidyterra)
@joshcullen
joshcullen / Create bathymetric map.R
Created December 4, 2023 17:09
Example for creating bathymetric map via GEBCO COG
### Example for quickly plotting bathymetry data from Cloud-optimized geotiff (COG) via GEBCO ###
library(tidyverse)
library(sf)
library(terra)
library(tidyterra)
library(rnaturalearth)
library(cmocean)
@joshcullen
joshcullen / Measure UD overlap.R
Created April 21, 2022 18:36
Example for measuring UD overlap
## Example for calculating UD overlap based on indices from Fieberg and Kochanny (2005)
library(move)
library(raster)
# Load example data from {move}
data("dbbmmstack")
@joshcullen
joshcullen / code.R
Created February 9, 2022 19:17
Example for creating new columns based on existing ones
#creation of fake data for example
dat<- data.frame(subregion_name = rep(c("DRTO","KEYW","BISC"), each = 5),
year = rep(2014:2018))
dat.new<- dat %>%
#create new variable to index whether SCTLD has been detected or not; replace these years with the year of first detection per region
mutate(sctld_pres = case_when(subregion_name == "DRTO" & year < 2020 ~ "NotDetected",
subregion_name == "KEYW" & year < 2017 ~ "NotDetected",
subregion_name == "BISC" & year < 2015 ~ "NotDetected",
@joshcullen
joshcullen / Remove points before deployment.R
Created January 24, 2022 20:17
Example for removing testing locations before tags were deployed
library(tidyverse)
library(sf)
library(rnaturalearth)
## SET YOUR WORKING DIRECTORY ACCORDINGLY
## Load your data here
dat<- read.csv("CrystalRiver_Bimini_Cm_data.csv")
@joshcullen
joshcullen / Facet plot example.R
Last active January 21, 2022 16:26
An example for facet plotting spatial data
### Example for creating a facet plot by year for mapping spatiotemporal patterns of FP ###
library(tidyverse)
### import data
capture_data <- read.csv("Data/2021-10_Cm_capture_data.csv")
fp_scores <- read.csv("Data/2021-10_Cm_FP_Scores.csv")