This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# > head(m_mm_ac) | |
# month.order year accumulated.value | |
# 1 10 2007 0.6 | |
# 2 11 2007 26.7 | |
# 3 12 2007 68.3 | |
# > head(m_t_mean) | |
# month.order year mean.value | |
# 1 10 2007 22.48750 | |
# 2 11 2007 21.04500 | |
# 3 12 2007 23.29516 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calera_organized <- OrganizeDateColumns(data.x = calera_raw, ncol.date = 1, orders = "mdyHMS", ncol.day = NULL, ncol.month = NULL, ncol.year = NULL) | |
head(calera_organized) | |
# | |
# > head(calera_organized) | |
# fecha mm temp humedad day month year | |
# 1 2018-04-27 0 22.8 49.8 27 4 2018 | |
# 2 2018-04-27 0 24.0 47.9 27 4 2018 | |
# 3 2018-04-27 0 26.4 45.5 27 4 2018 | |
# 4 2018-04-27 0 25.9 49.7 27 4 2018 | |
# 5 2018-04-27 0 26.0 56.7 27 4 2018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HourlyToDaily <- function(data.x, ncol.obs, ncol.date, na.presence = TRUE, value = "mean") { | |
# | |
if (!any(value == c("mean", "accumulated"))) { | |
stop(" value must to be 'mean' or 'accumulated'") | |
} | |
# Calculate the mean of the variable of interest | |
first.year <- min(data.x$year, na.rm = na.presence) | |
last.year <- max(data.x$year, na.rm = na.presence) | |
x.daily.per.years <- list() | |
date.tot <- list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First we read the .csv with the data from La Calera | |
# | |
calera_raw <- read.csv(".../meteorologicos_la_calera.csv") | |
head(calera_raw) | |
# | |
#> head(calera) | |
# fecha mm temp humedad | |
# 1 04/27/2018 17:00:00 0 22.8 49.8 | |
# 2 04/27/2018 16:00:00 0 24.0 47.9 | |
# 3 04/27/2018 15:00:00 0 26.4 45.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function that creates day, month and year columns. | |
# | |
OrganizeDateColumns <- function(data.x, ncol.date = 1, orders = "mdyHMS", ncol.day = NULL, ncol.month = NULL, ncol.year = NULL) { | |
# | |
require(lubridate) | |
# | |
# Organizes dates's columns using lubridate | |
# If columns with days, months or years are NULL, creates these columns with a | |
# function inside the function | |
# |