Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrohitjha authored Jul 19, 2024
1 parent dd5505a commit cded357
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions projectCode/example_data(garlic_mustard).R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
library(dplyr)
library(tidyverse)
library(dplyr)
library(ggplot2)
library(lubridate)
library(tidyr)
library(maps)

# list files in the Data folder
# get your file names to be consistent!
csv_files = list.files("Alliaria_petiolata", full.names = T)
list(csv_files)

data <- read.csv("Alliaria_petiolata/inat_annot_Alliaria_petiolata_USA_.csv")
nrow(data)

range(data$observed_on)


# Load necessary libraries
library(dplyr)
library(ggplot2)

# Load necessary libraries
library(dplyr)
library(ggplot2)

# Load necessary libraries
library(dplyr)
library(ggplot2)
library(lubridate) # For date handling


# Ensure the 'observed_on' column is in date format
data$observed_on <- as.Date(data$observed_on, format = "%Y-%m-%d")

# Calculate DOY (Day of Year)
data$DOY <- yday(data$observed_on)

# Filter data for observations since 2018 and exclude 2024
data_filtered <- data %>% filter(year(observed_on) >= 2018 & year(observed_on) < 2024)

# Extract the year from the observation date
data_filtered$year <- year(data_filtered$observed_on)

# Group by year and calculate mean latitude and mean DOY of flowers
grouped_data <- data_filtered %>%
filter(flowers == "Y") %>%
group_by(year) %>%
summarize(mean_latitude = mean(latitude, na.rm = TRUE),
mean_DOY_flowers = mean(DOY, na.rm = TRUE))

# Plotting
ggplot(data_filtered, aes(x = latitude, y = DOY,
color = as.factor(year))) +
geom_point() +
geom_smooth(method = "lm") +
labs(x = "Mean Latitude", y = "Mean DOY of Flowers", title = "Mean Latitude vs Mean DOY of Flowers (2018-2023)") +
theme_minimal()


0 comments on commit cded357

Please sign in to comment.