Commit b2320717 authored by Dorchies David's avatar Dorchies David
Browse files

refactor: Add capital letter to class names

Refs #1
Showing with 13 additions and 12 deletions
+13 -12
......@@ -9,13 +9,13 @@
#' @export
#'
#' @examples
ginet <- function(db, cols = list(id = "id", down = "down", length = "length", runoff = "runoff"), keep_all = FALSE) {
Ginet <- function(db, cols = list(id = "id", down = "down", length = "length", runoff = "runoff"), keep_all = FALSE) {
colsDefault <- list(id = "id", down = "down", length = "length", runoff = "runoff")
cols <- utils::modifyList(colsDefault, as.list(cols))
db <- dplyr::rename(db, unlist(cols))
if(!keep_all) {
db <- dplyr::select(db, names(cols))
}
class(db) <- append(class(db), "ginet")
class(db) <- append(class(db), "Ginet")
db
}
......@@ -8,7 +8,7 @@
#' @export
#'
#' @examples
girop <- function(db, cols = c(id = "id", area = "area", model = "model", params = "params"), keep_all = FALSE) {
Girop <- function(db, cols = c(id = "id", area = "area", model = "model", params = "params"), keep_all = FALSE) {
colsDefault <- list(id = "id", area = "area", model = "model", params = "params")
cols <- utils::modifyList(colsDefault, as.list(cols))
if(!any(names(db) == cols$params)) {
......@@ -19,6 +19,6 @@ girop <- function(db, cols = c(id = "id", area = "area", model = "model", params
if(!keep_all) {
db <- dplyr::select(db, names(cols))
}
class(db) <- append(class(db), "girop")
class(db) <- append(class(db), "Girop")
db
}
......@@ -8,7 +8,7 @@
#' @export
#'
#' @examples
gits <- function(id, ts,
Gits <- function(id, ts,
cols = list(date = "date", Precip = "Precip", PotEvap = "PotEvap", Qobs = "Qobs")) {
cols <- as.list(cols)
......@@ -16,7 +16,7 @@ gits <- function(id, ts,
gitsOut <- list(date = ts$date)
cols$date <- NULL
gitsOut[[id]] <- dplyr::select(ts, names(cols))
class(gitsOut) <- append(class(gitsOut), "gits")
class(gitsOut) <- append(class(gitsOut), "Gits")
gitsOut
}
......@@ -29,9 +29,10 @@ gits <- function(id, ts,
#' @export
#'
#' @examples
merge.gits <- function(x, y) {
if(!is(y, "gits")) {
stop("A gits class object can only be merged with a gits class object")
merge.Gits <- function(x, y) {
browser()
if(!is(y, "Gits")) {
stop("A Gits class object can only be merged with a Gits class object")
}
if(! identical(x$date, y$date)) {
stop("Time series dates are not identical")
......
......@@ -32,7 +32,7 @@ Create the ginet object
# Specify that all nodes are of run-off type
seine_nodes$runoff = TRUE
# Generate the ginet object
ginetSeine <- ginet(seine_nodes, list(id = "id_sgl", down = "id_aval", length = "distance_aval"))
ginetSeine <- Ginet(seine_nodes, list(id = "id_sgl", down = "id_aval", length = "distance_aval"))
```
Create the girop object
......@@ -41,7 +41,7 @@ Create the girop object
# Specify which run-off model to use
seine_nodes$model = "RunModel_GR4J"
# Generate girop object
giropSeine <- girop(seine_nodes, list(id = "id_sgl", area = "area"))
giropSeine <- Girop(seine_nodes, list(id = "id_sgl", area = "area"))
```
......@@ -66,7 +66,7 @@ l <- lapply(urls, readr::read_delim, delim = ";", skip = 16, trim_ws = TRUE)
```
```{r}
gitsSeine <- gits(ginetSeine$id[1], l[[ginetSeine$id[1]]], cols = list(date = "Date", Precip = "Ptot", PotEvap = "ETP", Qobs = "Qnat"))
gitsSeine <- Gits(ginetSeine$id[1], l[[ginetSeine$id[1]]], cols = list(date = "Date", Precip = "Ptot", PotEvap = "ETP", Qobs = "Qnat"))
for(id in ginetSeine$id) {
gitsSeine <- merge(gitsSeine, gits(id, l[[id]], cols = list(date = "Date", Precip = "Ptot", PotEvap = "ETP", Qobs = "Qnat")))
......
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