diff --git a/R/ginet.R b/R/ginet.R index c2aa2803cb0d6acf8e9905bc6ab2224598ee2848..46a52d14400de5dcf2679eebd09a1dd0f81c7bf2 100644 --- a/R/ginet.R +++ b/R/ginet.R @@ -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 } diff --git a/R/girop.R b/R/girop.R index 7b6addec3084982630bfa3eb1be587a092a3f680..45861aad6c4abb3b3dc9fd647311d83c82a8ca87 100644 --- a/R/girop.R +++ b/R/girop.R @@ -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 } diff --git a/R/gits.R b/R/gits.R index 97c1abda7c9f36ec2350827dc83cbfb2bb4083a0..6e4faad59a0480ff39dd2a9459acf560e815198e 100644 --- a/R/gits.R +++ b/R/gits.R @@ -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") diff --git a/vignettes/01_First_network.Rmd b/vignettes/01_First_network.Rmd index 0817edb2fbe9eeb55c86ba87715aed71b13344fd..138ed3494fe8955d7a50b36197cdcb22ed54546f 100644 --- a/vignettes/01_First_network.Rmd +++ b/vignettes/01_First_network.Rmd @@ -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")))