updated date format for excel

This commit is contained in:
Martin Folkerts 2024-10-28 15:57:23 +01:00
parent f08da04c3b
commit ddb4fdbc02
2 changed files with 10 additions and 4 deletions

Binary file not shown.

View file

@ -52,25 +52,31 @@ harvesting_data <- read_excel(here(data_dir, "harvest.xlsx")) %>%
field = as.character(field),
sub_field = as.character(sub_field),
year = as.numeric(year),
season_start = as.Date(season_start),
season_end = as.Date(season_end),
season_start = as.Date(season_start, format="%d/%m/%Y"),
season_end = as.Date(season_end, format="%d/%m/%Y"),
age = as.numeric(age),
sub_area = as.character(sub_area),
tonnage_ha = as.numeric(tonnage_ha)
) %>%
mutate(
season_end = case_when(season_end > Sys.Date() ~ Sys.Date(),
is.na(season_end) ~ Sys.Date(),
TRUE ~ season_end),
age = round(as.numeric(season_end - season_start) / 7, 0)
)
log_file <- here(log_dir, paste0(format(Sys.Date(), "%Y%m%d"), ".log"))
# Create a logging function
log_message <- function(message) {
cat(message, "\n", file = log_file, append = TRUE)
}
log_head <- function(list) {
log_message(paste(capture.output(str(head(AllPivots0))), collapse = "\n"))
log_message(paste(capture.output(str(head(list))), collapse = "\n"))
}