Commit 7129bdfe authored by Nicolau Manubens's avatar Nicolau Manubens
Browse files

Small fixes.

parent 23cb4a5e
......@@ -60,7 +60,7 @@ NcToArray <- function(file_to_read, dim_indices = NULL, vars_to_read = NULL,
print_error <- TRUE
}
if (print_error) {
stop("The variables to take specified in 'vars_to_read' or in 'dim_indices[['var']]' must be one or a list of numeric vectors or vectors of character strings or NULL.")
stop("The variables to take specified in 'vars_to_read' or in 'dim_indices[['var']]' must be one or a list of numeric vectors or vectors of character strings.")
}
# if (!is.character(vars_to_read) && !is.numeric(vars_to_read)) {
# stop("Parameter 'vars_to_read' must be a numeric vector or vector of character strings.")
......@@ -229,23 +229,23 @@ NcToArray <- function(file_to_read, dim_indices = NULL, vars_to_read = NULL,
names(dim(var_result)) <- sapply(file_object$var[[var_name]]$dim, '[[', 'name')
}
if (!is.null(var_result)) {
if (units %in% c('seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years')) {
if (units == 'seconds') {
units <- 'secs'
} else if (units == 'minutes') {
units <- 'mins'
}
var_result[] <- paste(var_result, units)
} else if (grepl(' since ', units)) {
parts <- strsplit(units, ' since ')[[1]]
units <- parts[1]
if (units == 'seconds') {
units <- 'secs'
} else if (units == 'minutes') {
units <- 'mins'
}
var_result <- seq(as.POSIXct(parts[2]), length = max(var_result, na.rm = TRUE) + 1, by = units)[var_result + 1]
}
# if (units %in% c('seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years')) {
# if (units == 'seconds') {
# units <- 'secs'
# } else if (units == 'minutes') {
# units <- 'mins'
# }
# var_result[] <- paste(var_result, units)
# } else if (grepl(' since ', units)) {
# parts <- strsplit(units, ' since ')[[1]]
# units <- parts[1]
# if (units == 'seconds') {
# units <- 'secs'
# } else if (units == 'minutes') {
# units <- 'mins'
# }
# var_result <- seq(as.POSIXct(parts[2]), length = max(var_result, na.rm = TRUE) + 1, by = units)[var_result + 1]
# }
if (!drop_var_dim && (length(vars_to_read_vector) == 1)) {
dim(var_result) <- c(c(var = 1), dim(var_result))
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment