library(readr) library(dplyr) library(lubridate) # Read a delimited file into a tibble data <- read_csv("Downloads/S123_69f6a2b6440848bab051f597ff4a8bf2_CSV/_25_Million_Trees_Initiative_Survey_0.csv") # Examine the column specifications for a data frame spec(data) # Parse date-times with year, month, and day, hour, minute, and second components from col_character. data <- data %>% mutate( `Start Date of Planting` = mdy_hms(`Start Date of Planting`), `End Date of Planting` = mdy_hms(`End Date of Planting`) ) # Get/set months and years component of lanting date-time. data <- data %>% mutate( plant_month = month(`Start Date of Planting`), # Extracts the month plant_year = year(`Start Date of Planting`) # Extracts the year ) # Group by municipality & county and summerize the total number of trees planted. aggregated_data <- data %>% group_by(`Year of Planting`, `Month of Planting`, Municipality, County) %>% summarize(`Total Tree Plantings` = sum(`Number of Trees Planted`, na.rm = TRUE)) # View the aggregated data print(aggregated_data)